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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#!/bin/sh -e
create_etc_modules() {
if [ ! -e /etc/modules ]; then
cat <<EOT > /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
EOT
chmod 644 /etc/modules
fi
}
archmodel() {
local arch=$(uname -m)
case $arch in
i[0-9]86) arch=i386 ;;
x86_64|amd64) arch=x86_64 ;;
lpia) arch=i386 ;;
arm*) arch=arm ;;
mips*) arch=mips ;;
# 64 bit variants of some architectures are treated like the 32 bit
s390x) arch=s390 ;;
parisc64) arch=parisc ;;
sparc64) arch=sparc ;;
# these architectures have variants with wildly different hardware
ppc64) arch=powerpc.generic ;;
ppc|powerpc)
if [ -f /proc/cpuinfo ]; then
model=$(sed -ne 's/^machine[[:space:]]*:[[:space:]]*//p' /proc/cpuinfo)
else
echo "/proc/cpuinfo does not exist, assuming generic powerpc system"
fi
case "$model" in
Amiga*) arch="powerpc.apus" ;;
Power*) arch="powerpc.pmac" ;;
*) arch="powerpc.generic" ;;
esac
;;
m68k)
if [ -f /proc/hardware ]; then
model=$(sed -ne 's/^Model:[[:space:]]*//p' /proc/hardware)
else
echo "/proc/hardware does not exist, assuming generic m68k system"
fi
case "$model" in
Atari*) arch="m68k.atari" ;;
Amiga*) arch="m68k.amiga" ;;
*) arch="m68k.generic" ;;
esac
;;
esac
echo $arch
}
create_arch_symlink() {
cd /etc/modprobe.d/
model=$(archmodel)
oldmodel=$model
while [ ! -f arch/$model ]; do
oldmodel=$model
model=${oldmodel%.*}.generic
[ "$model" = "$oldmodel" ] && break
echo "Configuration for $oldmodel not found, trying $model"
done
ARCHCONFFILE=arch/$model
if [ -f $ARCHCONFFILE ]; then
ln -sf $ARCHCONFFILE arch-aliases
else
echo "Architecture-specific config file not found"
fi
}
remove_compat_symlinks() {
for file in /bin/lsmod.modutils /sbin/ksyms /sbin/kallsyms; do
[ -L $file ] && rm $file
done
return 0
}
undivert_gen() {
DEXT=${3:-modutils}
dpkg-divert --remove --rename --package module-init-tools \
--divert $2/$1.$DEXT $2/$1 > /dev/null
}
undivert_man() {
DSECTION=${2:-8}
for locale in '' fr/; do
# When a diverted file is removed from a package, old version of dpkg
# forget to delete it. See #428650 for the gory details.
rm -f /usr/share/man/${locale}man$DSECTION/$1.modutils.$DSECTION.gz
dpkg-divert --remove --rename --package module-init-tools --divert \
/usr/share/man/${locale}man$DSECTION/$1.modutils.$DSECTION.gz \
/usr/share/man/${locale}man$DSECTION/$1.$DSECTION.gz > /dev/null
done
}
big_modutils_cleanup() {
remove_compat_symlinks
undivert_man modules 5
for cmd in depmod insmod update-modules modinfo; do
undivert_gen $cmd /sbin
undivert_man $cmd
done
for cmd in kallsyms ksyms; do
undivert_gen $cmd /sbin
done
for cmd in lsmod modprobe rmmod; do
rm -f /sbin/$cmd.modutils
undivert_gen $cmd /sbin Lmodutils
undivert_man $cmd
done
# modutils forgets to delete this file on purge
rm -f /etc/rcS.d/S20modutils
}
upgrade_quirks() {
[ "$2" ] || return 0
dpkg --compare-versions $2 lt 3.3-pre11-4 || return 0
# finally remove the diversions of modutils
big_modutils_cleanup
return 0
}
case "$1" in
configure)
create_etc_modules
create_arch_symlink
upgrade_quirks "$@"
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "$0 called with unknown argument '$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|