]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut-init.sh): add module to mods_to_load before checking dependencies
authorPhilipp Rudo <prudo@redhat.com>
Thu, 25 Jul 2024 10:47:00 +0000 (12:47 +0200)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Wed, 31 Jul 2024 11:41:26 +0000 (07:41 -0400)
When implementing erofs support for 99squash we end up with three
modules 99squash, 95squash-squashfs and 95squash-erofs. Where 99squash
contains the common code for filesystem images and
95squash-{squashfs,erofs} the special handing depending on the
filesystem used. This leads to a dependency cycle as we want to allow
users both to choose 99squash, when the exact filesystem doesn't matter,
as well as 95squash-{squashfs,erofs} when a specific filesystem is
required.

But when 99squash is added as a dependency calling
dracut_module_included fails in its depends() function. This lead to
cases where both handlers, 95squash-squashfs and 95squash-erofs, were
added to the initrd.

Reason for the failure is that a module only is marked to be loaded
after all it's dependencies have been checked as well. Thus a child
module cannot detect which parent module wants it to be included. Fix
this by marking modules to be loaded before checking its dependencies in
check_module. Do the same change in check_mount for consistency.

Signed-off-by: Philipp Rudo <prudo@redhat.com>
dracut-init.sh

index b9134864428ec712806dd75730a664f6004513b2..e47e034d2ed1109c81db7932f8b8bc9cbc73b449 100755 (executable)
@@ -882,6 +882,9 @@ check_mount() {
         fi
     fi
 
+    [[ " $mods_to_load " == *\ $_mod\ * ]] \
+        || mods_to_load+=" $_mod "
+
     for _moddep in $(module_depends "$_mod" "$_moddir"); do
         # handle deps as if they were manually added
         [[ " $dracutmodules " == *\ $_mod\ * ]] \
@@ -900,9 +903,6 @@ check_mount() {
         fi
     done
 
-    [[ " $mods_to_load " == *\ $_mod\ * ]] \
-        || mods_to_load+=" $_mod "
-
     return 0
 }
 
@@ -957,6 +957,9 @@ check_module() {
         fi
     fi
 
+    [[ " $mods_to_load " == *\ $_mod\ * ]] \
+        || mods_to_load+=" $_mod "
+
     for _moddep in $(module_depends "$_mod" "$_moddir"); do
         # handle deps as if they were manually added
         [[ " $dracutmodules " == *\ $_mod\ * ]] \
@@ -975,9 +978,6 @@ check_module() {
         fi
     done
 
-    [[ " $mods_to_load " == *\ $_mod\ * ]] \
-        || mods_to_load+=" $_mod "
-
     return 0
 }