lib.sh: perform root check even earlier

initialising variables, setting PWD, setting version,
this is all unnecessary before the root check, because
the dependencies commands use none of these.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe 2025-04-18 02:16:21 +01:00
parent dbf40653b2
commit ec25425e55

View file

@ -79,16 +79,9 @@ install_packages()
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; :
}
xbmkpwd="`pwd`" || $err "Cannot generate PWD"
export PWD="$xbmkpwd"
eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \
datadir version relname xbmktmp`"
for fv in version versiondate; do
eval "[ ! -f \".$fv\" ] || read -r $fv < \".$fv\" || :"
done
if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then
install_packages "$@" || exit 1
exit 0
@ -97,6 +90,13 @@ fi
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"
xbmkpwd="`pwd`" || $err "Cannot generate PWD"
export PWD="$xbmkpwd"
for fv in version versiondate; do
eval "[ ! -f \".$fv\" ] || read -r $fv < \".$fv\" || :"
done
pyver="2"
python="python3"
command -v python3 1>/dev/null || python="python"