]> git.ipfire.org Git - thirdparty/dracut.git/blobdiff - dracut-functions.sh
dracut: fixed module dependency handling
[thirdparty/dracut.git] / dracut-functions.sh
index 8d62c303585ccc8f59a8c92e5bf8c4adee0f7a3a..1bcc3b43e7ae718e4bb1c37f4aeb133f4662abb1 100755 (executable)
@@ -1314,13 +1314,17 @@ check_mount() {
         fi
     fi
 
-
     for _moddep in $(module_depends $_mod); do
         # handle deps as if they were manually added
-        [[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
-            add_dracutmodules+=" $_moddep "
-        [[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
-            force_add_dracutmodules+=" $_moddep "
+        [[ " $dracutmodules " == *\ $_mod\ * ]] \
+            && [[ " $dracutmodules " != *\ $_moddep\ * ]] \
+            && dracutmodules+=" $_moddep "
+        [[ " $add_dracutmodules " == *\ $_mod\ * ]] \
+            && [[ " $add_dracutmodules " != *\ $_moddep\ * ]] \
+            && add_dracutmodules+=" $_moddep "
+        [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] \
+            && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
+            && force_add_dracutmodules+=" $_moddep "
         # if a module we depend on fail, fail also
         if ! check_module $_moddep; then
             derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
@@ -1358,7 +1362,7 @@ check_module() {
     fi
 
     if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
-        if [[ " $force_add_dracutmodules " == *\ $_mod\ * ]]; then
+        if [[ " $dracutmodules $force_add_dracutmodules " == *\ $_mod\ * ]]; then
             module_check $_mod 1; ret=$?
         else
             module_check $_mod 0; ret=$?
@@ -1369,7 +1373,11 @@ check_module() {
         # module not in our list
         if [[ $dracutmodules = all ]]; then
             # check, if we can and should install this module
-            module_check $_mod || return 1
+            module_check $_mod; ret=$?
+            if [[ $ret != 0 ]]; then
+                [[ $2 ]] && return 1
+                [[ $ret != 255 ]] && return 1
+            fi
         else
             # skip this module
             return 1
@@ -1378,10 +1386,15 @@ check_module() {
 
     for _moddep in $(module_depends $_mod); do
         # handle deps as if they were manually added
-        [[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
-            add_dracutmodules+=" $_moddep "
-        [[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
-            force_add_dracutmodules+=" $_moddep "
+        [[ " $dracutmodules " == *\ $_mod\ * ]] \
+            && [[ " $dracutmodules " != *\ $_moddep\ * ]] \
+            && dracutmodules+=" $_moddep "
+        [[ " $add_dracutmodules " == *\ $_mod\ * ]] \
+            && [[ " $add_dracutmodules " != *\ $_moddep\ * ]] \
+            && add_dracutmodules+=" $_moddep "
+        [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] \
+            && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
+            && force_add_dracutmodules+=" $_moddep "
         # if a module we depend on fail, fail also
         if ! check_module $_moddep; then
             derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
@@ -1418,11 +1431,13 @@ for_each_module_dir() {
         [[ " $mods_to_load " == *\ $_mod\ * ]] && continue
 
         [[ " $force_add_dracutmodules " != *\ $_mod\ * ]] \
+            && [[ " $dracutmodules " != *\ $_mod\ * ]] \
             && [[ " $omit_dracutmodules " == *\ $_mod\ * ]] \
             && continue
 
         derror "dracut module '$_mod' cannot be found or installed."
         [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] && exit 1
+        [[ " $dracutmodules " == *\ $_mod\ * ]] && exit 1
         [[ " $add_dracutmodules " == *\ $_mod\ * ]] && exit 1
     done
 }