Module: check_mk
Branch: master
Commit: c0ce5d528bc279b04d1bcb796b53716364e32aba
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c0ce5d528bc279…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Wed Oct 18 12:50:18 2017 +0200
Win-agent build: improve error handling and cleanup
* Handle exit codes of functions and subprocesses.
* Update chown'd files (cleanup after build).
Change-Id: I462cffcfeb9f6e133b08790be7f72c623a3e1bfa
---
agents/windows/build-agent | 10 +++++++++-
agents/windows/build.sh | 6 +++---
agents/windows/make-agent | 2 +-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/agents/windows/build-agent b/agents/windows/build-agent
index 5b1728a..4f7fd61 100755
--- a/agents/windows/build-agent
+++ b/agents/windows/build-agent
@@ -10,6 +10,8 @@
#
# Requires the environment variable CHROOT_BUILD_DIR to be set.
+set -e
+
# Ensure that CHROOT_BUILD_DIR is set.
[[ -z $CHROOT_BUILD_DIR ]] && exit 1
@@ -29,10 +31,16 @@ elif [[ " $targets " =~ " unittest " ]] ; then
fi
# Build 32 and 64 bit in parallel, wait for child processes to terminate.
+children=()
for arch in "${build_archs[@]}" ; do
build $arch &
+ children+=($!)
+done
+
+for pid in "${children[@]}" ; do
+ # If any subprocess fails, wait for the rest to exit in a controlled way.
+ wait $pid || { wait; exit 1; }
done
-wait
# If no special targets given, produce msi installer as post-install step.
if [[ -z "$targets" ]] ; then
diff --git a/agents/windows/build.sh b/agents/windows/build.sh
index 7ad9fa2..4c18a4c 100644
--- a/agents/windows/build.sh
+++ b/agents/windows/build.sh
@@ -66,14 +66,14 @@ function build {
CC=${archs[$1]}${common}-gcc-posix \
CXX=${archs[$1]}${common}-g++-posix \
WINDRES=${archs[$1]}${common}-windres \
- STRIP=${archs[$1]}${common}-strip
+ STRIP=${archs[$1]}${common}-strip || return 1
# Default (no targets given): do parallel build and install non-debug exe's.
if [ -z "$targets" ] ; then
- make -j${njobs} && make install-strip
+ make -j${njobs} && make install-strip || return 1
else
# If special targets given, do just them.
- make -j${njobs} "$targets"
+ make -j${njobs} "$targets" || return 1
fi
cd -
}
diff --git a/agents/windows/make-agent b/agents/windows/make-agent
index ab91780..8183fd4 100755
--- a/agents/windows/make-agent
+++ b/agents/windows/make-agent
@@ -60,7 +60,7 @@ EXIT_CODE=$?
# Some cleanup: chown build artifacts to the original user.
find . -maxdepth 1 -regextype egrep \
--regex
'(.*\.(exe|msi|m4))|.*\/build.*|.*build_version|.*plugins|.*msibuild|.*Makefile.*|.*configure'
\
+-regex
'(.*\.(exe|msi|m4|cache|in))|.*\/.*build.*|.*plugins|.*Makefile.*|.*configure|.*comp.*|.*install.*|.*missing'
\
-exec sudo chown -R $USER:$USER {} \;
exit $EXIT_CODE