Blame 0029-fixed-instmods-return-code-and-set-pipefail-globally.patch

Harald Hoyer d1bf89
From 7abd426438984f9c3112fd409e9c019408fe85a4 Mon Sep 17 00:00:00 2001
Harald Hoyer d1bf89
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer d1bf89
Date: Mon, 18 Jun 2012 12:51:21 +0200
Harald Hoyer d1bf89
Subject: [PATCH] fixed instmods() return code and set pipefail globally
Harald Hoyer d1bf89
Harald Hoyer d1bf89
---
Harald Hoyer d1bf89
 dracut-functions.sh |   21 +++++++++------------
Harald Hoyer d1bf89
 dracut.sh           |    2 ++
Harald Hoyer d1bf89
 2 files changed, 11 insertions(+), 12 deletions(-)
Harald Hoyer d1bf89
Harald Hoyer d1bf89
diff --git a/dracut-functions.sh b/dracut-functions.sh
Harald Hoyer d1bf89
index 7439131..68c81f2 100755
Harald Hoyer d1bf89
--- a/dracut-functions.sh
Harald Hoyer d1bf89
+++ b/dracut-functions.sh
Harald Hoyer d1bf89
@@ -1028,11 +1028,11 @@ install_kmod_with_fw() {
Harald Hoyer d1bf89
         _kmod=${_kmod/-/_}
Harald Hoyer d1bf89
         if [[ "$_kmod" =~ $omit_drivers ]]; then
Harald Hoyer d1bf89
             dinfo "Omitting driver $_kmod"
Harald Hoyer d1bf89
-            return 1
Harald Hoyer d1bf89
+            return 0
Harald Hoyer d1bf89
         fi
Harald Hoyer d1bf89
         if [[ "${1##*/lib/modules/$kernel/}" =~ $omit_drivers ]]; then
Harald Hoyer d1bf89
             dinfo "Omitting driver $_kmod"
Harald Hoyer d1bf89
-            return 1
Harald Hoyer d1bf89
+            return 0
Harald Hoyer d1bf89
         fi
Harald Hoyer d1bf89
     fi
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
@@ -1073,16 +1073,13 @@ install_kmod_with_fw() {
Harald Hoyer d1bf89
 # rest of args = arguments to modprobe
Harald Hoyer d1bf89
 # _fderr specifies FD passed from surrounding scope
Harald Hoyer d1bf89
 for_each_kmod_dep() {
Harald Hoyer d1bf89
-    local _func=$1 _kmod=$2 _cmd _modpath _options _found=0
Harald Hoyer d1bf89
+    local _func=$1 _kmod=$2 _cmd _modpath _options
Harald Hoyer d1bf89
     shift 2
Harald Hoyer d1bf89
     modprobe "$@" --ignore-install --show-depends $_kmod 2>&${_fderr} | (
Harald Hoyer d1bf89
         while read _cmd _modpath _options; do
Harald Hoyer d1bf89
             [[ $_cmd = insmod ]] || continue
Harald Hoyer d1bf89
             $_func ${_modpath} || exit $?
Harald Hoyer d1bf89
-            _found=1
Harald Hoyer d1bf89
         done
Harald Hoyer d1bf89
-        [[ $_found -eq 0 ]] && exit 1
Harald Hoyer d1bf89
-        exit 0
Harald Hoyer d1bf89
     )
Harald Hoyer d1bf89
 }
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
@@ -1127,14 +1124,16 @@ instmods() {
Harald Hoyer d1bf89
                     ( [[ "$_mpargs" ]] && echo $_mpargs
Harald Hoyer d1bf89
                       cat "${srcmods}/modules.${_mod#=}" ) \
Harald Hoyer d1bf89
                     | instmods
Harald Hoyer d1bf89
+                    ((_ret+=$?))
Harald Hoyer d1bf89
                 else
Harald Hoyer d1bf89
                     ( [[ "$_mpargs" ]] && echo $_mpargs
Harald Hoyer d1bf89
-                      find "$srcmods" -path "*/${_mod#=}/*" -printf '%f\n' ) \
Harald Hoyer d1bf89
+                      find "$srcmods" -type f -path "*/${_mod#=}/*" -printf '%f\n' ) \
Harald Hoyer d1bf89
                     | instmods
Harald Hoyer d1bf89
+                    ((_ret+=$?))
Harald Hoyer d1bf89
                 fi
Harald Hoyer d1bf89
                 ;;
Harald Hoyer d1bf89
             --*) _mpargs+=" $_mod" ;;
Harald Hoyer d1bf89
-            i2o_scsi) return ;; # Do not load this diagnostic-only module
Harald Hoyer d1bf89
+            i2o_scsi) return 0;; # Do not load this diagnostic-only module
Harald Hoyer d1bf89
             *)
Harald Hoyer d1bf89
                 _mod=${_mod##*/}
Harald Hoyer d1bf89
                 # if we are already installed, skip this module and go on
Harald Hoyer d1bf89
@@ -1143,14 +1142,14 @@ instmods() {
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
                 if [[ $omit_drivers ]] && [[ "$1" =~ $omit_drivers ]]; then
Harald Hoyer d1bf89
                     dinfo "Omitting driver ${_mod##$srcmods}"
Harald Hoyer d1bf89
-                    return
Harald Hoyer d1bf89
+                    return 0
Harald Hoyer d1bf89
                 fi
Harald Hoyer d1bf89
                 # If we are building a host-specific initramfs and this
Harald Hoyer d1bf89
                 # module is not already loaded, move on to the next one.
Harald Hoyer d1bf89
                 [[ $hostonly ]] \
Harald Hoyer d1bf89
                     && ! [[ -d $(echo /sys/module/${_mod//-/_}|{ read a b; echo $a; }) ]] \
Harald Hoyer d1bf89
                     && ! [[ "$add_drivers" =~ " ${_mod} " ]] \
Harald Hoyer d1bf89
-                    && return
Harald Hoyer d1bf89
+                    && return 0
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
                 # We use '-d' option in modprobe only if modules prefix path
Harald Hoyer d1bf89
                 # differs from default '/'.  This allows us to use Dracut with
Harald Hoyer d1bf89
@@ -1193,12 +1192,10 @@ instmods() {
Harald Hoyer d1bf89
     }
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
     local _ret _filter_not_found='FATAL: Module .* not found.'
Harald Hoyer d1bf89
-    set -o pipefail
Harald Hoyer d1bf89
     # Capture all stderr from modprobe to _fderr. We could use {var}>...
Harald Hoyer d1bf89
     # redirections, but that would make dracut require bash4 at least.
Harald Hoyer d1bf89
     eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
Harald Hoyer d1bf89
     | while read line; do [[ "$line" =~ $_filter_not_found ]] || echo $line;done | derror
Harald Hoyer d1bf89
     _ret=$?
Harald Hoyer d1bf89
-    set +o pipefail
Harald Hoyer d1bf89
     return $_ret
Harald Hoyer d1bf89
 }
Harald Hoyer d1bf89
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer d1bf89
index 64cd75e..919f78e 100755
Harald Hoyer d1bf89
--- a/dracut.sh
Harald Hoyer d1bf89
+++ b/dracut.sh
Harald Hoyer d1bf89
@@ -26,6 +26,8 @@
Harald Hoyer d1bf89
 # store for logging
Harald Hoyer d1bf89
 dracut_args="$@"
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
+set -o pipefail
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
 usage() {
Harald Hoyer d1bf89
     [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
Harald Hoyer d1bf89
     if [[ -f $dracutbasedir/dracut-version.sh ]]; then