summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-10-16 21:46:42 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-16 23:39:45 +0200
commit2a4f81fc8374354e9109333894eef0ca4f1046de (patch)
tree5223ef140b3029155c891cb7747a8642b60ba50c
parent9d6c4c51379b2561ebc72db9ba32576004604275 (diff)
downloadserenity-2a4f81fc8374354e9109333894eef0ca4f1046de.zip
Meta: Start moving common shell definitions into a common file
-rwxr-xr-xMeta/.shell_include.sh15
-rwxr-xr-xMeta/build-image-extlinux.sh12
-rwxr-xr-xMeta/build-image-grub.sh12
-rwxr-xr-xMeta/build-image-limine.sh12
-rwxr-xr-xMeta/build-image-qemu.sh12
-rwxr-xr-xMeta/build-native-partition.sh12
6 files changed, 25 insertions, 50 deletions
diff --git a/Meta/.shell_include.sh b/Meta/.shell_include.sh
new file mode 100755
index 0000000000..bf883b6319
--- /dev/null
+++ b/Meta/.shell_include.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# shellcheck disable=SC2034
+# SC2034: "Variable appears unused. Verify it or export it."
+# Those are intentional here, as the file is meant to be included elsewhere.
+
+SUDO="sudo"
+
+if [ "$(uname -s)" = "SerenityOS" ]; then
+ SUDO="pls"
+fi
+
+die() {
+ echo "die: $*"
+ exit 1
+}
diff --git a/Meta/build-image-extlinux.sh b/Meta/build-image-extlinux.sh
index 863d91bb7e..2840733441 100755
--- a/Meta/build-image-extlinux.sh
+++ b/Meta/build-image-extlinux.sh
@@ -2,16 +2,9 @@
set -e
-SUDO="sudo"
-
-if [ "$(uname -s)" = "SerenityOS" ]; then
- SUDO="pls"
-fi
+script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
-die() {
- echo "die: $*"
- exit 1
-}
+. "${script_path}/.shell_include.sh"
if [ "$(id -u)" != 0 ]; then
set +e
@@ -98,7 +91,6 @@ mkdir -p mnt
mount "${dev}${partition_number}" mnt/ || die "couldn't mount filesystem"
echo "done"
-script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
"$script_path/build-root-filesystem.sh"
if [ -z "$1" ]; then
diff --git a/Meta/build-image-grub.sh b/Meta/build-image-grub.sh
index 4bb95b7667..c0720e335a 100755
--- a/Meta/build-image-grub.sh
+++ b/Meta/build-image-grub.sh
@@ -2,16 +2,9 @@
set -e
-SUDO="sudo"
-
-if [ "$(uname -s)" = "SerenityOS" ]; then
- SUDO="pls"
-fi
+script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
-die() {
- echo "die: $*"
- exit 1
-}
+. "${script_path}/.shell_include.sh"
if [ "$(id -u)" != 0 ]; then
set +e
@@ -116,7 +109,6 @@ mkdir -p mnt
mount "${dev}${partition_number}" mnt/ || die "couldn't mount filesystem"
echo "done"
-script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
"$script_path/build-root-filesystem.sh"
if [ -z "$2" ]; then
diff --git a/Meta/build-image-limine.sh b/Meta/build-image-limine.sh
index b4c2ac8c3c..94787a2740 100755
--- a/Meta/build-image-limine.sh
+++ b/Meta/build-image-limine.sh
@@ -2,16 +2,9 @@
set -e
-SUDO="sudo"
+script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
-if [ "$(uname -s)" = "SerenityOS" ]; then
- SUDO="pls"
-fi
-
-die() {
- echo "die: $*"
- exit 1
-}
+. "${script_path}/.shell_include.sh"
if [ ! -d "limine" ]; then
echo "limine not found, the script will now build it"
@@ -102,7 +95,6 @@ mkdir -p mnt
mount "${dev}p2" mnt || die "couldn't mount root filesystem"
echo "done"
-script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
"$script_path/build-root-filesystem.sh"
echo "installing limine"
diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh
index 832bf683ba..e94f396689 100755
--- a/Meta/build-image-qemu.sh
+++ b/Meta/build-image-qemu.sh
@@ -14,16 +14,9 @@ fi
set -e
-SUDO="sudo"
+SCRIPT_DIR="$(dirname "${0}")"
-if [ "$(uname -s)" = "SerenityOS" ]; then
- SUDO="pls"
-fi
-
-die() {
- echo "die: $*"
- exit 1
-}
+. "${SCRIPT_DIR}/.shell_include.sh"
USE_FUSE2FS=0
@@ -66,7 +59,6 @@ else
fi
fi
-SCRIPT_DIR="$(dirname "${0}")"
# Prepend the toolchain qemu directory so we pick up QEMU from there
PATH="$SCRIPT_DIR/../Toolchain/Local/qemu/bin:$PATH"
diff --git a/Meta/build-native-partition.sh b/Meta/build-native-partition.sh
index fa73ad6da5..e702482ca5 100755
--- a/Meta/build-native-partition.sh
+++ b/Meta/build-native-partition.sh
@@ -2,16 +2,9 @@
set -e
-SUDO="sudo"
+script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
-if [ "$(uname -s)" = "SerenityOS" ]; then
- SUDO="pls"
-fi
-
-die() {
- echo "die: $*"
- exit 1
-}
+. "${script_path}/.shell_include.sh"
cleanup() {
if [ -d mnt ]; then
@@ -60,5 +53,4 @@ else
echo "done"
fi
-script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
"$script_path/build-root-filesystem.sh"