Preserve exit value when leaving cleanup trap

If we entered the cleanup trap due to exit with an error code we should
exit dib with an error code.

Change-Id: Iee1a05668b3239113fb91a2da0d9a66d7de4db6b
This commit is contained in:
Gregory Haynes 2014-10-10 17:01:37 -07:00
parent 8a8bbb5673
commit f06493bcd6
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
fi
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
export TMP_IMAGE_PATH=$TMP_IMAGE_DIR/image.raw
export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks

View File

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