File: module-init-tools.postinst

package info (click to toggle)
module-init-tools 3.12-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,296 kB
  • ctags: 1,264
  • sloc: sh: 7,010; ansic: 6,584; makefile: 1,114
file content (86 lines) | stat: -rw-r--r-- 2,057 bytes parent folder | download
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
#!/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
}

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() {
  undivert_man modules 5

  # try hard to remove any old file left around (see #509575 for details)
  for cmd in depmod insmod update-modules modinfo; do
    rm -f /sbin/$cmd.modutils
    undivert_gen $cmd /sbin
    undivert_man $cmd
  done
  for cmd in kallsyms ksyms; do
    rm -f /sbin/$cmd.modutils
    undivert_gen $cmd /sbin
  done
  for cmd in lsmod modprobe rmmod; do
    rm -f /sbin/$cmd.modutils /sbin/$cmd.Lmodutils
    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

    upgrade_quirks "$@"
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
    echo "$0 called with unknown argument '$1'" >&2
    exit 1
    ;;
esac

#DEBHELPER#

exit 0