File 0158-Add-SUSE-kernel-module-dependencies-in-etc-modprobe..patch of Package dracut.892

From 75faba5ea84fe53df7d3ca3e4f4b6cf390c824bb Mon Sep 17 00:00:00 2001
From: Jan Loseser <jloeser@suse.de>
Date: Thu, 11 Sep 2014 15:20:23 +0200
Subject: Add SUSE kernel module dependencies (in /etc/modprobe.d/*)

bnc#895331

CC: Jan Loeser <jloeser@suse.de>
---
 dracut-functions.sh |    6 +++++-
 dracut.sh           |   12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index 208c295..7d81f65 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -1706,8 +1706,12 @@ instmods() {
                         --set-version $kernel ${_moddirname} $_mpargs
                     ((_ret+=$?))
                 else
-                    [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \
+                    if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [ -n "$_mod" ]; then
                         echo $_mod >> "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist"
+                        for suse_mod_dep in ${suse_mod_deps["$_mod"]}; do
+                            echo $suse_mod_dep >> "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist"
+                        done
+                    fi
                 fi
                 ;;
         esac
diff --git a/dracut.sh b/dracut.sh
index 411a972..c301138 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -823,6 +823,18 @@ if [[ -n "$logfile" ]];then
     fi
 fi
 
+# parse SUSE kernel module dependencies
+# Kernel modules using "load_module" function may not show up in modprobe
+# depencies. While this is the case there is a workaround in SUSE which adds:
+# # SUSE_INITRD: module_name REQUIRES module1 module2 ...
+# to /etc/modprobe.d/*.conf
+declare -A suse_mod_deps
+while read -r line; do
+    _suse_mod="${line##*SUSE INITRD: }"
+    _suse_mod="${_suse_mod%% REQUIRES*}"
+    suse_mod_deps["$_suse_mod"]="${suse_mod_deps["$_suse_mod"]} ${line##*REQUIRES }"
+done <<< "$(grep -h "^# SUSE INITRD: " /etc/modprobe.d/[0-9][0-9]*.conf)"
+
 # handle compression options.
 [[ $compress ]] || compress="gzip"
 case $compress in
-- 
1.7.6.1