mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
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>
This commit is contained in:
+7
-2
@@ -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"
|
||||
|
||||
+1
-1
@@ -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()
|
||||
|
||||
@@ -17,7 +17,6 @@ fi
|
||||
. "include/mrc.sh"
|
||||
|
||||
eval "`setvars "" vdir src_dirname srcdir mode xp ser`"
|
||||
err="fail"
|
||||
|
||||
main()
|
||||
{
|
||||
@@ -119,23 +118,7 @@ build_release()
|
||||
rm -Rf "$srcdir" || $err "!rm -Rf $srcdir"
|
||||
}
|
||||
|
||||
fail()
|
||||
{
|
||||
tmp_cleanup || printf "WARNING: can't rm tmpfiles: %s\n" "$TMPDIR" 1>&2
|
||||
err_ "${1}"
|
||||
}
|
||||
|
||||
tmp_cleanup()
|
||||
{
|
||||
[ "$xbmk_parent" = "y" ] || return 0
|
||||
[ "$TMPDIR" = "/tmp" ] || rm -Rf "$TMPDIR" || return 1
|
||||
rm -f lock || return 1
|
||||
}
|
||||
|
||||
if main "$@"; then
|
||||
tmp_cleanup || err_ "can't rm TMPDIR upon non-zero exit: $TMPDIR"
|
||||
exit 0
|
||||
fi
|
||||
main "$@" && exit 0
|
||||
|
||||
# what follows was formerly script/trees, whose main() is now trees()
|
||||
|
||||
@@ -525,5 +508,3 @@ if trees "$@"; then
|
||||
. "$mkhelpercfg"
|
||||
$cmd
|
||||
fi
|
||||
|
||||
tmp_cleanup || err_ "can't rm TMPDIR upon non-zero exit: $TMPDIR"
|
||||
|
||||
Reference in New Issue
Block a user