catalyst-auto: Allow parallel building of spec sets
This assumes that the spec sets are logically independent from each other, i.e., building different ABIs. Code shamelessly adapted from locale-gen. Signed-off-by: Andreas K. Huettel <dilfridge@gentoo.org>
This commit is contained in:
parent
4e6ebec966
commit
e2d27f67f5
|
@ -23,6 +23,7 @@ testing=0
|
||||||
preclean=0
|
preclean=0
|
||||||
lastrun=0
|
lastrun=0
|
||||||
lock_file=
|
lock_file=
|
||||||
|
parallel_sets=1
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
local msg=$1
|
local msg=$1
|
||||||
|
@ -38,6 +39,7 @@ Usage:
|
||||||
Options:
|
Options:
|
||||||
-c|--config Specifies the config file to use (required)
|
-c|--config Specifies the config file to use (required)
|
||||||
-C|--preclean Clean up loose artifacts from previous runs
|
-C|--preclean Clean up loose artifacts from previous runs
|
||||||
|
-j|--jobs <n> Build <n> spec sets in parallel
|
||||||
-v|--verbose Send output of commands to console as well as log
|
-v|--verbose Send output of commands to console as well as log
|
||||||
-k|--keep-tmpdir Don't remove temp dir when build finishes
|
-k|--keep-tmpdir Don't remove temp dir when build finishes
|
||||||
-t|--test Stop after mangling specs and copying files
|
-t|--test Stop after mangling specs and copying files
|
||||||
|
@ -133,6 +135,10 @@ parse_args() {
|
||||||
config_files+=("$1")
|
config_files+=("$1")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-j|--jobs)
|
||||||
|
parallel_sets="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-v|--verbose)
|
-v|--verbose)
|
||||||
verbose=$(($verbose+1))
|
verbose=$(($verbose+1))
|
||||||
;;
|
;;
|
||||||
|
@ -385,47 +391,76 @@ run_catalyst_commands() {
|
||||||
timeprefix=()
|
timeprefix=()
|
||||||
which time >/dev/null && timeprefix=( "time" )
|
which time >/dev/null && timeprefix=( "time" )
|
||||||
|
|
||||||
|
JOB_PIDS=()
|
||||||
|
JOB_RETS=()
|
||||||
|
JOB_IDX_S=0
|
||||||
|
JOB_IDX_E=0
|
||||||
|
|
||||||
for a in "" ${SETS}; do
|
for a in "" ${SETS}; do
|
||||||
if [[ -z ${a} ]]; then
|
|
||||||
specs_var="SPECS"
|
if [[ $(( JOB_IDX_E - JOB_IDX_S )) == ${parallel_sets} ]] ; then
|
||||||
optional_specs_var="OPTIONAL_SPECS"
|
wait ${JOB_PIDS[$(( JOB_IDX_S++ ))]}
|
||||||
else
|
JOB_RETS+=( $? )
|
||||||
specs_var="SET_${a}_SPECS"
|
|
||||||
optional_specs_var="SET_${a}_OPTIONAL_SPECS"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in ${!specs_var}; do
|
(
|
||||||
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
|
|
||||||
specpath=$(readlink -f "${i}")
|
if [[ -z ${a} ]]; then
|
||||||
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}"
|
specs_var="SPECS"
|
||||||
if [[ $? != 0 ]]; then
|
optional_specs_var="OPTIONAL_SPECS"
|
||||||
build_failure=1
|
|
||||||
send_email "Catalyst fatal build error - ${i}" "" "${LOGFILE}"
|
|
||||||
continue 2
|
|
||||||
else
|
else
|
||||||
trigger_post_build "${a}" "${i}"
|
specs_var="SET_${a}_SPECS"
|
||||||
|
optional_specs_var="SET_${a}_OPTIONAL_SPECS"
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
for i in ${!optional_specs_var}; do
|
for i in ${!specs_var}; do
|
||||||
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
|
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
|
||||||
specpath=$(readlink -f "${i}")
|
specpath=$(readlink -f "${i}")
|
||||||
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}"
|
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}"
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
build_failure=1
|
build_failure=1
|
||||||
send_email "Catalyst non-fatal build error - ${i}" "" "${LOGFILE}"
|
send_email "Catalyst fatal build error - ${i}" "" "${LOGFILE}"
|
||||||
break
|
exit 1
|
||||||
else
|
else
|
||||||
trigger_post_build "${a}" "${i}"
|
trigger_post_build "${a}" "${i}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for i in ${!optional_specs_var}; do
|
||||||
|
LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
|
||||||
|
specpath=$(readlink -f "${i}")
|
||||||
|
run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -c "${CATALYST_CONFIG}" -f "${specpath}"
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
build_failure=1
|
||||||
|
send_email "Catalyst non-fatal build error - ${i}" "" "${LOGFILE}"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
trigger_post_build "${a}" "${i}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Do not purge yet, because there might be interdendency between specs
|
||||||
|
# in different build sets!
|
||||||
|
|
||||||
|
update_symlinks
|
||||||
|
|
||||||
|
exit ${build_failure}
|
||||||
|
|
||||||
|
)&
|
||||||
|
|
||||||
|
JOB_PIDS+=( $! )
|
||||||
|
: $(( ++JOB_IDX_E ))
|
||||||
|
|
||||||
# Do not purge yet, because there might be interdendency between specs
|
|
||||||
# in different build sets!
|
|
||||||
|
|
||||||
update_symlinks
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for (( i = JOB_IDX_S; i < JOB_IDX_E; ++i )) ; do
|
||||||
|
wait ${JOB_PIDS[i]}
|
||||||
|
JOB_RETS+=( $? )
|
||||||
|
done
|
||||||
|
build_failure=$(( 0 ${JOB_RETS[@]/#/+} ))
|
||||||
|
|
||||||
|
|
||||||
# Now do the cleanup
|
# Now do the cleanup
|
||||||
for a in "" ${SETS}; do
|
for a in "" ${SETS}; do
|
||||||
if [[ -z ${a} ]]; then
|
if [[ -z ${a} ]]; then
|
||||||
|
|
Loading…
Reference in a new issue