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