From 546fbde71bea902b8e6bc0c3e00c01aaa2a39199 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 19 Apr 2016 16:37:19 -0700 Subject: update.sh: use exit trap to report unexpected exits Add exit trap to report unexpected exits (due to set -e). Note that this traps every exit, also explicit calls to exit. Therefor register the trap only during the sequencial image generating/coping part, after the sanity checks... Signed-off-by: Stefan Agner Acked-by: Marcel Ziswiler --- recipes/images/files/colibri-imx7/update.sh | 10 +++++++--- recipes/images/files/colibri-vf/update.sh | 12 ++++++++---- recipes/images/files/library/imx6/update.sh | 9 +++++++-- recipes/images/files/library/tegra/update.sh | 9 +++++++-- 4 files changed, 29 insertions(+), 11 deletions(-) (limited to 'recipes') diff --git a/recipes/images/files/colibri-imx7/update.sh b/recipes/images/files/colibri-imx7/update.sh index ee44989..d531b98 100755 --- a/recipes/images/files/colibri-imx7/update.sh +++ b/recipes/images/files/colibri-imx7/update.sh @@ -141,8 +141,11 @@ if [ "$CNT" -eq 0 ] ; then exit 1 fi +#Install trap to write a sensible message in case any of the commands below +#exit premature... +trap '{ printf "\033[31mScript aborted unexpectedly...\033[0m\n"; }' EXIT + # Prepare full flashing -#build ${IMAGEFILE} if it does not exist sudo $LOCPATH/mkfs.ubifs --space-fixup -c ${MAXLEB} -e ${BLOCK} -m ${PAGE} -o ${BINARIES}/${IMAGEFILE} -r rootfs/ -v echo "" @@ -167,7 +170,8 @@ sudo cp ${BINARIES}/fwd_eth.img "$OUT_DIR/../flash_eth.img" sudo rm ${BINARIES}/ubifs.img ${BINARIES}/versions.txt sync -echo "Successfully copied data to target folder." -echo "" +#Remove trap and report success! +trap - EXIT +printf "\033[32mSuccessfully copied data to target folder.\033[0m\n\n" Flash diff --git a/recipes/images/files/colibri-vf/update.sh b/recipes/images/files/colibri-vf/update.sh index 05af9ca..ee832a8 100755 --- a/recipes/images/files/colibri-vf/update.sh +++ b/recipes/images/files/colibri-vf/update.sh @@ -158,8 +158,11 @@ if [ "$CNT" -eq 0 ] ; then exit 1 fi -# Prepare full flashing -#build ${IMAGEFILE} if it does not exist +#Install trap to write a sensible message in case any of the commands below +#exit premature... +trap '{ printf "\033[31mScript aborted unexpectedly...\033[0m\n"; }' EXIT + +#Prepare full flashing sudo $LOCPATH/mkfs.ubifs --space-fixup -c ${MAXLEB} -e ${BLOCK} -m ${PAGE} -o ${BINARIES}/${IMAGEFILE} -r rootfs/ -v echo "" @@ -198,7 +201,8 @@ sudo cp ${BINARIES}/fwd_mmc.img "$OUT_DIR/../flash_mmc.img" sudo rm ${BINARIES}/ubifs.img ${BINARIES}/versions.txt sync -echo "Successfully copied data to target folder." -echo "" +#Remove trap and report success! +trap - EXIT +printf "\033[32mSuccessfully copied data to target folder.\033[0m\n\n" Flash diff --git a/recipes/images/files/library/imx6/update.sh b/recipes/images/files/library/imx6/update.sh index 0bf5380..b80e198 100755 --- a/recipes/images/files/library/imx6/update.sh +++ b/recipes/images/files/library/imx6/update.sh @@ -159,6 +159,10 @@ MKFSVFAT=`command -v mkfs.vfat` || MKFSVFAT=`sudo -s command -v mkfs.vfat` || { MKFSEXT3=`command -v mkfs.ext3` || MKFSEXT3=`sudo -s command -v mkfs.ext3` || { echo >&2 "Program mkfs.ext3 not available. Aborting."; exit 1; } dd --help >/dev/null 2>&1 || { echo >&2 "Program dd not available. Aborting."; exit 1; } +#Install trap to write a sensible message in case any of the commands below +#exit premature... +trap '{ printf "\033[31mScript aborted unexpectedly...\033[0m\n"; }' EXIT + #make the directory with the outputfiles writable sudo chown $USER: ${BINARIES} @@ -278,7 +282,8 @@ sudo split -a 2 -b `expr 64 \* 1024 \* 1024` --numeric-suffixes=10 "$OUT_DIR/roo fi sync -echo "Successfully copied data to target folder." -echo "" +#Remove trap and report success! +trap - EXIT +printf "\033[32mSuccessfully copied data to target folder.\033[0m\n\n" Flash diff --git a/recipes/images/files/library/tegra/update.sh b/recipes/images/files/library/tegra/update.sh index 8f09001..1849bed 100755 --- a/recipes/images/files/library/tegra/update.sh +++ b/recipes/images/files/library/tegra/update.sh @@ -255,6 +255,10 @@ if [ "${MODTYPE}" = "colibri-t20" ] ; then fi fi +#Install trap to write a sensible message in case any of the commands below +#exit premature... +trap '{ printf "\033[31mScript aborted unexpectedly...\033[0m\n"; }' EXIT + #make the directory with the outputfiles writable sudo chown $USER: ${BINARIES} @@ -399,7 +403,8 @@ if [ "${IMAGEFILE}" = "root.ext3" ] ; then fi sync -echo "Successfully copied data to target folder." -echo "" +#Remove trap and report success! +trap - EXIT +printf "\033[32mSuccessfully copied data to target folder.\033[0m\n\n" Flash -- cgit v1.2.3