From cba04aa74b816cbd5f1266a73962f6dd48ee2892 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 19:00:13 +0100 Subject: init.sh: Use readlink in pybin() Use realpath only as a fallback. Signed-off-by: Leah Rowe --- include/init.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index 1be860ea..5032d734 100644 --- a/include/init.sh +++ b/include/init.sh @@ -80,8 +80,7 @@ pybin() # ideally, don't rely on PATH or hardcoded paths if python venv. # use the *real*, direct executable linked to by the venv symlink if [ $venv -gt 0 ] && [ -L "`command -v "$1" 2>/dev/null`" ]; then - # realpath isn't posix, but available mostly universally - pypath="$(realpath \ + pypath="$(findpath \ "$(command -v "$1" 2>/dev/null)" 2>/dev/null || :)" [ -e "$pypath" ] && [ ! -d "$pypath" ] && \ [ -x "$pypath" ] && printf "%s\n" "$pypath" && return 0; : -- cgit v1.2.1 From 40a944118f2af08ab37719c07cf7e826267a0eef Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 19:03:51 +0100 Subject: init.sh: run set_version before set_env Signed-off-by: Leah Rowe --- include/init.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index 5032d734..6ccdf13f 100644 --- a/include/init.sh +++ b/include/init.sh @@ -31,7 +31,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 set_pyver set_env set_version git_init create_tmpdir \ + for init_cmd in set_pyver set_version set_env git_init create_tmpdir \ lock create_pathdirs child_exec; do xbmk_$init_cmd "$@" || break done @@ -97,26 +97,6 @@ pybin() command -v "$1" 2>/dev/null || return 1 } -xbmk_set_env() -{ - # 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" - [ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \ - err "cachedir '$xbmkpwd/cache' is a symlink" - [ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache" - [ -f "$XBMK_CACHE" ] && err "cachedir '$XBMK_CACHE' is a file"; : - - # if "y": a coreboot target won't be built if target.cfg says release="n" - # (this is used to exclude certain build targets from releases) - [ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n" - [ "$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() { [ ! -f ".version" ] || read -r version < ".version" || :; : @@ -142,6 +122,26 @@ xbmk_set_version() export LOCALVERSION="-$projectname-${version%%-*}" } +xbmk_set_env() +{ + # 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" + [ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \ + err "cachedir '$xbmkpwd/cache' is a symlink" + [ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache" + [ -f "$XBMK_CACHE" ] && err "cachedir '$XBMK_CACHE' is a file"; : + + # if "y": a coreboot target won't be built if target.cfg says release="n" + # (this is used to exclude certain build targets from releases) + [ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n" + [ "$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_git_init() { for gitarg in "--global user.name" "--global user.email"; do -- cgit v1.2.1 From e1628ad8f3e63428888b42d0c49c3fe6b3c9d006 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 19:04:52 +0100 Subject: init.sh: export LOCALVERSION in set_env Don't do it in set_version Signed-off-by: Leah Rowe --- include/init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index 6ccdf13f..1bf52eef 100644 --- a/include/init.sh +++ b/include/init.sh @@ -119,11 +119,12 @@ xbmk_set_version() printf "%s\n" "$versiondate" > ".versiondate" || err "can't save date" relname="$projectname-$version" - export LOCALVERSION="-$projectname-${version%%-*}" } xbmk_set_env() { + export LOCALVERSION="-$projectname-${version%%-*}" + # 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" -- cgit v1.2.1 From e1af1055ed11b25df42c8a7a32c250da346b08b7 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 19:09:29 +0100 Subject: init.sh: check XBMK_CACHE is a directory instead it doesn't matter if it's not a file. that's the wrong check. 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 1bf52eef..1a01de45 100644 --- a/include/init.sh +++ b/include/init.sh @@ -131,7 +131,7 @@ xbmk_set_env() [ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \ err "cachedir '$xbmkpwd/cache' is a symlink" [ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache" - [ -f "$XBMK_CACHE" ] && err "cachedir '$XBMK_CACHE' is a file"; : + [ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; : # if "y": a coreboot target won't be built if target.cfg says release="n" # (this is used to exclude certain build targets from releases) -- cgit v1.2.1 From 570f1417a80224cf73a57febf126bd80e908b32e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 19:12:51 +0100 Subject: init.sh: Resolve XBMK_CACHE via readlink Signed-off-by: Leah Rowe --- include/init.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index 1a01de45..a322370b 100644 --- a/include/init.sh +++ b/include/init.sh @@ -131,6 +131,9 @@ xbmk_set_env() [ -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" [ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; : # if "y": a coreboot target won't be built if target.cfg says release="n" -- cgit v1.2.1 From 1b0afdcea226ebc4e5f46c50fc21aa835b52ada9 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 19:23:32 +0100 Subject: init.sh: also allow XBMK_RELEASE=Y or N as opposed to =n or =y Signed-off-by: Leah Rowe --- include/init.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index a322370b..e5e3f564 100644 --- a/include/init.sh +++ b/include/init.sh @@ -139,6 +139,8 @@ xbmk_set_env() # if "y": a coreboot target won't be built if target.cfg says release="n" # (this is used to exclude certain build targets from releases) [ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n" + [ "$XBMK_RELEASE" = "N" ] && export XBMK_RELEASE="n" + [ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y" [ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n" [ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1 -- cgit v1.2.1 From 2cea8517f3b6c7f72cdecbcd3e6745db29284852 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 May 2025 21:16:50 +0100 Subject: init.sh: remove useless export we already reset to n if not y, afterward just rely on that Signed-off-by: Leah Rowe --- include/init.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'include/init.sh') diff --git a/include/init.sh b/include/init.sh index e5e3f564..d2db0236 100644 --- a/include/init.sh +++ b/include/init.sh @@ -139,7 +139,6 @@ xbmk_set_env() # if "y": a coreboot target won't be built if target.cfg says release="n" # (this is used to exclude certain build targets from releases) [ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n" - [ "$XBMK_RELEASE" = "N" ] && export XBMK_RELEASE="n" [ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y" [ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n" -- cgit v1.2.1