/[baselayout]/trunk/sbin/update-modules
Gentoo

Diff of /trunk/sbin/update-modules

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.27  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.20