summaryrefslogtreecommitdiff
path: root/run-bootstrap-in-chroot
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-02-14 14:40:14 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-02-14 15:02:34 +0000
commit2c1fb6748a746b2a0796cd26fef6cd4cb4ae7123 (patch)
treed7ab4407056d89261eea7463def96d34148b119f /run-bootstrap-in-chroot
parent1d53f02329e50780fb80a06d133f0a998c965ef1 (diff)
downloadmorph-2c1fb6748a746b2a0796cd26fef6cd4cb4ae7123.tar.gz
scripts: use EXIT traps to unmount
Jenkins failed to build because proc and sys were still mounted after a forced termination of a build. The exit traps will be run when the shell exits, so there are fewer code paths that can avoid unmounting EXIT is not the only signal that can be used INT and TERM will be executed when Interrupted (by ^C) or Terminated (by kill)
Diffstat (limited to 'run-bootstrap-in-chroot')
-rwxr-xr-xrun-bootstrap-in-chroot4
1 files changed, 2 insertions, 2 deletions
diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot
index ee19bced..184d35e6 100755
--- a/run-bootstrap-in-chroot
+++ b/run-bootstrap-in-chroot
@@ -24,11 +24,11 @@ snapshotdir="$1"
cat >"./do-squeeze-chroot" <<EOF
#!/bin/sh
if mount -t proc proc "$dir/proc"; then
+ trap "umount \"$dir/proc\"" INT TERM EXIT
if mount -t sysfs sysfs "$dir/sys"; then
+ trap "umount \"$dir/proc\" \"$dir/sys\"" INT TERM EXIT
chroot "$dir" "\$@"
- umount "$dir/sys"
fi
- umount "$dir/proc"
fi
EOF
chmod +x "./do-squeeze-chroot"