]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(dracut): expose determine_kernel_image as a public function
authorJo Zzsi <jozzsicsataban@gmail.com>
Thu, 15 Jan 2026 22:52:35 +0000 (17:52 -0500)
committerLaszlo <laszlo.gombos@gmail.com>
Sat, 17 Jan 2026 02:06:39 +0000 (21:06 -0500)
Expose determine_kernel_image as a public and documented helper
function.

dracut-functions.sh
man/dracut.modules.7.adoc
test/TEST-12-UEFI/test.sh
test/TEST-43-KERNEL-INSTALL/test.sh
test/test-functions

index 460499b0d53305ed9fcfdf68c74906c6b1d6a00b..067dad80e078d9af56cbccf0c548503ee6f480c0 100755 (executable)
@@ -1485,6 +1485,27 @@ require_kernel_modules() {
     return "$_ret"
 }
 
+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
+    return 1
+}
+
 if ! is_func dinfo > /dev/null 2>&1; then
     # shellcheck source=./dracut-logger.sh
     . "${BASH_SOURCE[0]%/*}/dracut-logger.sh"
index 5db25e3547af3e7f31a3d420a8ab2a75414e7958..62aaca5c6d22e87406357087ab1972528fb8c550 100644 (file)
@@ -394,8 +394,9 @@ Issues a standardized warning message.
 
 === Initramfs Functions
 
-FIXME
+==== determine_kernel_image <kversion>
 
+Helper function for determining the path for the kernel image file.
 
 === Network Modules
 
index b00f139d0fd541568f760921c2b27247b1f53337..0ca9d4f0e59c578d14131ff92a700c6bbb2576ab 100755 (executable)
@@ -44,6 +44,9 @@ test_run() {
 }
 
 test_setup() {
+    # shellcheck source=./dracut-functions.sh
+    . "$PKGLIBDIR"/dracut-functions.sh
+
     # Create what will eventually be our root filesystem
     call_dracut --tmpdir "$TESTDIR" \
         --add-confdir test-root \
index 70cbd20c77d067a7a06d29c7136dfd2331155350..5887cddb1db77abdc89d7b4be461c3cabad7586a 100755 (executable)
@@ -38,6 +38,9 @@ test_run() {
 }
 
 test_setup() {
+    # shellcheck source=./dracut-functions.sh
+    . "$PKGLIBDIR"/dracut-functions.sh
+
     # create root filesystem
     # shellcheck disable=SC2153
     call_dracut --tmpdir "$TESTDIR" \
index 9d2df77d4ef01bf0a62cbd02a0cbad16d72015c2..64fe9eb6944ce4adb190485013e158e6e1b485d8 100644 (file)
@@ -141,27 +141,6 @@ determine_kernel_version() {
     lsinitrd "$1" | grep modules.dep | head -1 | sed 's;.*/\([^/]\+\)/modules.dep;\1;'
 }
 
-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)