summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2015-09-09 08:48:36 +0200
committerHolger Levsen <holger@layer-acht.org>2015-09-09 08:48:36 +0200
commita28f0c2826bc37feea328666c469cd63eb98736b (patch)
tree2de3f60f0352a8224070b32507b35ac0681db689 /bin
parent95670eabae1f49779ca6fceb26af13c8db0d06a9 (diff)
downloadjenkins.debian.net-a28f0c2826bc37feea328666c469cd63eb98736b.tar.xz
make 'apt-get install' more robust against network failures
Diffstat (limited to 'bin')
-rwxr-xr-xbin/schroot-create.sh22
1 files changed, 18 insertions, 4 deletions
diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh
index 8e902cd0..93648e3e 100755
--- a/bin/schroot-create.sh
+++ b/bin/schroot-create.sh
@@ -110,6 +110,20 @@ robust_chroot_apt_update() {
rm -f $TMPLOG
}
+robust_chroot_apt_install() {
+ set +e
+ sudo chroot $CHROOT_TARGET apt-get install $@ | 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 install failed, sleeping 5min before retrying..."
+ sleep 5m
+ sudo chroot $CHROOT_TARGET apt-get install $@
+ 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"
@@ -152,12 +166,12 @@ bootstrap() {
done
set -x
robust_chroot_apt_update
- # install diffoscope with all recommends...
+ # first, (if), install diffoscope with all recommends...
if [ "$1" = "diffoscope" ] ; then
- sudo chroot $CHROOT_TARGET apt-get install -y --install-recommends diffoscope
+ robust_chroot_apt_install -y --install-recommends diffoscope
fi
- sudo chroot $CHROOT_TARGET apt-get install -y --no-install-recommends "$@"
- # always use diffoscope from unstable
+ robust_chroot_apt_install -y --no-install-recommends "$@"
+ # always try to 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
robust_chroot_apt_update