From 1ff56037d6dc9e94c4ba512dd0af41e6843645af Mon Sep 17 00:00:00 2001 From: Ayan Kumar Halder Date: Tue, 21 Dec 2021 13:04:46 +0000 Subject: Avoid exiting the script from the common If there is any error in compile_merge_partial_dts() and sanity_check_partial_dts(), it should return 1 to the caller. The caller will then check the return and call cleanup_and_return_err() (which terminates the script). This is to prevent compile_merge_partial_dts() and sanity_check_partial_dts() terminating the script. The reason being these functions can get invoked from disk_image (in the future) which may require some additional cleanup. Also, moved cleanup_and_return_err() to uboot-script-gen as the cleanup is specific to the script. Ensure that we preseve the directory containing the partial dtbs only when the dtbs were generated successfully. Else, we delete it. Signed-off-by: Ayan Kumar Halder Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- scripts/uboot-script-gen | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'scripts/uboot-script-gen') diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index 967cf6d..71669a9 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -4,6 +4,12 @@ offset=$((2*1024*1024)) filesize=0 prog_req=(mkimage file fdtput mktemp awk) +function cleanup_and_return_err() +{ + rm -f $UBOOT_SOURCE $UBOOT_SCRIPT + remove_tmp_files + exit 1 +} function dt_mknode() { @@ -854,8 +860,14 @@ cd "$uboot_dir" if test "$PASSTHROUGH_DTS_REPO" then - compile_merge_partial_dts "$PASSTHROUGH_DTS_REPO" - echo "Done compiling the partial device trees" + output_dir=`mktemp -d "partial-dtbs-XXX"` + compile_merge_partial_dts $output_dir "$PASSTHROUGH_DTS_REPO" + if test $? -ne 0 + then + # Remove the output dir holding the partial dtbs in case of any error + tmp_dirs+=($output_dir) + cleanup_and_return_err + fi fi if test "$FIT" -- cgit v1.2.3