mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 21:39:03 +02:00
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>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -44,3 +44,4 @@
|
||||
/r
|
||||
/e
|
||||
/xbmkpath/
|
||||
/xbmkwd/
|
||||
|
||||
@@ -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'"; :
|
||||
|
||||
Reference in New Issue
Block a user