build: don't generate version/versiondate as root

don't run it directly at the bottom of err.sh,
because otherwise the version and versiondate
files will be generated when running "./build
dependencies distroname" which would then create
these files, but as root because the user runs
that specific command as root.

the rest of lbmk, for any other command, prevents
use of the root account, so running check_project
during "./build dependencies distroname" will cause
the build system to fail (because as non-root user,
the user will run lbmk and it will try to update
those files, and fail because it can't, due to lack
of permissions)

this patch fixes the issue, by only generating those
files if the user is *not* root

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-11-08 06:05:49 +00:00
parent c4d9008753
commit f4b2a588e2
2 changed files with 6 additions and 3 deletions

7
build
View File

@ -43,7 +43,10 @@ main()
{ {
xx_ id -u 1>/dev/null 2>/dev/null xx_ id -u 1>/dev/null 2>/dev/null
[ $# -lt 1 ] && fail "Too few arguments. Try: ${0} help" [ $# -lt 1 ] && fail "Too few arguments. Try: ${0} help"
[ "${1}" = "dependencies" ] && xx_ install_packages $@ && lbmk_exit 0 if [ "${1}" = "dependencies" ]; then
xx_ install_packages $@
lbmk_exit 0
fi
initialise_command $@ && shift 1 initialise_command $@ && shift 1
@ -59,6 +62,8 @@ initialise_command()
{ {
[ "$(id -u)" != "0" ] || fail "this command as root is not permitted" [ "$(id -u)" != "0" ] || fail "this command as root is not permitted"
check_project
case "${1}" in case "${1}" in
help) usage ${0} && lbmk_exit 0 ;; help) usage ${0} && lbmk_exit 0 ;;
list) items "${buildpath}" && lbmk_exit 0 ;; list) items "${buildpath}" && lbmk_exit 0 ;;

View File

@ -78,5 +78,3 @@ err()
printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2 printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
exit 1 exit 1
} }
check_project