diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2025-09-23 16:41:59 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2025-09-23 16:41:59 +0200 |
| commit | 29523170630804b6083c6d46ac54d65e06bde176 (patch) | |
| tree | a3b4332b0f8add794197541f354d9caac2a9336f | |
| parent | a8a6111e22a69a315bfb1fb112d24a03bb8c1fa3 (diff) | |
| download | dotfiles-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>
| -rw-r--r-- | .bashrc | 1 | ||||
| -rwxr-xr-x | bin/run-riscv-qemu.sh | 21 |
2 files changed, 17 insertions, 5 deletions
@@ -130,7 +130,6 @@ fi # Local builds for busybox and the Linux kernel. Needed by scripts like # `bin/run-riscv-qemu.sh`. export BUSYBOX_SRC="$HOME/src/busybox/1.36.1" -export QEMU_KERNEL="$HOME/src/git.kernel.org/linux/kernel/riscv/arch/riscv/boot/Image" ## # Misc. 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 ;; *) |
