Blob Blame History Raw
From c9143a63fef0d6f2dfd7cc37b09fc68d744d900f Mon Sep 17 00:00:00 2001
From: Jon Ander Hernandez <jonan.h@gmail.com>
Date: Tue, 10 Apr 2012 15:14:38 +0200
Subject: [PATCH] Debian multiarch support

Another solution could be searching in directories found at
/etc/ld.so.conf.d/*.conf or adding a new parameter. Here is a patch
which adds a new --libdirs parameter, and also a new inst_libdir_file
function which will try to expand metacharacters on each lib
directory:

    inst_libdir_file "libdevmapper-event-lvm*.so"
---
 dracut-functions.sh                    |   28 ++++++++++++++++++++++++++++
 dracut.sh                              |   12 ++++++++++--
 modules.d/01fips/module-setup.sh       |   11 +++++------
 modules.d/40network/module-setup.sh    |    9 ++-------
 modules.d/80cms/module-setup.sh        |    4 +---
 modules.d/90dm/module-setup.sh         |    4 +---
 modules.d/90dmraid/module-setup.sh     |    4 +---
 modules.d/90lvm/module-setup.sh        |    4 +---
 modules.d/90multipath/module-setup.sh  |    6 ++++--
 modules.d/95nfs/module-setup.sh        |    6 +-----
 modules.d/95udev-rules/module-setup.sh |    4 +---
 modules.d/98syslog/module-setup.sh     |    8 +++-----
 12 files changed, 58 insertions(+), 42 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index 910f2d8..f5611dc 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -677,6 +677,34 @@ dracut_install() {
     done
 }
 
+
+# inst_libdir_file [-n <pattern>] <file> [<file>...]
+# Install a <file> located on a lib directory to the initramfs image
+# -n <pattern> install non-matching files
+inst_libdir_file() {
+    if [[ "$1" == "-n" ]]; then
+        local _pattern=$1
+        shift 2
+        for _dir in $libdirs; do
+            for _i in "$@"; do
+                for _f in "$_dir"/$_i; do
+                    [[ "$_i" =~ $_pattern ]] || continue
+                    [[ -e "$_i" ]] && dracut_install "$_i"
+                done
+            done
+        done
+    else
+        for _dir in $libdirs; do
+            for _i in "$@"; do
+                for _f in "$_dir"/$_i; do
+                    [[ -e "$_f" ]] && dracut_install "$_f"
+                done
+            done
+        done
+    fi
+}
+
+
 # install function decompressing the target and handling symlinks
 # $@ = list of compressed (gz or bz2) files or symlinks pointing to such files
 #
diff --git a/dracut.sh b/dracut.sh
index 0418c78..7f61143 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -221,6 +221,7 @@ while (($# > 0)); do
         --filesystems) push_arg filesystems_l        "$@" || shift;;
         -I|--install)  push_arg install_items_l      "$@" || shift;;
         --fwdir)       push_arg fw_dir_l             "$@" || shift;;
+        --libdirs)     push_arg libdirs_l            "$@" || shift;;
         --fscks)       push_arg fscks_l              "$@" || shift;;
         --add-fstab)   push_arg add_fstab_l          "$@" || shift;;
         --mount)       push_arg fstab_lines          "$@" || shift;;
@@ -400,6 +401,13 @@ if (( ${#fw_dir_l[@]} )); then
     done
 fi
 
+if (( ${#libdirs_l[@]} )); then
+    libdirs=''
+    while pop libdirs_l val; do
+        libdirs+="$val "
+    done
+fi
+
 [[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
 [[ ! $stdloglvl ]] && stdloglvl=4
 stdloglvl=$((stdloglvl + verbosity_mod_l))
@@ -505,14 +513,14 @@ ddebug "Executing $0 $dracut_args"
 
 # Detect lib paths
 [[ $libdir ]] || for libdir in /lib64 /lib; do
-    [[ -d $libdir ]] && break
+    [[ -d $libdir ]] && libdirs+=" $libdir" && break
 done || {
     dfatal 'No lib directory?!!!'
     exit 1
 }
 
 [[ $usrlibdir ]] || for usrlibdir in /usr/lib64 /usr/lib; do
-    [[ -d $usrlibdir ]] && break
+    [[ -d $usrlibdir ]] && libdirs+=" $usrlibdir" && break
 done || dwarn 'No usr/lib directory!'
 
 # This is kinda legacy -- eventually it should go away.
diff --git a/modules.d/01fips/module-setup.sh b/modules.d/01fips/module-setup.sh
index a490827..6bfe31e 100755
--- a/modules.d/01fips/module-setup.sh
+++ b/modules.d/01fips/module-setup.sh
@@ -34,12 +34,11 @@ install() {
 
     dracut_install sha512hmac rmmod insmod mount uname umount
 
-    for _dir in "$usrlibdir" "$libdir"; do
-        [[ -e $_dir/libsoftokn3.so ]] && \
-            dracut_install $_dir/libsoftokn3.so $_dir/libsoftokn3.chk \
-            $_dir/libfreebl3.so $_dir/libfreebl3.chk && \
-            break
-    done
+    inst_libdir_file libsoftokn3.so
+    inst_libdir_file libsoftokn3.so
+    inst_libdir_file libsoftokn3.chk
+    inst_libdir_file libfreebl3.so
+    inst_libdir_file libfreebl3.chk
 
     dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac
     if command -v prelink >/dev/null; then
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index c91f164..97fc5cb 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -89,12 +89,7 @@ install() {
 
     _arch=$(uname -m)
 
-    for _dir in "$usrlibdir/tls/$_arch" "$usrlibdir/tls" "$usrlibdir/$_arch" \
-        "$usrlibdir" "$libdir"; do
-        for _i in "$_dir"/libnss_dns.so.* "$_dir"/libnss_mdns4_minimal.so.*; do
-            [ -e "$_i" ] && dracut_install "$_i"
-        done
-    done
-
+    inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*"
+    inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*"
 }
 
diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh
index 5cb5413..5cce1b4 100755
--- a/modules.d/80cms/module-setup.sh
+++ b/modules.d/80cms/module-setup.sh
@@ -31,9 +31,7 @@ install() {
 	[[ -f $file ]] && inst $file
     done
 
-    for file in {"$usrlibdir","$libdir"}/gconv/*; do
-        [[ -f $file ]] && inst $file
-    done
+    inst_libdir_file "gconv/*"
 #inst /usr/lib/locale/locale-archive
 
     dracut_install cmsfs-fuse fusermount ulockmgr_server bash tr insmod rmmod cat
diff --git a/modules.d/90dm/module-setup.sh b/modules.d/90dm/module-setup.sh
index a55d591..bac854a 100755
--- a/modules.d/90dm/module-setup.sh
+++ b/modules.d/90dm/module-setup.sh
@@ -22,9 +22,7 @@ install() {
 
     type -P dmeventd >/dev/null && dracut_install dmeventd
 
-    for _i in {"$libdir","$usrlibdir"}/libdevmapper-event.so*; do
-        [ -e "$_i" ] && dracut_install "$_i"
-    done
+    inst_libdir_file "libdevmapper-event.so*"
 
     inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
     # Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules
diff --git a/modules.d/90dmraid/module-setup.sh b/modules.d/90dmraid/module-setup.sh
index 786cf25..0a8ed7f 100755
--- a/modules.d/90dmraid/module-setup.sh
+++ b/modules.d/90dmraid/module-setup.sh
@@ -62,9 +62,7 @@ install() {
         inst_rules 64-md-raid.rules
     fi
 
-    for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so*; do
-        [ -e "$_i" ] && dracut_install "$_i"
-    done
+    inst_libdir_file "libdmraid-events*.so*"
 
     inst_rules "$moddir/61-dmraid-imsm.rules"
     #inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
index cf46372..15c824d 100755
--- a/modules.d/90lvm/module-setup.sh
+++ b/modules.d/90lvm/module-setup.sh
@@ -60,8 +60,6 @@ install() {
     inst "$moddir/lvm_scan.sh" /sbin/lvm_scan
     inst_hook cmdline 30 "$moddir/parse-lvm.sh"
 
-    for _i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do
-        [ -e "$_i" ] && dracut_install "$_i"
-    done
+    inst_libdir_file "libdevmapper-event-lvm*.so"
 }
 
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
index b78c005..8a193c4 100755
--- a/modules.d/90multipath/module-setup.sh
+++ b/modules.d/90multipath/module-setup.sh
@@ -62,11 +62,13 @@ install() {
         /sbin/xdrgetprio \
         /etc/xdrdevices.conf \
         /etc/multipath.conf \
-        /etc/multipath/* \
-        "$libdir"/libmultipath* "$libdir"/multipath/*; do
+        /etc/multipath/*; do
         [ -e "$_f" ] && inst "$_f"
     done
 
+    inst_libdir_file "libmultipath*"
+    inst_libdir_file "multipath/*"
+
     inst_hook pre-trigger 02 "$moddir/multipathd.sh"
     inst_hook pre-pivot   02 "$moddir/multipathd-stop.sh"
     inst_rules 40-multipath.rules
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
index 7853783..455f52f 100755
--- a/modules.d/95nfs/module-setup.sh
+++ b/modules.d/95nfs/module-setup.sh
@@ -54,11 +54,7 @@ install() {
     _nsslibs=${_nsslibs#|}
     _nsslibs=${_nsslibs%|}
 
-    for _i in {/usr,}$libdir/libnss*.so; do
-        [[ -e $_i ]] || continue
-        [[ "$_i" =~ $_nsslibs ]] || continue
-        dracut_install "$_i"
-    done
+    inst_libdir_file -n "$_nsslibs" "libnss*.so"
 
     inst_hook cmdline 90 "$moddir/parse-nfsroot.sh"
     inst_hook pre-udev 99 "$moddir/nfs-start-rpc.sh"
diff --git a/modules.d/95udev-rules/module-setup.sh b/modules.d/95udev-rules/module-setup.sh
index 5f8bae8..1c71336 100755
--- a/modules.d/95udev-rules/module-setup.sh
+++ b/modules.d/95udev-rules/module-setup.sh
@@ -74,8 +74,6 @@ install() {
     [ -f /etc/arch-release ] && \
         inst "$moddir/load-modules.sh" /lib/udev/load-modules.sh
 
-    for _i in {"$libdir","$usrlibdir"}/libnss_files*; do
-        [ -e "$_i" ] && dracut_install "$_i"
-    done
+    inst_libdir_file "libnss_files*"
 }
 
diff --git a/modules.d/98syslog/module-setup.sh b/modules.d/98syslog/module-setup.sh
index 5579c5a..bd6e92c 100755
--- a/modules.d/98syslog/module-setup.sh
+++ b/modules.d/98syslog/module-setup.sh
@@ -16,11 +16,9 @@ install() {
     local _installs
     if type -P rsyslogd >/dev/null; then
         _installs="rsyslogd"
-        for _i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \
-            {"$libdir","$usrlibdir"}/rsyslog/imklog.so \
-            {"$libdir","$usrlibdir"}/rsyslog/imuxsock.so ; do
-            [ -e "$_i" ] && _installs="$_installs $_i"
-        done
+        inst_libdir_file rsyslog/lmnet.so
+        inst_libdir_file rsyslog/imklog.so
+        inst_libdir_file rsyslog/imuxsock.so
     elif type -P syslogd >/dev/null; then
         _installs="syslogd"
     elif type -P syslog-ng >/dev/null; then