1 |
commit: e2d27f67f5c832e30b4683917e2bd7e28f22cfb9 |
2 |
Author: Andreas K. Huettel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Aug 22 19:11:51 2020 +0000 |
4 |
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 29 12:33:37 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=e2d27f67 |
7 |
|
8 |
catalyst-auto: Allow parallel building of spec sets |
9 |
|
10 |
This assumes that the spec sets are logically independent from each other, |
11 |
i.e., building different ABIs. |
12 |
|
13 |
Code shamelessly adapted from locale-gen. |
14 |
|
15 |
Signed-off-by: Andreas K. Huettel <dilfridge <AT> gentoo.org> |
16 |
|
17 |
tools/catalyst-auto | 97 ++++++++++++++++++++++++++++++++++++----------------- |
18 |
1 file changed, 66 insertions(+), 31 deletions(-) |
19 |
|
20 |
diff --git a/tools/catalyst-auto b/tools/catalyst-auto |
21 |
index 34238c01..484eaffc 100755 |
22 |
--- a/tools/catalyst-auto |
23 |
+++ b/tools/catalyst-auto |
24 |
@@ -23,6 +23,7 @@ testing=0 |
25 |
preclean=0 |
26 |
lastrun=0 |
27 |
lock_file= |
28 |
+parallel_sets=1 |
29 |
|
30 |
usage() { |
31 |
local msg=$1 |
32 |
@@ -38,6 +39,7 @@ Usage: |
33 |
Options: |
34 |
-c|--config Specifies the config file to use (required) |
35 |
-C|--preclean Clean up loose artifacts from previous runs |
36 |
+ -j|--jobs <n> Build <n> spec sets in parallel |
37 |
-v|--verbose Send output of commands to console as well as log |
38 |
-k|--keep-tmpdir Don't remove temp dir when build finishes |
39 |
-t|--test Stop after mangling specs and copying files |
40 |
@@ -133,6 +135,10 @@ parse_args() { |
41 |
config_files+=("$1") |
42 |
shift |
43 |
;; |
44 |
+ -j|--jobs) |
45 |
+ parallel_sets="$1" |
46 |
+ shift |
47 |
+ ;; |
48 |
-v|--verbose) |
49 |
verbose=$(($verbose+1)) |
50 |
;; |
51 |
@@ -385,47 +391,76 @@ run_catalyst_commands() { |
52 |
timeprefix=() |
53 |
which time >/dev/null && timeprefix=( "time" ) |
54 |
|
55 |
+ JOB_PIDS=() |
56 |
+ JOB_RETS=() |
57 |
+ JOB_IDX_S=0 |
58 |
+ JOB_IDX_E=0 |
59 |
+ |
60 |
for a in "" ${SETS}; do |
61 |
- if [[ -z ${a} ]]; then |
62 |
- specs_var="SPECS" |
63 |
- optional_specs_var="OPTIONAL_SPECS" |
64 |
- else |
65 |
- specs_var="SET_${a}_SPECS" |
66 |
- optional_specs_var="SET_${a}_OPTIONAL_SPECS" |
67 |
+ |
68 |
+ if [[ $(( JOB_IDX_E - JOB_IDX_S )) == ${parallel_sets} ]] ; then |
69 |
+ wait ${JOB_PIDS[$(( JOB_IDX_S++ ))]} |
70 |
+ JOB_RETS+=( $? ) |
71 |
fi |
72 |
|
73 |
- for i in ${!specs_var}; do |
74 |
- LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log" |
75 |
- specpath=$(readlink -f "${i}") |
76 |
- run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}" |
77 |
- if [[ $? != 0 ]]; then |
78 |
- build_failure=1 |
79 |
- send_email "Catalyst fatal build error - ${i}" "" "${LOGFILE}" |
80 |
- continue 2 |
81 |
- else |
82 |
- trigger_post_build "${a}" "${i}" |
83 |
- fi |
84 |
- done |
85 |
+ ( |
86 |
|
87 |
- for i in ${!optional_specs_var}; do |
88 |
- LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log" |
89 |
- specpath=$(readlink -f "${i}") |
90 |
- run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}" |
91 |
- if [[ $? != 0 ]]; then |
92 |
- build_failure=1 |
93 |
- send_email "Catalyst non-fatal build error - ${i}" "" "${LOGFILE}" |
94 |
- break |
95 |
+ if [[ -z ${a} ]]; then |
96 |
+ specs_var="SPECS" |
97 |
+ optional_specs_var="OPTIONAL_SPECS" |
98 |
else |
99 |
- trigger_post_build "${a}" "${i}" |
100 |
+ specs_var="SET_${a}_SPECS" |
101 |
+ optional_specs_var="SET_${a}_OPTIONAL_SPECS" |
102 |
fi |
103 |
- done |
104 |
|
105 |
- # Do not purge yet, because there might be interdendency between specs |
106 |
- # in different build sets! |
107 |
+ for i in ${!specs_var}; do |
108 |
+ LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log" |
109 |
+ specpath=$(readlink -f "${i}") |
110 |
+ run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}" |
111 |
+ if [[ $? != 0 ]]; then |
112 |
+ build_failure=1 |
113 |
+ send_email "Catalyst fatal build error - ${i}" "" "${LOGFILE}" |
114 |
+ exit 1 |
115 |
+ else |
116 |
+ trigger_post_build "${a}" "${i}" |
117 |
+ fi |
118 |
+ done |
119 |
+ |
120 |
+ for i in ${!optional_specs_var}; do |
121 |
+ LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log" |
122 |
+ specpath=$(readlink -f "${i}") |
123 |
+ run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}" |
124 |
+ if [[ $? != 0 ]]; then |
125 |
+ build_failure=1 |
126 |
+ send_email "Catalyst non-fatal build error - ${i}" "" "${LOGFILE}" |
127 |
+ break |
128 |
+ else |
129 |
+ trigger_post_build "${a}" "${i}" |
130 |
+ fi |
131 |
+ done |
132 |
+ |
133 |
+ # Do not purge yet, because there might be interdendency between specs |
134 |
+ # in different build sets! |
135 |
+ |
136 |
+ update_symlinks |
137 |
+ |
138 |
+ exit ${build_failure} |
139 |
+ |
140 |
+ )& |
141 |
+ |
142 |
+ JOB_PIDS+=( $! ) |
143 |
+ : $(( ++JOB_IDX_E )) |
144 |
+ |
145 |
|
146 |
- update_symlinks |
147 |
done |
148 |
|
149 |
+ for (( i = JOB_IDX_S; i < JOB_IDX_E; ++i )) ; do |
150 |
+ wait ${JOB_PIDS[i]} |
151 |
+ JOB_RETS+=( $? ) |
152 |
+ done |
153 |
+ build_failure=$(( 0 ${JOB_RETS[@]/#/+} )) |
154 |
+ |
155 |
+ |
156 |
# Now do the cleanup |
157 |
for a in "" ${SETS}; do |
158 |
if [[ -z ${a} ]]; then |