1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
From: Benjamin Drung <benjamin.drung@canonical.com>
Date: Wed, 19 Nov 2025 04:14:28 +0100
Subject: test(run-qemu): do not expect -initrd as first parameter
Check all parameters for `-initrd` instead of expecting it to be the
first parameter.
Forwarded: https://github.com/dracut-ng/dracut-ng/pull/1860
---
test/run-qemu | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/test/run-qemu b/test/run-qemu
index 073d69b..cc1fab6 100755
--- a/test/run-qemu
+++ b/test/run-qemu
@@ -7,6 +7,17 @@ export PATH=/usr/sbin:/usr/bin:/sbin:/bin
ARCH="${ARCH-$(uname -m)}"
QEMU_CPU="${QEMU_CPU:-max}"
+get_initrd() {
+ local next
+ for i in $(seq 1 $(($# - 1))); do
+ if [[ ${!i} == "-initrd" ]]; then
+ next=$((i + 1))
+ echo "${!next}"
+ return
+ fi
+ done
+}
+
quote_args() {
local arg args=()
for arg in "$@"; do
@@ -106,12 +117,9 @@ if [[ $ARCH != "s390x" ]]; then
fi
# only set -kernel if -initrd is specified
-if [[ $* == *-initrd* ]]; then
- for arg in "$@"; do
- [[ $1 == *-initrd* ]] && break
- done
-
- KVERSION=$(lsinitrd "$arg" | grep modules.dep | head -1 | rev | cut -d'/' -f2 | rev)
+initrd=$(get_initrd "$@")
+if [[ -n $initrd ]]; then
+ KVERSION=$(lsinitrd "$initrd" | grep modules.dep | head -1 | rev | cut -d'/' -f2 | rev)
set_vmlinux_env
ARGS+=(-kernel "$VMLINUZ")
fi
|