summaryrefslogtreecommitdiffstats
path: root/bin/schroot-create.sh
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2015-09-07 17:30:09 +0200
committerHolger Levsen <holger@layer-acht.org>2015-09-07 17:30:09 +0200
commita0eea0e2e743f0798668da61c5acc788e9478168 (patch)
tree05d6f278b9f02eec3e44b598e3c16fa772e52e37 /bin/schroot-create.sh
parent1b730f4c4b564254d79d0fb56bad72969b71e6d1 (diff)
downloadjenkins.debian.net-a0eea0e2e743f0798668da61c5acc788e9478168.tar.xz
retry debootstrap after 5min on failure
Diffstat (limited to 'bin/schroot-create.sh')
-rwxr-xr-xbin/schroot-create.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh
index 3c562565..1b23f7df 100755
--- a/bin/schroot-create.sh
+++ b/bin/schroot-create.sh
@@ -39,6 +39,8 @@ shift
SUITE="$1"
shift
+TMPLOG=$(mktemp)
+
declare -a EXTRA_SOURCES
if [ "$SUITE" = "experimental" ] ; then
# experimental cannot be bootstrapped
@@ -100,7 +102,17 @@ bootstrap() {
echo force-unsafe-io > "$CHROOT_TARGET/etc/dpkg/dpkg.cfg.d/02dpkg-unsafe-io"
echo "Bootstraping $SUITE into $CHROOT_TARGET now."
- sudo debootstrap $SUITE $CHROOT_TARGET $MIRROR
+ set +e
+ sudo debootstrap $SUITE $CHROOT_TARGET $MIRROR | tee $TMPLOG
+ RESULT=$(egrep "E: Couldn't download packages" $TMPLOG)
+ set -e
+ if [ -z "$RESULT" ] ; then
+ echo "$(date -u) - initial debootstrap failed, sleeping 5min before retrying..."
+ rm $CHROOT_TARGET -rf
+ sleep 5m
+ sudo debootstrap $SUITE $CHROOT_TARGET $MIRROR
+ fi
+ rm -f $TMPLOG
echo -e '#!/bin/sh\nexit 101' | sudo tee $CHROOT_TARGET/usr/sbin/policy-rc.d >/dev/null
sudo chmod +x $CHROOT_TARGET/usr/sbin/policy-rc.d
@@ -160,6 +172,7 @@ cleanup() {
if [ -d $CHROOT_TARGET ]; then
sudo rm -rf --one-file-system $CHROOT_TARGET || ( echo "Warning: $CHROOT_TARGET could not be fully removed on forced cleanup." ; fuser -mv $CHROOT_TARGET ; ls $CHROOT_TARGET -la )
fi
+ rm -f $TMPLOG
}
trap cleanup INT TERM EXIT
bootstrap $@