[OE-core] [PATCH 2/2] mkefidisk.sh: Add signal handling

Darren Hart dvhart at linux.intel.com
Mon Jul 21 22:45:58 UTC 2014


Add basic signal handling to unmount and remove any temporary files.

Signed-off-by: Darren Hart <dvhart at linux.intel.com>
---
 scripts/contrib/mkefidisk.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index 44ab8d5..7d48b53 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -46,7 +46,9 @@ cleanup() {
 	if [ -d "$TMPDIR" ]; then
 		rm -rf $TMPDIR || error "Failed to remove $TMPDIR"
 	fi
+	exit $1
 }
+trap cleanup HUP INT TERM
 
 # Logging routines
 WARNINGS=0
@@ -72,8 +74,7 @@ success() {
 }
 die() {
 	error $1
-	cleanup
-	exit 1
+	cleanup 1
 }
 debug() {
 	if [ $DEBUG -eq 1 ]; then
@@ -375,10 +376,6 @@ if [ -d $ROOTFS_MNT/etc/udev/ ] ; then
 	echo "$TARGET_DEVICE" >> $ROOTFS_MNT/etc/udev/mount.blacklist
 fi
 
-
-# Call cleanup to unmount devices and images and remove the TMPDIR
-cleanup
-
 echo ""
 if [ $WARNINGS -ne 0 ] && [ $ERRORS -eq 0 ]; then
 	echo "${YELLOW}Installation completed with warnings${CLEAR}"
@@ -391,3 +388,6 @@ else
 	success "Installation completed successfully"
 fi
 echo ""
+
+# Call cleanup to unmount devices and images and remove the TMPDIR
+cleanup 0
-- 
2.0.0




More information about the Openembedded-core mailing list