summaryrefslogtreecommitdiff
path: root/include/init.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-09-24 23:06:16 +0100
committerLeah Rowe <leah@libreboot.org>2025-09-24 23:26:11 +0100
commitdc722b5bb87d0c24269d57d09f917e9b1cb26fce (patch)
tree0195c524eeefee7fd7acf163d5194dabc408cd8e /include/init.sh
parent4686ba8a4af7d3bc53a0447a2aeeb299780d03be (diff)
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>
Diffstat (limited to 'include/init.sh')
-rw-r--r--include/init.sh63
1 files changed, 20 insertions, 43 deletions
diff --git a/include/init.sh b/include/init.sh
index 7aae2adc..e1e436d5 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -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"