summaryrefslogtreecommitdiff
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
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.
-rwxr-xr-xMeta/build-image-extlinux.sh14
-rwxr-xr-xMeta/build-image-grub.sh14
-rwxr-xr-xMeta/build-image-limine.sh14
-rwxr-xr-xMeta/build-image-qemu.sh15
-rwxr-xr-xMeta/build-native-partition.sh15
5 files changed, 65 insertions, 7 deletions
diff --git a/Meta/build-image-extlinux.sh b/Meta/build-image-extlinux.sh
index 176a36e6f8..f52e29b168 100755
--- a/Meta/build-image-extlinux.sh
+++ b/Meta/build-image-extlinux.sh
@@ -8,7 +8,19 @@ die() {
}
if [ "$(id -u)" != 0 ]; then
- exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
+ 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
diff --git a/Meta/build-image-grub.sh b/Meta/build-image-grub.sh
index dffc940fdb..c0b8ecc2bd 100755
--- a/Meta/build-image-grub.sh
+++ b/Meta/build-image-grub.sh
@@ -8,7 +8,19 @@ die() {
}
if [ "$(id -u)" != 0 ]; then
- exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
+ 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
diff --git a/Meta/build-image-limine.sh b/Meta/build-image-limine.sh
index 0760ed7772..c84330323a 100755
--- a/Meta/build-image-limine.sh
+++ b/Meta/build-image-limine.sh
@@ -17,7 +17,19 @@ if [ ! -d "limine" ]; then
fi
if [ "$(id -u)" != 0 ]; then
- exec sudo -E -- "$0" "$@" || die "this script needs to run as root"
+ 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
diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh
index 114e555db1..832bf683ba 100755
--- a/Meta/build-image-qemu.sh
+++ b/Meta/build-image-qemu.sh
@@ -31,8 +31,19 @@ if [ "$(id -u)" != 0 ]; then
if [ -x "$FUSE2FS_PATH" ] && $FUSE2FS_PATH --help 2>&1 |grep fakeroot > /dev/null; then
USE_FUSE2FS=1
else
- ${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
fi
else
: "${SUDO_UID:=0}" "${SUDO_GID:=0}"
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