aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2025-09-23 16:41:59 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2025-09-23 16:41:59 +0200
commit29523170630804b6083c6d46ac54d65e06bde176 (patch)
treea3b4332b0f8add794197541f354d9caac2a9336f /bin
parenta8a6111e22a69a315bfb1fb112d24a03bb8c1fa3 (diff)
downloaddotfiles-295231706308.tar.gz
dotfiles-295231706308.zip
bin: Guess the QEMU_KERNEL to be used based on cwd
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/run-riscv-qemu.sh21
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/run-riscv-qemu.sh b/bin/run-riscv-qemu.sh
index c96cafb..2e926cf 100755
--- a/bin/run-riscv-qemu.sh
+++ b/bin/run-riscv-qemu.sh
@@ -4,12 +4,25 @@ set -e
# Enfore BUSYBOX_SRC and QEMU_KERNEL.
if [ -z "$BUSYBOX_SRC" ]; then
- echo "run-qemu (error): you need to define BUSYBOX_SRC."
+ echo "run-riscv-qemu (error): you need to define BUSYBOX_SRC."
exit 1
fi
+
+# If the $QEMU_KERNEL environment variable is not explicitely set, then guess
+# one based on the current working directory.
if [ -z "$QEMU_KERNEL" ]; then
- echo "run-qemu (error): you need to define QEMU_KERNEL with the Image to be used."
- exit 1
+ if [ ! -z "$ARCH" ]; then
+ if [ -f "arch/$ARCH/boot/Image" ]; then
+ QEMU_KERNEL=$(realpath "arch/$ARCH/boot/Image")
+ else
+ echo "run-riscv-qemu (error): you need to define QEMU_KERNEL with the Image to be used."
+ exit 1
+ fi
+ echo "run-riscv-qemu (info): using '$QEMU_KERNEL' as the Linux kernel Image."
+ else
+ echo "run-riscv-qemu (error): you need to define QEMU_KERNEL with the Image to be used."
+ exit 1
+ fi
fi
# Configurable variables.
@@ -31,7 +44,7 @@ while [[ $# -gt 0 ]]; do
shift
;;
-*)
- echo "run-qemu (error): unknown option '$1'."
+ echo "run-riscv-qemu (error): unknown option '$1'."
exit 1
;;
*)