1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#! /bin/sh
#
# This is the update-modules script for Debian GNU/Linux.
# Written by Wichert Akkerman <wakkerma@debian.org>
# Copyright (C) 1998, 1999 Software in the Public Interest
#
CFGFILE=/etc/modules.conf
TMPFILE="${CFGFILE}.$!"
ARCHDIR=/etc/modutils/arch
HEADER="### This file is automatically generated by update-modules"
set -e
depdir()
{
dep=`grep '[[:space:]]*depfile' ${CFGFILE} | tail -n 1 | sed -e 's/depfile=//' -e 's,/[^/]*$,,'`
if [ -z "$dep" ]
then
dep=/lib/modules/`uname -r`
fi
echo $dep
}
arch() {
local model=`uname -m`
case $model in
i[0-9]86) model=i386; ;;
sun4u) model=sparc64; ;;
arm*) model=arm; ;;
ppc) model=powerpc; ;;
esac
echo $model
}
archmodel() {
local arch=`arch`
local model=""
if [ $arch = "m68k" ]; then
if [ -f /proc/hardware ]; then
model=`cat /proc/hardware | sed -ne 's/^Model:[[:space:]]*//p'`
case $model in
Atari*) model="atari"; ;;
Amiga*) model="amiga"; ;;
Macintosh*) model="mac"; ;;
Motorola*) model="MVME"; ;;
*) model="generic"; ;;
esac
model=".${model}"
else
echo "/proc/hardware does not exist, assuming general m68k system"
fi
fi
echo "${arch}${model}"
}
if [ -f $CFGFILE ]; then
if ! sed -ne 1p $CFGFILE | grep -q "^$HEADER" ; then
echo "Error: the current $CFGFILE is not automatically generated."
if [ "$1" != "force" ]; then
echo "Use \"update-modules force\" to force (re)generation."
exit 1
else
echo "force specified, (re)generating file anyway."
fi
fi
fi
if [ 0 -ne "`id -u`" ]; then
echo "You have to be root to do this."
exit 2
fi
model=`archmodel`
oldmodel=$model
while [ ! -f ${ARCHDIR}/${model} ]; do
oldmodel=$model
model=`echo $oldmodel | sed -e 's/\.[^.]\+//'`
if [ "$model" = "$oldmodel" ]; then
break
fi
echo "Configuration for $oldmodel not found, trying $model"
done
CONF="${ARCHDIR}/${model}"
if [ ! -f $CONF ]; then
echo "Architecture-specific modutils configuration not found, using defaults"
CONF="${ARCHDIR}/generic"
fi
if [ -e $CFGFILE ]; then
cp -f $CFGFILE ${CFGFILE}.old
fi
echo $HEADER > $TMPFILE
cat <<EOF >> $TMPFILE
#
# Please do not edit this file directly. If you want to change or add
# anything please take a look at the files in /etc/modutils and read
# the manpage for update-modules.
#
EOF
for cfg in /etc/modutils/* $CONF ; do
if [ -f $cfg ]; then # this check is necesarry to skip /etc/modutils/archs
if ! echo $cfg | grep -q '\(\.dpkg-[a-z]*\|~\)$' ; then
echo "### update-modules: start processing $cfg" >> $TMPFILE
if [ -x $cfg ]; then
$cfg >> $TMPFILE
else
cat $cfg >> $TMPFILE
fi
echo >> $TMPFILE
echo "### update-modules: end processing $cfg" >> $TMPFILE
echo >> $TMPFILE
fi
fi
done
mv $TMPFILE $CFGFILE
# We also call depmod here to stop insmod from complaining that modules.conf
# is more recent then modules.dep
#
if [ -d `depdir` -a -f /proc/modules ]
then
depmod -a
fi
|