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

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

bnc#895331

Fixed-by: Fabian Vogt <fvogt@suse.com>
---
 dracut-init.sh |    6 +++++-
 dracut.sh           |   12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)

Index: dracut-044/dracut-init.sh
===================================================================
--- dracut-044.orig/dracut-init.sh
+++ dracut-044/dracut-init.sh
@@ -944,6 +944,13 @@ for_each_kmod_dep() {
             $_func ${_modpath} || exit $?
         done
     )
+
+    for suse_mod_dep in ${suse_mod_deps["${_kmod%.ko*}"]}; do
+        _modpath=$(modinfo -k "$kernel" -F filename "$suse_mod_dep" 2> /dev/null)
+        [ -n "$_modpath" ] || continue
+        for_each_kmod_dep "$_func" "$_modpath" "$@"
+        $_func ${_modpath} || exit $?
+    done
 }
 
 dracut_kernel_post() {
@@ -1141,8 +1148,14 @@ instmods() {
                         --set-version $kernel ${_moddirname} $_mpargs
                     ((_ret+=$?))
                 else
-                    [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \
+                    if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] \
+			&& [ -n "${_mod%.ko*}" ]; then
                         echo ${_mod%.ko*} >> "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist"
+                        for suse_mod_dep in ${suse_mod_deps["${_mod%.ko*}"]}; do
+                            echo $suse_mod_dep >> "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist"
+                        done
+                    fi
+
                 fi
                 ;;
         esac
Index: dracut-044/dracut.sh
===================================================================
--- dracut-044.orig/dracut.sh
+++ dracut-044/dracut.sh
@@ -767,6 +767,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.
 if [[ $_no_compress_l = "cat" ]]; then
     compress="cat"