Allow renaming of modules, #103 thanks to Sven.

This commit is contained in:
Roy Marples 2008-08-19 15:25:06 +00:00
parent cdace75539
commit 1f227d62bf
2 changed files with 19 additions and 3 deletions

View File

@ -5,6 +5,10 @@
#modules_2_6="tun" #modules_2_6="tun"
#modules="ohci1394" #modules="ohci1394"
# You can give modules a different name when they load - the new name
# will also be used to pick arguments below.
#modules="dummy:dummy1"
# Give the modules some arguments if needed, per version if necessary. # Give the modules some arguments if needed, per version if necessary.
#module_ieee1394_args="debug" #module_ieee1394_args="debug"
#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394" #module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394"

View File

@ -23,7 +23,7 @@ start()
x=${KV#*.*.} x=${KV#*.*.}
local KV_MICRO=${x%%-*} local KV_MICRO=${x%%-*}
local list= x= xx= y= args= cnt=0 local list= x= xx= y= args= mpargs= cnt=0 a=
for x in "${KV}" \ for x in "${KV}" \
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
${KV_MAJOR}.${KV_MINOR} \ ${KV_MAJOR}.${KV_MINOR} \
@ -34,17 +34,29 @@ start()
[ -z "${list}" ] && list=${modules} [ -z "${list}" ] && list=${modules}
for x in ${list}; do for x in ${list}; do
a=${x#*:}
if [ "${a}" = "${x}" ]; then
unset mpargs
ebegin "Loading module ${x}" ebegin "Loading module ${x}"
else
x=${x%%:*}
mpargs="-o ${a}"
ebegin "Loading module ${x} as ${a}"
fi
aa=$(shell_var "${a}")
xx=$(shell_var "${x}") xx=$(shell_var "${x}")
for y in "${KV}" \ for y in "${KV}" \
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
${KV_MAJOR}.${KV_MINOR} \ ${KV_MAJOR}.${KV_MINOR} \
; do ; do
eval args=\$module_${aa}_args_$(shell_var "${y}")
[ -n "${args}" ] && break
eval args=\$module_${xx}_args_$(shell_var "${y}") eval args=\$module_${xx}_args_$(shell_var "${y}")
[ -n "${args}" ] && break [ -n "${args}" ] && break
done done
[ -z "${args}" ] && eval args=\$module_${aa}_args
[ -z "${args}" ] && eval args=\$module_${xx}_args [ -z "${args}" ] && eval args=\$module_${xx}_args
eval modprobe -q "${x}" "${args}" eval modprobe -q "${mpargs}" "${x}" "${args}"
eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1)) eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1))
done done
einfo "Autoloaded ${cnt} module(s)" einfo "Autoloaded ${cnt} module(s)"