instmods: factor out egrep of "FATAL: Module .* not found"

master
John Reiser 2011-08-29 16:03:35 -07:00 committed by Harald Hoyer
parent 0024702fe7
commit f9708da223
1 changed files with 19 additions and 15 deletions

View File

@ -820,7 +820,7 @@ install_kmod_with_fw() {
for_each_kmod_dep() { for_each_kmod_dep() {
local _func=$1 _kmod=$2 _cmd _modpath _options _found=0 local _func=$1 _kmod=$2 _cmd _modpath _options _found=0
shift 2 shift 2
modprobe "$@" --ignore-install --show-depends $_kmod 2>"$initdir/modprobe.err" | ( modprobe "$@" --ignore-install --show-depends $_kmod 2>&$modprobe_stderr | (
while read _cmd _modpath _options; do while read _cmd _modpath _options; do
[[ $_cmd = insmod ]] || continue [[ $_cmd = insmod ]] || continue
$_func ${_modpath} || exit $? $_func ${_modpath} || exit $?
@ -829,9 +829,6 @@ for_each_kmod_dep() {
[[ $_found -eq 0 ]] && exit 1 [[ $_found -eq 0 ]] && exit 1
exit 0 exit 0
) )
egrep -v 'FATAL: Module .* not found.' "$initdir/modprobe.err" | derror
rm -f "$initdir/modprobe.err"
return $?
} }


# filter kernel modules to install certain modules that meet specific # filter kernel modules to install certain modules that meet specific
@ -934,16 +931,23 @@ instmods() {
esac esac
} }


local _mpargs _ret=0 function instmods_1() {
if (($# == 0)); then # filenames from stdin local _ret=0 _mod _mpargs
local _mod if (($# == 0)); then # filenames from stdin
while read _mod; do while read _mod; do
inst1mod "${_mod%.ko*}" inst1mod "${_mod%.ko*}"
done
fi
while (($# > 0)); do # filenames as arguments
inst1mod ${1%.ko*}
shift
done done
fi return $_ret
while (($# > 0)); do # filenames as args }
inst1mod ${1%.ko*}
shift # Capture all stderr from modprobe onto a new fd $modprobe_stderr,
done # and pipe it into egrep. See REDIRECTION in bash manpage.
return $_ret ( instmods_1 "$@" ) {modprobe_stderr}>&1 \
| egrep -v 'FATAL: Module .* not found.' | derror
return $?
} }