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

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