Merge "Preserve exit value when leaving cleanup trap"

This commit is contained in:
Jenkins 2014-10-14 21:05:14 +00:00 committed by Gerrit Code Review
commit 16b0e5e856
2 changed files with 7 additions and 1 deletions

View File

@ -36,7 +36,7 @@ function mk_build_dir () {
sudo mount -t tmpfs tmpfs $TMP_IMAGE_DIR sudo mount -t tmpfs tmpfs $TMP_IMAGE_DIR
fi fi
sudo chown $(id -u):$(id -g) $TMP_BUILD_DIR $TMP_IMAGE_DIR sudo chown $(id -u):$(id -g) $TMP_BUILD_DIR $TMP_IMAGE_DIR
trap cleanup EXIT trap trap_cleanup EXIT
echo Building in $TMP_BUILD_DIR echo Building in $TMP_BUILD_DIR
export TMP_IMAGE_PATH=$TMP_IMAGE_DIR/image.raw export TMP_IMAGE_PATH=$TMP_IMAGE_DIR/image.raw
export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks

View File

@ -28,6 +28,12 @@ function unmount_image () {
fi fi
} }
function trap_cleanup() {
exitval=$?
cleanup
exit $exitval
}
function cleanup () { function cleanup () {
unmount_image unmount_image
cleanup_dirs cleanup_dirs