diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-02-14 14:40:14 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-02-14 15:02:34 +0000 |
commit | 2c1fb6748a746b2a0796cd26fef6cd4cb4ae7123 (patch) | |
tree | d7ab4407056d89261eea7463def96d34148b119f | |
parent | 1d53f02329e50780fb80a06d133f0a998c965ef1 (diff) | |
download | morph-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)
-rwxr-xr-x | baserock-bootstrap | 10 | ||||
-rwxr-xr-x | run-bootstrap-in-chroot | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/baserock-bootstrap b/baserock-bootstrap index fc15e23e..9fbfa6e3 100755 --- a/baserock-bootstrap +++ b/baserock-bootstrap @@ -821,10 +821,11 @@ python ./morph --verbose build \ --git-base-url=git://gitorious.org/baserock-morphs/ EOF $HOST_CHMOD +x "$LFS/baserock/build.sh" - local do_chroot="$BASEDIR/do-chroot" + local do_chroot="$BASEDIR/do-chroot.bash" if [ ! -e "$do_chroot" ]; then $HOST_CAT >"$do_chroot" <<EOF -trap "umount $LFS/proc $LFS/sys" EXIT +#!/bin/bash +trap "$HOST_SUDO umount $LFS/proc $LFS/sys" INT TERM EXIT set -e set -x if ! mount | grep "$LFS/proc" >/dev/null @@ -841,7 +842,6 @@ $HOST_SUDO /usr/sbin/chroot "$LFS" \\ PATH="/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin" \\ BOOTSTRAP_TOOLS="$LFS/tools" \\ "\${@-\$SHELL}" -$HOST_SUDO umount "$LFS/proc" "$LFS/sys" EOF $HOST_CHMOD +x "$do_chroot" fi @@ -862,13 +862,13 @@ pass2_build_devel_system_outside_chroot() $HOST_SUDO parted -s "$img" set 1 boot on $HOST_SUDO install-mbr "$img" part=/dev/mapper/$($HOST_SUDO kpartx -av "$img" | awk '/^add map/ { print $3 }' | head -n1) - trap "$HOST_SUDO kpartx -dv $img" EXIT + trap "$HOST_SUDO kpartx -dv $img" INT TERM EXIT # mapper may not yet be ready while test ! -e "$part"; do :; done $HOST_SUDO mkfs -t ext4 "$part" mp="$(mktemp -d)" $HOST_SUDO mount "$part" "$mp" - trap "$HOST_SUDO umount $part; $HOST_SUDO kpartx -dv $img" EXIT + trap "$HOST_SUDO umount $part; $HOST_SUDO kpartx -dv $img" INT TERM EXIT for stratum in "$LFS"/baserock/cache/*.stratum.{foundation,linux-stratum,devel} do 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" |