diff options
author | Leah Rowe <leah@libreboot.org> | 2025-09-02 06:02:57 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-09-02 06:02:57 +0100 |
commit | 64b69907ababbafc13a0fdaabc3aaf439e02ec86 (patch) | |
tree | 5233fc13f3ace71da67cc1630440a3f92b7b044a /include | |
parent | 8a8be1dec99f37932a2bedea7cc0427ea90903e6 (diff) |
init.sh: put TMPDIR inside xbmkpwd, not /tmp
This way, all operations will be done inside the xbmk
work directory. This is being done, so that I can then
reliably sandybox certain commands in future commits,
for example the "rm" command.
This will also allow me to unify the location of all
temporary files, in future commits. I previously used
the /tmp directory because it's tmpfs-based on many
setups, and this is great for performance. However, in
practise, I never noticed any difference in performance
when benchmarking it (testing /tmp on-disk versus tmpfs).
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/init.sh | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/include/init.sh b/include/init.sh index f71c486e..aabdd5d4 100644 --- a/include/init.sh +++ b/include/init.sh @@ -15,15 +15,17 @@ projectsite="https://libreboot.org/" eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \ datadir version xbmkpwd relname xbmkpwd xbtmp python pyver xbloc \ - xbmklock cvxbmk cvchk xbmkpath is_child`" + xbmklock cvxbmk cvchk xbmkpath is_child basetmp`" xbmk_init() { xbmkpwd="`pwd`" || err "Cannot generate PWD" xbloc="$xbmkpwd/tmp" xbmklock="$xbmkpwd/lock" + basetmp="$xbmkpwd/xbmkwd" export PWD="$xbmkpwd" + x_ mkdir -p "$basetmp" [ $# -gt 0 ] && [ "$1" = "dependencies" ] && x_ xbmkpkg "$@" && exit 0 @@ -92,16 +94,16 @@ xbmk_child_set_tmp() { eval `setvars "" xbtmp badtmp xbtmpchk xbtmpname` - [ -z "${TMPDIR+x}" ] && export TMPDIR="/tmp" + [ -z "${TMPDIR+x}" ] && export TMPDIR="$basetmp" # extremely pedantic safety checks on TMPDIR xbtmpchk="`findpath "$TMPDIR" || err`" || err - [ "$xbtmpchk" = "${xbtmpchk#/tmp/}" ] && \ - badtmp="not a subdirectory in /tmp" - [ -z "$badtmp" ] && xbtmpname="${xbtmpchk#/tmp/}" && \ - [ -z "$xbtmpchk" ] && badtmp="name after /tmp is empty" + [ "$xbtmpchk" = "${xbtmpchk#"$basetmp/"}" ] && \ + badtmp="not a subdirectory in $basetmp" + [ -z "$badtmp" ] && xbtmpname="${xbtmpchk#"$basetmp/"}" && \ + [ -z "$xbtmpchk" ] && badtmp="name after $basetmp is empty" [ -z "$badtmp" ] && [ "$xbtmpname" != "${xbtmpname#*/}" ] && \ - badtmp="'$TMPDIR' is a subdirectory in a subdir of /tmp" + badtmp="'$TMPDIR' is a subdirectory in a subdir of $basetmp" [ -z "$badtmp" ] && [ -L "$xbtmpchk" ] && badtmp="is a symlink" [ -z "$badtmp" ] && [ ! -d "$xbtmpchk" ] && \ badtmp="not a directory" @@ -124,12 +126,12 @@ xbmk_child_set_tmp() xbmk_parent_check_tmp() { - export TMPDIR="/tmp" + export TMPDIR="$basetmp" xbmklist="`mktemp || err "can't make tmplist"`" || err x_ rm -f "$xbmklist" x_ touch "$xbmklist" - for xtmpdir in /tmp/xbmk_*; do + for xtmpdir in "$basetmp"/xbmk_*; do [ -e "$xtmpdir" ] || continue printf "%s\n" "$xtmpdir" >> "$xbmklist" || \ err "can't write '$xtmpdir' to file: '$xbmklist'"; : |