Bug 373808: init.d/modules skipped certain variable combinations

The version iteration code missed certain combinations:
KV=1.2.3.4
skips: 1.2.3, 1
KV=1.2.3
skips: 1

Simplify the code to use a loop and build the list of versions directly
instead of unique variables per version component.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2011-07-04 07:48:51 +00:00
parent 9076baa573
commit be990b308a
2 changed files with 21 additions and 17 deletions

View File

@ -1,8 +1,10 @@
# You can define a list modules for a specific kernel version,
# a released kernel version, a main kernel version or just a list.
# The most specific versioned variable will take precedence.
#modules_2_6_23_gentoo_r5="ieee1394 ohci1394"
#modules_2_6_23="tun ieee1394"
#modules_2_6="tun"
#modules_2="ipv6"
#modules="ohci1394"
# You can give modules a different name when they load - the new name
@ -10,10 +12,12 @@
#modules="dummy:dummy1"
# Give the modules some arguments if needed, per version if necessary.
# Again, the most specific versioned variable will take precedence.
#module_ieee1394_args="debug"
#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394"
#module_ieee1394_args_2_6_23="tun ieee1394"
#module_ieee1394_args_2_6="tun"
#module_ieee1394_args_2_6_23_gentoo_r5="debug2"
#module_ieee1394_args_2_6_23="debug3"
#module_ieee1394_args_2_6="debug4"
#module_ieee1394_args_2="debug5"
# You should consult your kernel documentation and configuration
# for a list of modules and their options.

View File

@ -16,18 +16,21 @@ start()
# support compiled in ...
[ ! -f /proc/modules ] && return 0
local KV=$(uname -r)
local KV_MAJOR=${KV%%.*}
local x=${KV#*.}
local KV_MINOR=${x%%.*}
x=${KV#*.*.}
local KV_MICRO=${x%%-*}
local KV x y kv_variant_list
KV=$(uname -r)
# full $KV
kv_variant_list="${KV}"
# remove any KV_EXTRA options to just get the full version
x=${KV%%-*}
# now slowly strip them
while [ -n "$x" ] && [ "$x" != "$y" ]; do
kv_variant_list="${kv_variant_list} $x"
y=$x
x=${x%.*}
done
local list= x= xx= y= args= mpargs= cnt=0 a=
for x in "$KV" \
$KV_MAJOR.$KV_MINOR.$KV_MICRO \
$KV_MAJOR.$KV_MINOR \
; do
for x in $kv_variant_list ; do
eval list=\$modules_$(shell_var "$x")
[ -n "$list" ] && break
done
@ -45,10 +48,7 @@ start()
fi
aa=$(shell_var "$a")
xx=$(shell_var "$x")
for y in "$KV" \
$KV_MAJOR.$KV_MINOR.$KV_MICRO \
$KV_MAJOR.$KV_MINOR \
; do
for y in $kv_variant_list ; do
eval args=\$module_${aa}_args_$(shell_var "$y")
[ -n "${args}" ] && break
eval args=\$module_${xx}_args_$(shell_var "$y")