init.sh: return from child in set_env instead

This is earlier than the current check, thus preventing
the initialisation of a git repository and/or the recreation
of xbmktmp and xbmklocal by erroneous parent executions of lbmk
while another parent is running - the latter of which could have
caused a massively unpredictable build failure, so this is also
a pre-emptive bug fix, fixing all kinds of weird bugs.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-05-18 11:18:45 +01:00
parent 7ec9ee4228
commit cde3b7051e
+11 -11
View File
@@ -146,6 +146,17 @@ xbmk_set_env()
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1; :
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
[ -z "${TMPDIR+x}" ] || return 1 # child instance, so return
# parent instance of xbmk, so don't return. set up TMPDIR
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
}
xbmk_git_init()
@@ -171,17 +182,6 @@ xbmk_create_tmpdir()
{
x_ mkdir -p "$xbmklocal"
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
[ -z "${TMPDIR+x}" ] || return 1 # child instance, so return
# parent instance of xbmk, so don't return. set up TMPDIR
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
# /tmp might be a tmpfs, so for large files we use ./tmp,
# not to be confused with xbmktmp (xbmktmp points to /tmp)
remkdir "$xbmktmp" "$xbmklocal"