Permalink
Browse files

make fewer calls to modinfo

  • Loading branch information...
1 parent 21346da commit e8003824ea84c6bf5bedb865f45f199a06cc6570 @falconindy committed Jul 1, 2011
Showing with 22 additions and 22 deletions.
  1. +0 −4 geninit
  2. +22 −18 geninit.api
View
4 geninit
@@ -405,10 +405,6 @@ __build_preset() { # {{{
done
} # }}}
-__kmodinfo() { # {{{
- modinfo -b "$basedir" -0k $kernver "$@"
-} # }}}
-
__ldd() { # {{{
LD_TRACE_LOADED_OBJECTS=1 "$ld_so" "$@"
} # }}}
View
40 geninit.api
@@ -74,34 +74,38 @@ add_module() { # {{{
(( $# )) || return 1
- local -a firmware moddeps
- local modpath= module= mod= dep=
+ local -a deps
+ local modpath= module= mod= dep= field= value=
module=${1%%.*}
- read -rd '' modpath < <(__kmodinfo -n "$module" 2>/dev/null)
- if [[ -z "$modpath" ]]; then
+ while IFS=':= ' read -r -d '' field value; do
+ case "$field" in
+ filename)
+ modpath=$value
+ ;;
+ depends)
+ IFS=',' read -r -a deps <<< "$value"
+ for dep in "${deps[@]}"; do
+ add_module "$dep"
+ done
+ ;;
+ firmware)
+ if [[ -e "$basedir/lib/firmware/$value" ]]; then
+ __add_file "/lib/firmware/$value" "$basedir/lib/firmware/$value"
+ fi
+ ;;
+ esac
+ done < <(modinfo "$module" -b "$basedir" -0k $kernver 2>/dev/null)
+
+ if [[ -z $modpath ]]; then
error "Module not found: $module"
return 1
fi
__add_file "${modpath#$basedir}" "$modpath" 644
[[ $? = @(0|$EEXIST) ]] || return 1
- # grab firmware
- IFS=',' read -rd '' -a firmware < <(__kmodinfo -F firmware "$modpath")
- for fw in "${firmware[@]}"; do
- if [[ -e $basedir/lib/firmware/$fw ]]; then
- __add_file "/lib/firmware/$fw" "$basedir/lib/firmware/$fw" 644
- fi
- done
-
- # resolve deps
- IFS=',' read -rd '' -a moddeps < <(__kmodinfo -F depends "$modpath")
- for dep in "${moddeps[@]}"; do
- add_module "$dep"
- done
-
# add in any quirks
for mod in ${modquirks[$module]}; do
add_module "$mod"

0 comments on commit e800382

Please sign in to comment.