[Qa-jenkins-scm] [jenkins.debian.net] 04/04: refactor

Holger Levsen holger at moszumanska.debian.org
Wed Sep 9 06:51:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit be7c3f10b940db41e5ac9a97999531ee8d717458
Author: Holger Levsen <holger at layer-acht.org>
Date:   Wed Sep 9 08:50:45 2015 +0200

    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 93648e3..26f0c3d 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list