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