diff options
author | Renato Botelho <renato@netgate.com> | 2017-08-22 09:57:53 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-08-22 10:11:04 -0300 |
commit | dd90320c41289d1bc9afbe4aa98cecd42cc0c470 (patch) | |
tree | a68e442f7e4ea460cbc66e2432876a0013cc0fa2 | |
parent | da058fe4c156e607227f1bac03a3ade42c475115 (diff) | |
download | pfsense-dd90320c41289d1bc9afbe4aa98cecd42cc0c470.zip pfsense-dd90320c41289d1bc9afbe4aa98cecd42cc0c470.tar.gz |
Teach build_snapshots.sh to read exit code of build.sh
-rwxr-xr-x | tools/build_snapshots.sh | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/tools/build_snapshots.sh b/tools/build_snapshots.sh index 5bcdf9e..46ef1cf 100755 --- a/tools/build_snapshots.sh +++ b/tools/build_snapshots.sh @@ -112,6 +112,23 @@ snapshot_update_status() { --snapshot-update-status "$*" } +exec_and_update_status() { + local _cmd="${@}" + + [ -z "${_cmd}" ] \ + && return 1 + + # Ref. https://stackoverflow.com/a/30658405 + exec 4>&1 + local _result=$( \ + { { ${_cmd} 2>&1 3>&-; printf $? 1>&3; } 4>&- \ + | while read -r LINE; do \ + snapshot_update_status "${LINE}"; done 1>&4; } 3>&1) + exec 4>&- + + return ${_result} +} + git_last_commit() { [ -z "${NO_RESET}" ] \ && git -C "${BUILDER_ROOT}" reset --hard >/dev/null 2>&1 @@ -198,25 +215,22 @@ while [ /bin/true ]; do IFS=" " if [ -n "${POUDRIERE_SNAPSHOTS}" ]; then - (${BUILDER_ROOT}/build.sh --update-poudriere-ports 2>&1) \ - | while read -r LINE; do - snapshot_update_status "${LINE}" - done - - (${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --update-pkg-repo 2>&1) \ - | while read -r LINE; do - snapshot_update_status "${LINE}" - done + exec_and_update_status \ + "${BUILDER_ROOT}/build.sh --update-poudriere-ports" \ + || exit $? + + exec_and_update_status \ + "${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --update-pkg-repo" \ + || exit $? else - (${BUILDER_ROOT}/build.sh --clean-builder 2>&1) \ - | while read -r LINE; do - snapshot_update_status "${LINE}" - done - - (${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --flash-size '2g 4g' \ - --snapshots ${NO_IMAGES} 2>&1) | while read -r LINE; do - snapshot_update_status "${LINE}" - done + exec_and_update_status \ + "${BUILDER_ROOT}/build.sh --clean-builder" \ + || exit $? + + exec_and_update_status \ + "${BUILDER_ROOT}/build.sh ${NO_UPLOAD} --flash-size '2g 4g' " \ + "--snapshots ${NO_IMAGES}" \ + || exit $? fi IFS=${OIFS} |