init.sh: switch back to old TMPDIR checks

the new check is still retained, to the extent that
the lock file still contains the TMPDIR string, and
it's checked whether this changed during execution.

however, the current TMPDIR handling is over-engineered
and prevents the re-use of project source caches when
doing release builds; this means that the release builds
happen much more slowly, especially for slow internet
connections.

this change *fixes* that bug. now release builds once
again re-use the main cache/ directory.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-09-24 23:06:16 +01:00
parent 4686ba8a4a
commit dc722b5bb8
+20 -43
View File
@@ -102,10 +102,19 @@ xbmk_get_version()
# after this function is called.
xbmk_set_env()
{
is_child="n"
xbmkpath="$PATH"
is_child="n"
if [ -f "$xbmklock" ]; then
# unify all temporary files/directories in a single TMPDIR
if [ -n "${TMPDIR+x}" ] && [ "${TMPDIR%_*}" != "$basetmp/xbmk" ]; then
unset TMPDIR
fi
if [ -n "${TMPDIR+x}" ]; then
export TMPDIR="$TMPDIR"
xbtmp="$TMPDIR"
fi
if [ -n "${TMPDIR+x}" ]; then
is_child="y"
fi
@@ -153,51 +162,18 @@ xbmk_set_env()
xbmk_child_set_tmp()
{
eval `setvars "" xbtmp badtmp xbtmpchk xbtmpname`
if [ -z "${TMPDIR+x}" ]; then
export TMPDIR="$basetmp"
fi
# extremely pedantic safety checks on TMPDIR
# TODO: should probably scale this back, because as a result
# of these checks, release work directories don't have
# project caches so projects have to be downloaded again.
# TODO: even if these checks are kept, this TMPDIR checking code
# is utter garbage and should be re-written more cleanly:
eval `setvars "" badtmp xbtmpchk locktmp`
xbtmpchk="`findpath "$TMPDIR" || err "!findpath $TMPDIR"`" || \
err "!findpath '$TMPDIR'" xbmk_child_set_tmp "$@"
if [ "$xbtmpchk" = "${xbtmpchk#"$basetmp/"}" ]; then
badtmp="not a subdirectory in $basetmp"
fi
if [ -z "$badtmp" ]; then
xbtmpname="${xbtmpchk#"$basetmp/"}"
if [ -z "$xbtmpchk" ]; then
badtmp="name after $basetmp is empty"
fi
fi
if [ -z "$badtmp" ] && [ "$xbtmpname" != "${xbtmpname#*/}" ]; then
badtmp="'$TMPDIR' is a subdirectory in a subdir of $basetmp"
fi
if [ -z "$badtmp" ] && [ -L "$xbtmpchk" ]; then
badtmp="is a symlink"
fi
if [ -z "$badtmp" ] && [ ! -d "$xbtmpchk" ]; then
badtmp="not a directory"
fi
if [ -z "$badtmp" ]; then
# final check: check if TMPDIR changed
locktmp=""
read -r locktmp < "$xbmklock" || \
err "can't read '$xbmklock'" xbmk_child_set_tmp "$@"
[ "$locktmp" = "$xbtmpchk" ] || \
badtmp="TMPDIR '$xbtmpchk' changed; was '$locktmp'"
fi
if [ -n "$badtmp" ]; then
read -r locktmp < "$xbmklock" || \
err "can't read '$xbmklock'" xbmk_child_set_tmp "$@"
if [ "$locktmp" != "$xbtmpchk" ]; then
badtmp="TMPDIR '$xbtmpchk' changed; was '$locktmp'"
printf "bad TMPDIR init, '%s': %s\n" "$TMPDIR" "$badtmp" 1>&2
fi
if [ -n "$badtmp" ]; then
err "'$xbmklock' present with bad tmpdir. is a build running?"
fi
@@ -205,6 +181,7 @@ xbmk_child_set_tmp()
export TMPDIR="$xbtmpchk"
}
xbmk_parent_check_tmp()
{
export TMPDIR="$basetmp"