diff options
author | Leah Rowe <leah@libreboot.org> | 2025-10-01 07:57:39 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-10-01 07:57:39 +0100 |
commit | 2ac51f442b2760d3c3509683e7eb3d179e4df52f (patch) | |
tree | 5d465faac487dfdbda9555ffdebdfed41cbe4f63 | |
parent | 8b351e51aa61c2091d7e4abbaf494c251e0c9c98 (diff) |
init.sh: break up xbmk_set_env
what this function does will differ wildly,
depending on whether it's a child instance
or a parent instance of xbmk.
break up this function accordingly.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r-- | include/init.sh | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/include/init.sh b/include/init.sh index 49f126eb..528e1eae 100644 --- a/include/init.sh +++ b/include/init.sh @@ -120,16 +120,10 @@ xbmk_set_env() if [ "$is_child" = "y" ] then - # child instance of xbmk, so we stop init after this point: + # child instance of xbmk, so we stop init after this point + # and execute the given user command upon return: - xbmk_child_set_tmp - - if [ -z "${XBMK_CACHE+x}" ]; then - err "XBMK_CACHE unset on child" "xbmk_set_env" "$@" - fi - if [ -z "${XBMK_THREADS+x}" ]; then - xbmk_set_threads; : - fi + xbmk_child_set_env return 1 else @@ -138,25 +132,21 @@ xbmk_set_env() # command directly; instead, it calls a child instance # of xbmk, and exits with the corresponding return status. - xbmk_parent_check_tmp - - printf "%s\n" "$xbtmp" > "$xbmklock" || \ - err "cannot create '$xbmklock'" xbmk_set_env "$@"; : - - # not really critical for security, but it's a barrier - # against the user to make them think twice before deleting it - # in case an actual instance of xbmk is already running: - - x_ chmod -w "$xbmklock" + xbmk_parent_set_env - xbmk_parent_set_export - xbmk_set_version - - remkdir "$xbtmp" "$xbtmp/gnupath" "$xbtmp/xbmkpath" + return 0 + fi +} - xbmk_set_pyver +xbmk_child_set_env() +{ + xbmk_child_set_tmp - return 0 + if [ -z "${XBMK_CACHE+x}" ]; then + err "XBMK_CACHE unset on child" "xbmk_set_env" "$@" + fi + if [ -z "${XBMK_THREADS+x}" ]; then + xbmk_set_threads; : fi } @@ -165,10 +155,10 @@ xbmk_child_set_tmp() eval `setvars "" badtmp xbtmpchk locktmp` xbtmpchk="`findpath "$TMPDIR" || err "!findpath $TMPDIR"`" || \ - err "!findpath '$TMPDIR'" xbmk_child_set_tmp "$@" + err "!findpath '$TMPDIR'" "xbmk_child_set_tmp" "$@" read -r locktmp < "$xbmklock" || \ - err "can't read '$xbmklock'" xbmk_child_set_tmp "$@" + err "can't read '$xbmklock'" "xbmk_child_set_tmp" "$@" if [ "$locktmp" != "$xbtmpchk" ]; then badtmp="TMPDIR '$xbtmpchk' changed; was '$locktmp'" @@ -181,6 +171,26 @@ xbmk_child_set_tmp() export TMPDIR="$xbtmpchk" } +xbmk_parent_set_env() +{ + xbmk_parent_check_tmp + + printf "%s\n" "$xbtmp" > "$xbmklock" || \ + err "cannot create '$xbmklock'" xbmk_set_env "$@"; : + + # not really critical for security, but it's a barrier + # against the user to make them think twice before deleting it + # in case an actual instance of xbmk is already running: + + x_ chmod -w "$xbmklock" + + xbmk_parent_set_export + xbmk_set_version + + remkdir "$xbtmp" "$xbtmp/gnupath" "$xbtmp/xbmkpath" + + xbmk_set_pyver +} xbmk_parent_check_tmp() { |