From be7c3f10b940db41e5ac9a97999531ee8d717458 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 9 Sep 2015 08:50:45 +0200 Subject: refactor --- bin/schroot-create.sh | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh index 93648e3e..26f0c3d8 100755 --- a/bin/schroot-create.sh +++ b/bin/schroot-create.sh @@ -97,33 +97,19 @@ Mb0BawlXZui0MNUSnZtxHMxrjejdvZdqtskHl9srB1QThH0jasmUqbQPxCnxMbf1 EOF } -robust_chroot_apt_update() { +robust_chroot_apt() { set +e - sudo chroot $CHROOT_TARGET apt-get update | tee $TMPLOG + sudo chroot $CHROOT_TARGET apt-get $@ | 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..." + echo "$(date -u) - 'apt-get $@' failed, sleeping 5min before retrying..." sleep 5m - sudo chroot $CHROOT_TARGET apt-get update + sudo chroot $CHROOT_TARGET apt-get $@ fi 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" @@ -159,22 +145,22 @@ bootstrap() { fi - robust_chroot_apt_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 - robust_chroot_apt_update + robust_chroot_apt update # first, (if), install diffoscope with all recommends... if [ "$1" = "diffoscope" ] ; then - robust_chroot_apt_install -y --install-recommends diffoscope + robust_chroot_apt install -y --install-recommends diffoscope fi - robust_chroot_apt_install -y --no-install-recommends "$@" + 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 + 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 -- cgit v1.2.3-70-g09d2