]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: avoid kernel-install add-all
authorBenjamin Drung <benjamin.drung@canonical.com>
Thu, 25 Sep 2025 23:28:05 +0000 (01:28 +0200)
committerLaszlo <laszlo.gombos@gmail.com>
Fri, 26 Sep 2025 00:21:19 +0000 (20:21 -0400)
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`.

test/TEST-12-UEFI/test.sh
test/TEST-43-KERNEL-INSTALL/test.sh
test/test-functions

index 4dbc8ad4c3155c94c6e7433e34b6b6d73d2b8e84..5a8d79467d5eddd1ba6fb79e8260b765c0445333 100755 (executable)
@@ -56,11 +56,7 @@ test_setup() {
         "$TESTDIR"/tmp-initramfs.root
 
     KVERSION=$(determine_kernel_version "$TESTDIR"/tmp-initramfs.root)
-
-    # workaround for kernel-install for Debian
-    if ! [ -e /usr/lib/modules/"$KVERSION"/vmlinuz ]; then
-        ln -sf /boot/vmlinuz-"$KVERSION" /usr/lib/modules/"$KVERSION"/vmlinuz
-    fi
+    KIMAGE=$(determine_kernel_image "$KVERSION")
 
     mksquashfs "$TESTDIR"/dracut.*/initramfs/ "$TESTDIR"/squashfs.img -quiet -no-progress
 
@@ -90,7 +86,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
 
index ab97a7df2627ff5cc0a051d65067d3593c01aaf8..19594b25a4cbae140c30ae4847f881da427f19ad 100755 (executable)
@@ -50,11 +50,7 @@ test_setup() {
         -f "$TESTDIR"/initramfs.root
 
     KVERSION=$(determine_kernel_version "$TESTDIR"/initramfs.root)
-
-    # workaround for kernel-install for Debian
-    if ! [ -e /usr/lib/modules/"$KVERSION"/vmlinuz ]; then
-        ln -sf /boot/vmlinuz-"$KVERSION" /usr/lib/modules/"$KVERSION"/vmlinuz
-    fi
+    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 +66,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
index ff1042071d298ff249249e46abb86fdfa7f8e0fb..b08efc18e8bc0cf4fa425e2af8f86aca979d402f 100644 (file)
@@ -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)