Commit 2da5844d authored by Mattia Rizzolo's avatar Mattia Rizzolo

schroot-create: properly fail when apt fails

no need to mess with set -e/set +e, because the return code of apt-get
is shadowed by `tee` (unless -o pipefail is used, which is not the case
here).
Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent dc4259d1
......@@ -75,11 +75,9 @@ fi
robust_chroot_apt() {
set +e
sudo chroot $SCHROOT_TARGET apt-get $@ | tee $TMPLOG
local RESULT=$(egrep 'Failed to fetch.*(Unable to connect to|Connection failed|Size mismatch|Cannot initiate the connection to|Bad Gateway|Service Unavailable)' $TMPLOG || true)
set -e
if [ ! -z "$RESULT" ] ; then
if [ ! -z "$RESULT" ] || [ "${PIPESTATUS[0]}" -ne 0 ] ; then
echo "$(date -u) - 'apt-get $@' failed, sleeping 5min before retrying..."
sleep 5m
sudo chroot $SCHROOT_TARGET apt-get $@ || ( echo "$(date -u ) - 2nd 'apt-get $@' failed, giving up..." ; exit 1 )
......@@ -92,11 +90,9 @@ bootstrap() {
echo force-unsafe-io > "$SCHROOT_TARGET/etc/dpkg/dpkg.cfg.d/02dpkg-unsafe-io"
echo "Bootstraping $SUITE into $SCHROOT_TARGET now."
set +e
sudo debootstrap $SUITE $SCHROOT_TARGET $MIRROR | tee $TMPLOG
local RESULT=$(egrep "E: (Couldn't download packages|Invalid Release signature)" $TMPLOG || true)
set -e
if [ ! -z "$RESULT" ] ; then
if [ ! -z "$RESULT" ] || [ "${PIPESTATUS[0]}" -ne 0 ] ; then
echo "$(date -u) - initial debootstrap failed, sleeping 5min before retrying..."
sudo rm -rf --one-file-system $SCHROOT_TARGET
sleep 5m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment