summaryrefslogtreecommitdiffstats
path: root/bin/schroot-create.sh
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2015-09-09 08:35:51 +0200
committerHolger Levsen <holger@layer-acht.org>2015-09-09 08:37:37 +0200
commit0af6aae3dd13faea83cb7c71144c8752e70ac3af (patch)
tree3529ee8a9e00e6f43070df880fe92313dfd919d2 /bin/schroot-create.sh
parent266184a88e52ebb12a4d6ba31061791cf72ef51a (diff)
downloadjenkins.debian.net-0af6aae3dd13faea83cb7c71144c8752e70ac3af.tar.xz
make 'apt-get update' more robust against network failures
Diffstat (limited to 'bin/schroot-create.sh')
-rwxr-xr-xbin/schroot-create.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh
index 4af2736a..dfeff867 100755
--- a/bin/schroot-create.sh
+++ b/bin/schroot-create.sh
@@ -97,6 +97,19 @@ Mb0BawlXZui0MNUSnZtxHMxrjejdvZdqtskHl9srB1QThH0jasmUqbQPxCnxMbf1
EOF
}
+robust_chroot_apt_update() {
+ set +e
+ sudo chroot $CHROOT_TARGET apt-get update | tee $TMPLOG
+ RESULT=$(egrep 'Failed to fetch.*(Unable to connect to|Connection failed|Size mismatch|Cannot initiate the connection to|Bad Gateway)' $TMPLOG)
+ set -e
+ if [ -z "$RESULT" ] ; then
+ echo "$(date -u) - apt-get update failed, sleeping 5min before retrying..."
+ sleep 5m
+ sudo chroot $CHROOT_TARGET apt-get update
+ fi
+ rm -f $TMPLOG
+}
+
bootstrap() {
mkdir -p "$CHROOT_TARGET/etc/dpkg/dpkg.cfg.d"
echo force-unsafe-io > "$CHROOT_TARGET/etc/dpkg/dpkg.cfg.d/02dpkg-unsafe-io"
@@ -132,13 +145,13 @@ bootstrap() {
fi
- sudo chroot $CHROOT_TARGET apt-get update
+ robust_chroot_apt_update
if [ -n "$1" ] ; then
for d in proc dev dev/pts ; do
sudo mount --bind /$d $CHROOT_TARGET/$d
done
set -x
- sudo chroot $CHROOT_TARGET apt-get update
+ robust_chroot_apt_update
# install diffoscope with all recommends...
if [ "$1" = "diffoscope" ] ; then
sudo chroot $CHROOT_TARGET apt-get install -y --install-recommends diffoscope
@@ -147,7 +160,7 @@ bootstrap() {
# always use diffoscope from unstable
if [ "$SUITE" = "testing" ] && [ "$1" = "diffoscope" ] ; then
echo "deb $MIRROR unstable main" | sudo tee -a $CHROOT_TARGET/etc/apt/sources.list > /dev/null
- sudo chroot $CHROOT_TARGET apt-get update
+ robust_chroot_apt_update
# install diffoscope from unstable without re-adding all recommends...
sudo chroot $CHROOT_TARGET apt-get install -y -t unstable --no-install-recommends diffoscope || echo "Warning: diffoscope from unstable is uninstallable at the moment."
fi