[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] schroot-create: umount all directories mounted below the schroot directory while cleaning up

Mattia Rizzolo gitlab at salsa.debian.org
Mon Aug 19 09:50:22 BST 2019



Mattia Rizzolo pushed to branch master at Debian QA / jenkins.debian.net


Commits:
83a68cb1 by Mattia Rizzolo at 2019-08-19T08:50:08Z
schroot-create: umount all directories mounted below the schroot directory while cleaning up

it seems sometimes we call cleanup() without first umounting /proc, in case of errors

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -


1 changed file:

- bin/schroot-create.sh


Changes:

=====================================
bin/schroot-create.sh
=====================================
@@ -55,6 +55,10 @@ TMPLOG=$(mktemp --tmpdir=$TMPDIR schroot-create-XXXXXXXX)
 cleanup() {
 	cd
 	if [ -d "$SCHROOT_TARGET" ]; then
+		local i
+		for i in $(findmnt -l -c | awk '{print $1}' | grep "^$SCHROOT_TARGET"); do
+			sudo umount "$i"
+		done
 		sudo rm -rf --one-file-system "$SCHROOT_TARGET" || ( echo "Warning: $SCHROOT_TARGET could not be fully removed during cleanup." ; ls "$SCHROOT_TARGET" -la )
 	fi
 	rm -f "$TMPLOG"
@@ -149,9 +153,7 @@ bootstrap() {
 
 	robust_chroot_apt update
 	if [ -n "$1" ] ; then
-		for d in proc ; do
-			sudo mount --bind /$d $SCHROOT_TARGET/$d
-		done
+		sudo mount --bind /proc $SCHROOT_TARGET/proc
 		set -x
 		robust_chroot_apt update
 		# first, (if), install diffoscope with all recommends...
@@ -183,10 +185,7 @@ bootstrap() {
 			sudo chroot $SCHROOT_TARGET dpkg -l diffoscope
 			echo
 		fi
-		# umount in reverse order than how they were mounted earlier
-		for d in proc ; do
-			sudo umount -l $SCHROOT_TARGET/$d
-		done
+		sudo umount -l $SCHROOT_TARGET/proc
 		# configure sudo inside just like outside
 		echo "jenkins    ALL=NOPASSWD: ALL" | sudo tee -a $SCHROOT_TARGET/etc/sudoers.d/jenkins >/dev/null
 		sudo chroot $SCHROOT_TARGET chown root.root /etc/sudoers.d/jenkins



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/commit/83a68cb14661317f333d00bca04474b20882fda7

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/commit/83a68cb14661317f333d00bca04474b20882fda7
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20190819/7880c499/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list