handle TMPDIR from include/export.sh

it looks a bit cluttered just sitting there in
the main script. make it an include.

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-09-02 10:22:39 +01:00
parent 56f16bc883
commit 4885c7962d
2 changed files with 23 additions and 20 deletions

22
include/export.sh Executable file
View File

@ -0,0 +1,22 @@
# Copyright (c) 2023 Leah Rowe <leah@libreboot.org>
# SPDX-License-Identifier: MIT
tmpdir=""
tmpdir_was_set="y"
set | grep TMPDIR 1>/dev/null 2>/dev/null || tmpdir_was_set="n"
if [ "${tmpdir_was_set}" = "y" ]; then
tmpdir="${TMPDIR##*/}"
tmpdir="${TMPDIR%_*}"
if [ "${tmpdir}" = "lbmk" ]; then
tmpdir=""
tmpdir_was_set="n"
fi
fi
if [ "${tmpdir_was_set}" = "n" ]; then
export TMPDIR="/tmp"
tmpdir="$(mktemp -d -t lbmk_XXXXXXXX)"
export TMPDIR="${tmpdir}"
else
export TMPDIR="${TMPDIR}"
fi
tmpdir="${TMPDIR}"

21
lbmk
View File

@ -25,26 +25,7 @@
set -u -e
. "include/err.sh"
tmpdir=""
tmpdir_was_set="y"
set | grep TMPDIR 1>/dev/null 2>/dev/null || tmpdir_was_set="n"
if [ "${tmpdir_was_set}" = "y" ]; then
tmpdir="${TMPDIR##*/}"
tmpdir="${TMPDIR%_*}"
if [ "${tmpdir}" = "lbmk" ]; then
tmpdir=""
tmpdir_was_set="n"
fi
fi
if [ "${tmpdir_was_set}" = "n" ]; then
export TMPDIR="/tmp"
tmpdir="$(mktemp -d -t lbmk_XXXXXXXX)"
export TMPDIR="${tmpdir}"
else
export TMPDIR="${TMPDIR}"
fi
tmpdir="${TMPDIR}"
. "include/export.sh"
projectname="$(cat projectname)"
buildpath=""