From 769a97aed5a712c80141fee8da60868c437fbf36 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 18:50:06 +0100 Subject: init.sh: Hardcode XBMK_CACHE for integrity I never really intended for this to be configurable, but the cache directory is also used during release builds. There's too much that can go wrong, letting the user decide where their cache is. Simplify it by hardcoding. Signed-off-by: Leah Rowe --- include/init.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index ee19c398..cd4acf43 100644 --- a/include/init.sh +++ b/include/init.sh @@ -89,15 +89,9 @@ xbmk_set_env() export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)" xbmktmp="$TMPDIR" - # XBMK_CACHE is a directory, for caching downloads and git repon - [ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache" - [ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache" + export XBMK_CACHE="$xbmkpwd/cache" [ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \ err "cachedir '$xbmkpwd/cache' is a symlink" - [ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache" - xbmkcache="`findpath "$XBMK_CACHE"`" || \ - err "Can't resolve cachedir: '$XBMK_CACHE'" - export XBMK_CACHE="$xbmkcache" [ ! -e "$XBMK_CACHE" ] || \ [ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; : -- cgit v1.2.1 From b25a4876434d371dc4278d71365574158c77d47d Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 18:53:22 +0100 Subject: init.sh: looser XBMK_THREADS validation on child processes, we can simply correct it. we currently provide an error message, but this is silly. Signed-off-by: Leah Rowe --- include/init.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index cd4acf43..38eb1c81 100644 --- a/include/init.sh +++ b/include/init.sh @@ -30,7 +30,7 @@ xbmk_init() id -u 1>/dev/null 2>/dev/null || err "suid check failed (id -u)" [ "$(id -u)" != "0" ] || err "this command as root is not permitted" - for init_cmd in get_version set_env git_init child_exec; do + for init_cmd in get_version set_env set_threads git_init child_exec; do xbmk_$init_cmd "$@" || break done } @@ -76,7 +76,7 @@ xbmk_set_env() if [ "$is_child" = "y" ]; then [ -z "${XBMK_CACHE+x}" ] && err "XBMK_CACHE unset on child" - [ -z "${XBMK_THREADS+x}" ] && err "XBMK_THREADS unset on child" + [ -z "${XBMK_THREADS+x}" ] && xbmk_set_threads e "lock" f missing && err "lock file absent on child" return 1 fi @@ -104,10 +104,6 @@ xbmk_set_env() [ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y" [ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n" - [ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1 - expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \ - 1>/dev/null 2>/dev/null || export XBMK_THREADS=1 - xbmk_set_version export LOCALVERSION="-$projectname-${version%%-*}" @@ -117,6 +113,13 @@ xbmk_set_env() xbmk_set_pyver } +xbmk_set_threads() +{ + [ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1 + expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \ + 1>/dev/null 2>/dev/null || export XBMK_THREADS=1 +} + xbmk_set_version() { version_="$version" -- cgit v1.2.1 From fb7aaa78bb080a473bdf0edf449bf08045e8366c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 20 May 2025 02:58:33 +0100 Subject: vendor.sh: optimise find_me() i'm adding characters to 7ztest, which isn't being passed on through because everything runs in subshells; the next pass would default back to the original string, so a given file may be checked multiple times. fix this by mitigation; use the random string from mktemp as a suffix instead. in practice, this has not affected performance much, but it will nevertheless avoid unnecessary work by xbmk. Signed-off-by: Leah Rowe --- include/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index 38eb1c81..39d48948 100644 --- a/include/init.sh +++ b/include/init.sh @@ -181,7 +181,7 @@ pybin() [ $venv -gt 0 ] && for pypath in "/usr/local/bin" "/usr/bin"; do [ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \ [ -x "$pypath/$1" ] && printf "%s/%s\n" "$pypath" "$1" && \ - return 0 + return 0; : done && return 1 # Defer to normal command -v if not a venv -- cgit v1.2.1 From f6b77822835fcd775a845c825a4e6a78abaa742a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 20 May 2025 20:14:09 +0100 Subject: Revert "vendor.sh: optimise find_me()" This reverts commit fb7aaa78bb080a473bdf0edf449bf08045e8366c. it caused a few issues. will re-do later the old code isn't really broken, just inefficient, because several files are scanned twice, but in practise the overhead isn't that great The error occurs sometimes, when bruteforcing me.bin: ERROR ./mk: Unhandled error for: mv /home/user/lbmk/tmp/me.bin /home/user/lbmk/cache/tmpdl/check This revert should fix the issue, for now. --- include/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index 39d48948..38eb1c81 100644 --- a/include/init.sh +++ b/include/init.sh @@ -181,7 +181,7 @@ pybin() [ $venv -gt 0 ] && for pypath in "/usr/local/bin" "/usr/bin"; do [ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \ [ -x "$pypath/$1" ] && printf "%s/%s\n" "$pypath" "$1" && \ - return 0; : + return 0 done && return 1 # Defer to normal command -v if not a venv -- cgit v1.2.1