3 # This is the update-modules script for Debian GNU/Linux.
4 # Copyright 1998-2001 Wichert Akkerman <wakkerma@debian.org>
5 # Licensed under the GNU GPL, version 2
8 MODCONFFILE=/etc/modules.conf
9 MODCONFTMPFILE="${MODCONFFILE}.$$"
10 MODULESFILE=/etc/modules
11 MODULESTMPFILE="${MODULESFILE}.$$"
13 ARCHDIR=/etc/modutils/arch
14 CPUDIR=/etc/modutils/cpu
15 HEADER="### This file is automatically generated by update-modules"
19 if [ "$1" = "force" ] ; then
25 # Reset the sorting order since we depend on it
31 dep=`grep '[[:space:]]*depfile' "${MODCONFFILE}" | tail -n 1 | sed -e 's/depfile=//' -e 's,/[^/]*$,,'`
32 if [ -z "$dep" ] ; then
33 dep="/lib/modules/`uname -r`"
40 local model=`uname -m`
42 i[0-9]86) model=i386; ;;
43 sun4u) model=sparc64; ;;
45 ppc) model=powerpc; ;;
53 if [ $arch = "m68k" ]; then
54 if [ -f /proc/hardware ]; then
55 model=`sed -ne 's/^Model:[[:space:]]*//p' /proc/hardware`
57 Atari*) model="atari"; ;;
58 Amiga*) model="amiga"; ;;
59 Macintosh*) model="mac"; ;;
60 Motorola*) model="MVME"; ;;
61 *) model="generic"; ;;
65 echo "/proc/hardware does not exist, assuming general m68k system"
68 elif [ $arch = "powerpc" ]; then
69 if [ -f /proc/cpuinfo ]; then
70 model=`sed -ne 's/^machine[[:space:]]*:[[:space:]]*//p' /proc/cpuinfo`
72 Amiga*) model="apus"; ;;
73 Power*) model="pmac"; ;;
74 *) model="generic"; ;;
78 echo "/proc/cpuinfo does not exist, assuming general powerpc system"
82 echo "${arch}${model}"
88 if [ -f "$cfgfile" ]; then
89 if ! sed -ne 1p "$cfgfile" | grep -q "^$HEADER" ; then
90 echo "Error: the current $cfgfile is not automatically generated." >&2
91 if [ -z "$force" ]; then
92 echo "Use \"update-modules force\" to force (re)generation."
95 echo "force specified, (re)generating file anyway."
105 # Please do not edit this file directly. If you want to change or add
106 # anything please take a look at the files in /etc/modutils and read
107 # the manpage for update-modules.
116 echo "### update-modules: start processing $src" >> "$tgt"
117 if [ -x "$src" ]; then
118 if ! "$src" >> "$tgt" ; then
119 echo "Error while executing $src, aborting" >&2
127 ### update-modules: end processing $cfg
133 checkoverwrite "$MODCONFFILE"
135 if [ 0 -ne "`id -u`" ]; then
136 echo "You have to be root to do this." >&2
143 while [ ! -f "${ARCHDIR}/${model}" ]; do
145 model=`echo $oldmodel | sed -e 's/\.[^.]\+//'`
146 if [ "$model" = "$oldmodel" ]; then
149 echo "Configuration for $oldmodel not found, trying $model"
152 CONF="${ARCHDIR}/${model}"
154 if [ ! -f "$CONF" ]; then
155 ## echo "Architecture-specific modutils configuration not found, using defaults"
156 CONF="${ARCHDIR}/generic"
159 [ -e "$MODCONFFILE" ] && cp -f "$MODCONFFILE" "${MODCONFFILE}.old"
161 createfile "$MODCONFTMPFILE"
162 createfile "$MODULESTMPFILE"
164 for cfg in /etc/modutils/* $CONF ; do
165 if [ -f "$cfg" ]; then # this check is necesarry to skip /etc/modutils/archs
166 if echo $cfg | grep -q '\.dpkg-[a-z]*\|~$' ; then
168 elif echo $cfg | grep -q '\.conf$' ; then
169 addfile "$cfg" "$MODCONFTMPFILE"
171 addfile "$cfg" "$MODULESTMPFILE"
177 if [ ! -f $MODULESFILE ]; then
181 mv "$MODCONFTMPFILE" "$MODCONFFILE"
182 mv "$MODULESTMPFILE" "$MODULESFILE"
184 if [ $first_time -eq 1 ]; then
185 /etc/init.d/modutils.sh || true
188 # We also call depmod here to stop insmod from complaining that modules.conf
189 # is more recent then modules.dep
191 if [ -d "`depdir`" -a -f /proc/modules ]