From 5d1f1823067d81867ab226a4d0e7c515e6a56e6a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 24 Dec 2024 13:33:20 +0000 Subject: vendor.sh: Safer exit when vendorfiles not needed When vendor files were not needed on a given board, the script would directly exit. This is bad, because the inject functions are called directly from the main script, which means the parent instance of lbmk. This means that the lock file and temporary files were not being removed on exit. On a subsequent run, this would cause the error stating that a lock file is present, which would cause further error, making the user believe something is broken in lbmk. Modify the behaviour accordingly; exits are now returns, and these are handled in the calling functions, in such a way that a proper exit occurs, whereby temporary files and the lock file are deleted. For context, please read the main "build" script where it calls vendor_inject and vendor_download. At the end of that script, it calls tmp_cleanup, which removes the TMPDIR that was created, and the lock file. In lbmk, the TMPDIR is not /tmp, but rather a subdirectory under /tmp, so that further calls to mktemp create everything under one single temporary directory, which lbmk automatically removes on exit. Therefore, this patch also avoids leaving temporary files laying around on the disk. Signed-off-by: Leah Rowe --- include/vendor.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/vendor.sh b/include/vendor.sh index 570048e2..d12d94e3 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -259,7 +259,7 @@ extract_tbfw() vendor_inject() { set +u +e; [ $# -lt 1 ] && $err "No options specified." - [ "$1" = "listboards" ] && eval "ls -1 config/coreboot || :; exit 0" + [ "$1" = "listboards" ] && eval "ls -1 config/coreboot || :; return 0" archive="$1"; while getopts n:r:b:m: option; do case "$option" in @@ -273,8 +273,11 @@ vendor_inject() check_board || return 0 [ "$nukemode" = "nuke" ] || x_ ./vendor download $board - [ "$vrelease" != "y" ] && patch_rom "$rom" - [ "$vrelease" = "y" ] && patch_release_roms; : + if [ "$vrelease" = "y" ]; then + patch_release_roms + else + patch_rom "$rom" || : + fi; : } check_board() @@ -338,7 +341,7 @@ patch_release_roms() $err "patch_release_roms: !tar -xf \"$archive\" -C \"tmp/romdir\"" for x in "tmp/romdir/bin/"*/*.rom ; do - patch_rom "$x" + patch_rom "$x" || return 0 done ( @@ -363,7 +366,7 @@ patch_release_roms() patch_rom() { rom="$1" - readkconfig || exit 0 + readkconfig || return 1 [ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \ "mrc" "0xfffa0000" -- cgit v1.2.1