summaryrefslogtreecommitdiff
path: root/Meta/build-native-partition.sh
diff options
context:
space:
mode:
authordemostanis <demostanis@protonmail.com>2022-09-03 12:54:05 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-15 01:40:01 +0200
commit48aea321c5e26f1fd71ad5c1dd7ae6be7313d3b6 (patch)
tree11ca673853ba0098cb15285f38978d292e8e9eb5 /Meta/build-native-partition.sh
parentd007337d97189facc8ad1b661ceabf06bfe7e5bc (diff)
downloadserenity-48aea321c5e26f1fd71ad5c1dd7ae6be7313d3b6.zip
Meta: Don't tell to run script as root when that's not the actual error
Before, and that was the cause of many confusion in #build-problems on Discord, the Meta/build-image-*.sh scripts would error out with the message "this script needs to run as root" while the actual error was unrelated.
Diffstat (limited to 'Meta/build-native-partition.sh')
-rwxr-xr-xMeta/build-native-partition.sh15
1 files changed, 13 insertions, 2 deletions
diff --git a/Meta/build-native-partition.sh b/Meta/build-native-partition.sh
index 71ddf11c17..89ea47f6ec 100755
--- a/Meta/build-native-partition.sh
+++ b/Meta/build-native-partition.sh
@@ -16,8 +16,19 @@ cleanup() {
}
if [ "$(id -u)" != 0 ]; then
- sudo -E -- "$0" "$@" || die "this script needs to run as root"
- exit 0
+ set +e
+ ${SUDO} -E -- sh -c "\"$0\" $* || exit 42"
+ case $? in
+ 1)
+ die "this script needs to run as root"
+ ;;
+ 42)
+ exit 1
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
else
: "${SUDO_UID:=0}" "${SUDO_GID:=0}"
fi