summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-04-26 21:47:28 +0100
committerLeah Rowe <leah@libreboot.org>2025-04-26 21:47:28 +0100
commit15268202478290b645e5d7c824a0c6f63e06373f (patch)
tree5855c9b0c058b7469b920b4dab827e7677f15463 /include
parent0280cd4c0e74a6d11e5f2a5d07d914532dfb7983 (diff)
init.sh: split xbmk_child_init into functions
one function, for one task. skeleton functions for performing multiple tasks. that is the basic coding style guideline for lbmk. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/init.sh27
1 files changed, 19 insertions, 8 deletions
diff --git a/include/init.sh b/include/init.sh
index dbe6bcd9..1518f358 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -178,22 +178,35 @@ init_ver()
export LOCALVERSION="-$projectname-${version%%-*}"
}
-# if this instance is the main parent, re-run as a child process and exit.
xbmk_child_init()
{
+ for init_cmd in create_tmpdir lock create_pathdirs child_exec; do
+ xbmk_$init_cmd "$@" || return 0; :
+ done
+}
+
+xbmk_create_tmpdir()
+{
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
- [ -z "${TMPDIR+x}" ] || return 0 # this is a child instance, so return
+ [ -z "${TMPDIR+x}" ] || return 1 # child instance, so return
# parent instance of xbmk, so don't return. set up TMPDIR
- # and re-run as a child instance:
- [ -f "lock" ] && $err "$xbmkpwd/lock exists. Is a build running?"
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
- touch lock || $err "cannot create 'lock' file"
+}
+
+xbmk_lock()
+{
+ [ -f "lock" ] && $err "$xbmkpwd/lock exists. Is a build running?"
+ touch lock || $err "cannot create 'lock' file"; :
+}
+
+xbmk_create_pathdirs()
+{
x_ rm -Rf "$XBMK_CACHE/xbmkpath" "$XBMK_CACHE/gnupath"
x_ mkdir -p "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH"
@@ -202,9 +215,7 @@ xbmk_child_init()
# see code above that detected the correct python3 command.
cd "$XBMK_CACHE/xbmkpath" || $err "can't cd $XBMK_CACHE/xbmkpath"
x_ ln -s "`pybin "$python"`" python
- ) || $err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"
-
- xbmk_child_exec "$@"
+ ) || $err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"; :
}
xbmk_child_exec()