From 9cbffa2e83427fa6b6d0ec91915a41fa3f086413 Mon Sep 17 00:00:00 2001 From: Dongwoo Lee Date: Wed, 1 Dec 2021 14:28:26 +0900 Subject: [PATCH] scripts: mkbootimg_rpi4.sh: Stop build on any kind of errors Currently, even if an error occurs during image creation, the script does not abort, which may result in incorrect image creation. In order to avoid confusion due to this, if any kind of error occurs during the build process, the build will be stopped. Change-Id: I8094f4b97128a8c754e5a9ff22f1b3395a3756b1 Signed-off-by: Dongwoo Lee --- scripts/mkbootimg_rpi4.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/scripts/mkbootimg_rpi4.sh b/scripts/mkbootimg_rpi4.sh index babfd46..d49082c 100755 --- a/scripts/mkbootimg_rpi4.sh +++ b/scripts/mkbootimg_rpi4.sh @@ -1,9 +1,38 @@ #!/bin/bash +TMP_UBOOT_PATH=tmp_uboot BOOT_PATH="rpi4/boot" USER_ID=`id -u` GROUP_ID=`id -g` IS_64BIT=`cat .config | grep "CONFIG_64BIT=y"` +BUILD_ROOT=$PWD + +cleanup() { + cd $BUILD_ROOT + if [ -e $TMP_UBOOT_PATH ]; then + rm -rf ${TMP_UBOOT_PATH} + fi + + if [ -e tmp_modules ]; then + rm -rf tmp_modules + fi + + if [ -e tmp/lib/modules ]; then + rm -rf tmp/lib/modules + fi + + if [ -n "$(mount | grep ${BUILD_ROOT}/tmp)" ]; then + sudo umount tmp + fi + + if [ -e tmp ]; then + rm -rf tmp + fi +} + +trap cleanup EXIT + +set -e rm -f boot.img rm -rf tmp @@ -32,7 +61,7 @@ else fi # install u-boot files extracted from u-boot-rpi4 rpm package in download.tizen.org. -TMP_UBOOT_PATH=tmp_uboot + mkdir -p ${TMP_UBOOT_PATH} pushd ${TMP_UBOOT_PATH} if [ -n "$IS_64BIT" ]; then @@ -93,3 +122,5 @@ if [ "$?" != "0" ]; then fi echo ${BOOT_TARBALL} + +set +e -- 2.7.4