summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-04-12 19:57:40 +0100
committerLeah Rowe <leah@libreboot.org>2025-04-12 20:03:40 +0100
commitc4c6692b761a50838deab5ed5ce5d3ff521fab7d (patch)
treedf6d3bb477c789fc62ec9b4065d971c23a95d7b6 /include
parentfd5431db05dcaa11e45e1e35f987d5cef9ce088f (diff)
remove xbmk_parent, handle forking in lib.sh
I was using a complicated method of knowing whether the current instance was parent or a child, to know whether the lock file and TMPDIR needed to be purged. It was quite error-prone too. Instead, I'm now handling it directly from within the if statement that previously initialised xbmk_parent=y, forking ./mk from there. The forked instance would not trigger that if clause again, since then TMPDIR is created, thus avoiding recursion. This is an improvement because it doesn't rely on how the parent handles exit statuses, and it ensures that the lock/tmp files are never accidentally deleted. Even if a given program/script that lbmk runs would export TMPDIR, it doesn't matter because lbmk doesn't, so it would be unaffected. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/lib.sh9
-rw-r--r--include/vendor.sh2
2 files changed, 8 insertions, 3 deletions
diff --git a/include/lib.sh b/include/lib.sh
index ac0003f0..19bd9357 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -50,7 +50,7 @@ chkvars()
}
eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \
- datadir version relname xbmk_parent`"
+ datadir version relname`"
for fv in version versiondate; do
eval "[ ! -f \".$fv\" ] || read -r $fv < \".$fv\" || :"
@@ -140,7 +140,12 @@ if [ -z "${TMPDIR+x}" ]; then
cd "$XBMK_CACHE/xbmkpath" || $err "can't cd $XBMK_CACHE/xbmkpath"
x_ ln -s "`command -v "$python"`" python
) || $err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"
- xbmk_parent="y"
+
+ xbmk_rval=0
+ ./mk "$@" || xbmk_rval=1
+ rm -Rf "$TMPDIR" || xbmk_rval=1
+ rm -f lock || xbmk_rval=1
+ exit $xbmk_rval
fi
# if "y": a coreboot target won't be built if target.cfg says release="n"
diff --git a/include/vendor.sh b/include/vendor.sh
index d98bde7e..6af25935 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -337,7 +337,7 @@ fail_inject()
printf "\n\n%s\n\n" "$dontflash" 1>&2
printf "WARNING: File '%s' was NOT modified.\n\n" "$archive" 1>&2
printf "Please MAKE SURE vendor files are inserted before flashing\n\n"
- fail "$1"
+ $err "$1"
}
vendor_inject()