commit: e8186ef489fa1d36d3c8116cb294ff8faf01ac55 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Fri Dec 9 04:51:29 2016 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Thu Dec 22 01:20:03 2016 +0000 URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=e8186ef4
catalyst-auto: rework run_cmd pass through Make the logfile the first arg so the rest of the args are the command to actually run. This allows us to properly quote arguments. tools/catalyst-auto | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tools/catalyst-auto b/tools/catalyst-auto index 793e0c6..ad4a95a 100755 --- a/tools/catalyst-auto +++ b/tools/catalyst-auto @@ -71,15 +71,16 @@ send_email() { /usr/sbin/sendmail -f "${EMAIL_FROM}" ${EMAIL_TO//,/ } } +# Usage: run_cmd <logfile> <command to run> run_cmd() { - local cmd=$1 - local logfile=$2 + local logfile="$1" + shift if [ $verbose = 1 ]; then - echo "*** Running command: ${cmd}" - ${cmd} 2>&1 | tee "${logfile}" + echo "*** Running command: $*" + "$@" 2>&1 | tee "${logfile}" else - ${cmd} &> "${logfile}" + "$@" &> "${logfile}" fi } @@ -220,7 +221,7 @@ if ! mkdir -p "${TMPDIR}"/{specs,kconfig,log}; then exit 1 fi -if ! run_cmd "pre_build" "${TMPDIR}/log/pre_build.log"; then +if ! run_cmd "${TMPDIR}/log/pre_build.log" pre_build; then send_email "Catalyst build error - pre_build" "The pre_build function failed" "${TMPDIR}/log/pre_build.log" exit 1 fi @@ -299,15 +300,15 @@ if [[ ${preclean} -eq 1 ]]; then fi # Create snapshot -if ! run_cmd "catalyst -c ${CATALYST_CONFIG} -s ${DATESTAMP}" "${TMPDIR}/log/snapshot.log"; then +if ! run_cmd "${TMPDIR}/log/snapshot.log" catalyst -c "${CATALYST_CONFIG}" -s "${DATESTAMP}"; then send_email "Catalyst build error - snapshot" "" "${TMPDIR}/log/snapshot.log" exit 1 fi build_failure=0 -timeprefix="" -which time >/dev/null && timeprefix="time" +timeprefix=() +which time >/dev/null && timeprefix=( "time" ) for a in "" ${SETS}; do if [ -z "${a}" ]; then @@ -320,7 +321,7 @@ for a in "" ${SETS}; do for i in ${!specs_var}; do LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log" - run_cmd "${timeprefix} catalyst -a -p -c ${CATALYST_CONFIG} -f ${i}" "${LOGFILE}" + run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -p -c "${CATALYST_CONFIG}" -f "${i}" if [ $? != 0 ]; then build_failure=1 send_email "Catalyst fatal build error - ${i}" "" "${LOGFILE}" @@ -330,7 +331,7 @@ for a in "" ${SETS}; do for i in ${!optional_specs_var}; do LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log" - run_cmd "${timeprefix} catalyst -a -p -c ${CATALYST_CONFIG} -f ${i}" "${LOGFILE}" + run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -a -p -c "${CATALYST_CONFIG}" -f "${i}" if [ $? != 0 ]; then build_failure=1 send_email "Catalyst non-fatal build error - ${i}" "" "${LOGFILE}" @@ -340,13 +341,13 @@ for a in "" ${SETS}; do for i in ${!specs_var} ${!optional_specs_var}; do LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::')_purge.log" - run_cmd "${timeprefix} catalyst -P -c ${CATALYST_CONFIG} -f ${i}" "${LOGFILE}" + run_cmd "${LOGFILE}" "${timeprefix[@]}" catalyst -P -c "${CATALYST_CONFIG}" -f "${i}" done update_symlinks done -if ! run_cmd "post_build" "${TMPDIR}/log/post_build.log"; then +if ! run_cmd "${TMPDIR}/log/post_build.log" post_build; then send_email "Catalyst build error - post_build" "The post_build function failed" "${TMPDIR}/log/post_build.log" exit 1 fi