diff options
author | Holger Levsen <holger@layer-acht.org> | 2015-02-06 11:26:06 +0100 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2015-02-06 11:26:06 +0100 |
commit | 241a08af4dc322a58bbfda8f2cf948e40d870cd6 (patch) | |
tree | 5d88624c45647aa2c9c484e634ca2894f9d2df5d | |
parent | 815dadbbe03f63c4799e9c4330fd97a3e1a1a65f (diff) | |
download | jenkins.debian.net-241a08af4dc322a58bbfda8f2cf948e40d870cd6.tar.xz |
chroot-installation: use 'set -o pipefail' to really catch all the failures, thanks wRAR for the hint
-rwxr-xr-x | bin/chroot-installation.sh | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bin/chroot-installation.sh b/bin/chroot-installation.sh index ba0d9e28..8358005f 100755 --- a/bin/chroot-installation.sh +++ b/bin/chroot-installation.sh @@ -50,13 +50,17 @@ cleanup_all() { execute_ctmpfile() { chmod +x $CTMPFILE - sudo chroot $CHROOT_TARGET $TMPFILE 2>&1 | tee $TMPLOG - RESULT=$(egrep "Failed to fetch.*Unable to connect to" $TMPLOG || true) - if [ ! -z "$RESULT" ] ; then - echo - echo "Trying to workaround temporarily failure fetching packages, trying again..." - echo - sudo chroot $CHROOT_TARGET $TMPFILE + set -o pipefail # see eg http://petereisentraut.blogspot.com/2010/11/pipefail.html + if ! $(sudo chroot $CHROOT_TARGET $TMPFILE 2>&1 | tee $TMPLOG) ; then + RESULT=$(egrep "Failed to fetch.*Unable to connect to" $TMPLOG || true) + if [ ! -z "$RESULT" ] ; then + echo + echo "Trying to workaround temporarily failure fetching packages, trying again..." + echo + sudo chroot $CHROOT_TARGET $TMPFILE + else + exit 1 + fi fi rm $CTMPFILE echo "Debug: This should only be printed on success." |