diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/schroot-create.sh | 22 |
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 |