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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
From: Benjamin Drung <benjamin.drung@canonical.com>
Date: Fri, 26 Sep 2025 01:28:05 +0200
Subject: test: avoid kernel-install add-all
The man page of `kernel-install` says about `add-all`: "This is the same
as add, but invokes the operation iteratively for every installed kernel
in /usr/lib/modules/. This operation is only supported on systems where
the kernel image is installed in
/usr/lib/modules/KERNEL-VERSION/vmlinuz."
Debian and Ubuntu do not ship the kernel images in `/usr/lib/modules/`
and therefore `add-all` is not supported there.
Since the test cases already determine the kernel version, search for
the kernel image and use `kernel-install add` instead of `add-all`.
Forwarded: https://github.com/dracut-ng/dracut-ng/pull/1708
---
test/TEST-12-UEFI/test.sh | 3 ++-
test/TEST-43-KERNEL-INSTALL/test.sh | 3 ++-
test/test-functions | 21 +++++++++++++++++++++
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/test/TEST-12-UEFI/test.sh b/test/TEST-12-UEFI/test.sh
index 37bc4c4..e1936e9 100755
--- a/test/TEST-12-UEFI/test.sh
+++ b/test/TEST-12-UEFI/test.sh
@@ -49,6 +49,7 @@ test_setup() {
"$TESTDIR"/tmp-initramfs.root
KVERSION=$(determine_kernel_version "$TESTDIR"/tmp-initramfs.root)
+ KIMAGE=$(determine_kernel_image "$KVERSION")
mksquashfs "$TESTDIR"/dracut.*/initramfs/ "$TESTDIR"/squashfs.img -quiet -no-progress
@@ -81,7 +82,7 @@ test_setup() {
# using kernell-install to invoke dracut
mkdir -p "$BOOT_ROOT/$TOKEN/$KVERSION" "$BOOT_ROOT/loader/entries"
- kernel-install add-all
+ kernel-install add "$KVERSION" "$KIMAGE"
mv "$TESTDIR"/EFI/Linux/*.efi "$TESTDIR"/ESP/EFI/BOOT/BOOTX64.efi
diff --git a/test/TEST-43-KERNEL-INSTALL/test.sh b/test/TEST-43-KERNEL-INSTALL/test.sh
index 2b53c49..c486844 100755
--- a/test/TEST-43-KERNEL-INSTALL/test.sh
+++ b/test/TEST-43-KERNEL-INSTALL/test.sh
@@ -55,6 +55,7 @@ test_setup() {
-f "$TESTDIR"/initramfs.root
KVERSION=$(determine_kernel_version "$TESTDIR"/initramfs.root)
+ KIMAGE=$(determine_kernel_image "$KVERSION")
dd if=/dev/zero of="$TESTDIR"/root.img bs=200MiB count=1 status=none && sync "$TESTDIR"/root.img
mkfs.ext4 -q -L dracut -d "$TESTDIR"/dracut.*/initramfs/ "$TESTDIR"/root.img && sync "$TESTDIR"/root.img
@@ -70,7 +71,7 @@ test_setup() {
# using kernell-install to invoke dracut
mkdir -p "$BOOT_ROOT/$TOKEN/$KVERSION" "$BOOT_ROOT/loader/entries" "$BOOT_ROOT/$TOKEN/0-rescue/loader/entries"
- kernel-install add-all
+ kernel-install add "$KVERSION" "$KIMAGE"
}
# shellcheck disable=SC1090
diff --git a/test/test-functions b/test/test-functions
index ff10420..b08efc1 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -111,6 +111,27 @@ determine_kernel_version() {
lsinitrd "$1" | grep modules.dep | head -1 | rev | cut -d'/' -f2 | rev
}
+determine_kernel_image() {
+ local kversion="$1"
+ local paths=(
+ "/lib/modules/${kversion}/vmlinuz"
+ "/lib/modules/${kversion}/vmlinux"
+ "lib/modules/${kversion}/Image"
+ "/boot/vmlinuz-${kversion}"
+ "/boot/vmlinux-${kversion}"
+ )
+
+ for path in "${paths[@]}"; do
+ if [ -f "$path" ]; then
+ echo "$path"
+ return 0
+ fi
+ done
+
+ echo "Could not find a Linux kernel image for version '$kversion'!" >&2
+ exit 1
+}
+
# terminal sequence to set color to a 'success' color (currently: green)
function SETCOLOR_SUCCESS() { echo -en '\033[0;32m'; }
# terminal sequence to set color to a 'failure' color (currently: red)
|