Blame SOURCES/0236-dracut-fixed-module-dependency-handling.patch

a56a5e
From 6914b67545633d23063d5c5812591c67df56c0cf Mon Sep 17 00:00:00 2001
a56a5e
From: Harald Hoyer <harald@redhat.com>
a56a5e
Date: Fri, 24 Oct 2014 13:19:58 +0200
a56a5e
Subject: [PATCH] dracut: fixed module dependency handling
a56a5e
a56a5e
Fail for "--modules" and "--force-add" dracut modules, if they or their
a56a5e
dependencies cannot be included.
a56a5e
a56a5e
(cherry picked from commit ab2f95e45ed9803c5cbee23f41201a0f934f8043)
a56a5e
---
a56a5e
 dracut-functions.sh | 37 ++++++++++++++++++++++++++-----------
a56a5e
 dracut.sh           |  4 +++-
a56a5e
 2 files changed, 29 insertions(+), 12 deletions(-)
a56a5e
a56a5e
diff --git a/dracut-functions.sh b/dracut-functions.sh
a56a5e
index 6e0b44a..89438b2 100755
a56a5e
--- a/dracut-functions.sh
a56a5e
+++ b/dracut-functions.sh
a56a5e
@@ -1215,13 +1215,17 @@ check_mount() {
a56a5e
         fi
a56a5e
     fi
a56a5e
 
a56a5e
-
a56a5e
     for _moddep in $(module_depends $_mod); do
a56a5e
         # handle deps as if they were manually added
a56a5e
-        [[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
a56a5e
-            add_dracutmodules+=" $_moddep "
a56a5e
-        [[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
a56a5e
-            force_add_dracutmodules+=" $_moddep "
a56a5e
+        [[ " $dracutmodules " == *\ $_mod\ * ]] \
a56a5e
+            && [[ " $dracutmodules " != *\ $_moddep\ * ]] \
a56a5e
+            && dracutmodules+=" $_moddep "
a56a5e
+        [[ " $add_dracutmodules " == *\ $_mod\ * ]] \
a56a5e
+            && [[ " $add_dracutmodules " != *\ $_moddep\ * ]] \
a56a5e
+            && add_dracutmodules+=" $_moddep "
a56a5e
+        [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] \
a56a5e
+            && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
a56a5e
+            && force_add_dracutmodules+=" $_moddep "
a56a5e
         # if a module we depend on fail, fail also
a56a5e
         if ! check_module $_moddep; then
a56a5e
             derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
a56a5e
@@ -1259,7 +1263,7 @@ check_module() {
a56a5e
     fi
a56a5e
 
a56a5e
     if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
a56a5e
-        if [[ " $force_add_dracutmodules " == *\ $_mod\ * ]]; then
a56a5e
+        if [[ " $dracutmodules $force_add_dracutmodules " == *\ $_mod\ * ]]; then
a56a5e
             module_check $_mod 1; ret=$?
a56a5e
         else
a56a5e
             module_check $_mod 0; ret=$?
a56a5e
@@ -1270,7 +1274,11 @@ check_module() {
a56a5e
         # module not in our list
a56a5e
         if [[ $dracutmodules = all ]]; then
a56a5e
             # check, if we can and should install this module
a56a5e
-            module_check $_mod || return 1
a56a5e
+            module_check $_mod; ret=$?
a56a5e
+            if [[ $ret != 0 ]]; then
a56a5e
+                [[ $2 ]] && return 1
a56a5e
+                [[ $ret != 255 ]] && return 1
a56a5e
+            fi
a56a5e
         else
a56a5e
             # skip this module
a56a5e
             return 1
a56a5e
@@ -1279,10 +1287,15 @@ check_module() {
a56a5e
 
a56a5e
     for _moddep in $(module_depends $_mod); do
a56a5e
         # handle deps as if they were manually added
a56a5e
-        [[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
a56a5e
-            add_dracutmodules+=" $_moddep "
a56a5e
-        [[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
a56a5e
-            force_add_dracutmodules+=" $_moddep "
a56a5e
+        [[ " $dracutmodules " == *\ $_mod\ * ]] \
a56a5e
+            && [[ " $dracutmodules " != *\ $_moddep\ * ]] \
a56a5e
+            && dracutmodules+=" $_moddep "
a56a5e
+        [[ " $add_dracutmodules " == *\ $_mod\ * ]] \
a56a5e
+            && [[ " $add_dracutmodules " != *\ $_moddep\ * ]] \
a56a5e
+            && add_dracutmodules+=" $_moddep "
a56a5e
+        [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] \
a56a5e
+            && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
a56a5e
+            && force_add_dracutmodules+=" $_moddep "
a56a5e
         # if a module we depend on fail, fail also
a56a5e
         if ! check_module $_moddep; then
a56a5e
             derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
a56a5e
@@ -1319,11 +1332,13 @@ for_each_module_dir() {
a56a5e
         [[ " $mods_to_load " == *\ $_mod\ * ]] && continue
a56a5e
 
a56a5e
         [[ " $force_add_dracutmodules " != *\ $_mod\ * ]] \
a56a5e
+            && [[ " $dracutmodules " != *\ $_mod\ * ]] \
a56a5e
             && [[ " $omit_dracutmodules " == *\ $_mod\ * ]] \
a56a5e
             && continue
a56a5e
 
a56a5e
         derror "dracut module '$_mod' cannot be found or installed."
a56a5e
         [[ " $force_add_dracutmodules " == *\ $_mod\ * ]] && exit 1
a56a5e
+        [[ " $dracutmodules " == *\ $_mod\ * ]] && exit 1
a56a5e
         [[ " $add_dracutmodules " == *\ $_mod\ * ]] && exit 1
a56a5e
     done
a56a5e
 }
a56a5e
diff --git a/dracut.sh b/dracut.sh
a56a5e
index eff096e..74c59a0 100755
a56a5e
--- a/dracut.sh
a56a5e
+++ b/dracut.sh
a56a5e
@@ -1152,7 +1152,9 @@ fi
a56a5e
 
a56a5e
 [[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system
a56a5e
 
a56a5e
-export initdir dracutbasedir dracutmodules \
a56a5e
+export initdir dracutbasedir \
a56a5e
+    dracutmodules force_add_dracutmodules add_dracutmodules omit_dracutmodules \
a56a5e
+    mods_to_load \
a56a5e
     fw_dir drivers_dir debug no_kernel kernel_only \
a56a5e
     omit_drivers mdadmconf lvmconf root_dev \
a56a5e
     use_fstab fstab_lines libdirs fscks nofscks ro_mnt \