init.sh: only update version files on parent

don't update them on child instances, since it's a waste
of time; the lock file prevents further execution, so we
are just wasting time writing to disk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
master
Leah Rowe 2025-05-18 12:58:42 +01:00
parent 412b0a81d7
commit 08610f4145
2 changed files with 24 additions and 17 deletions

View File

@ -30,7 +30,7 @@ xbmk_init()
id -u 1>/dev/null 2>/dev/null || err "suid check failed (id -u)" 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" [ "$(id -u)" != "0" ] || err "this command as root is not permitted"
for init_cmd in get_version set_env lock set_version git_init \ for init_cmd in get_version set_env lock git_init \
mkdirs set_pyver child_exec; do mkdirs set_pyver child_exec; do
xbmk_$init_cmd "$@" || break xbmk_$init_cmd "$@" || break
done done
@ -58,15 +58,7 @@ xbmk_get_version()
[ ! -e ".git" ] && [ ! -f ".version" ] && version="unknown" [ ! -e ".git" ] && [ ! -f ".version" ] && version="unknown"
[ ! -e ".git" ] && [ ! -f ".versiondate" ] && versiondate="1716415872" [ ! -e ".git" ] && [ ! -f ".versiondate" ] && versiondate="1716415872"
version_="$version" [ -n "$version" ] && relname="$projectname-$version"; :
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
relname="$projectname-$version"
} }
xbmk_set_env() xbmk_set_env()
@ -74,7 +66,6 @@ xbmk_set_env()
is_child="n" is_child="n"
xbmkpath="$PATH" xbmkpath="$PATH"
export LOCALVERSION="-$projectname-${version%%-*}"
# unify all temporary files/directories in a single TMPDIR # unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \ [ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
@ -117,7 +108,10 @@ xbmk_set_env()
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1 [ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \ expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1; : 1>/dev/null 2>/dev/null || export XBMK_THREADS=1
xbmk_set_version
export LOCALVERSION="-$projectname-${version%%-*}"
} }
xbmk_lock() xbmk_lock()
@ -128,8 +122,17 @@ xbmk_lock()
xbmk_set_version() xbmk_set_version()
{ {
printf "%s\n" "$version" > ".version" || err "can't save version" version_="$version"
printf "%s\n" "$versiondate" > ".versiondate" || err "can't save date" [ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
update_xbmkver "."
relname="$projectname-$version"
} }
xbmk_git_init() xbmk_git_init()

View File

@ -15,13 +15,17 @@ remkdir()
mkrom_tarball() mkrom_tarball()
{ {
printf "%s\n" "$version" > "$1/.version" || err "$1 !version" update_xbmkver "$1"
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"
mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz" mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
x_ rm -Rf "$1" x_ rm -Rf "$1"
} }
update_xbmkver()
{
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"; :
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"; :
}
mktarball() mktarball()
{ {
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1" printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"