File: module-init-tools.postrm

package info (click to toggle)
module-init-tools 3.3-pre4-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 436 kB
  • ctags: 27
  • sloc: sh: 598; makefile: 219
file content (73 lines) | stat: -rw-r--r-- 1,691 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
#!/bin/sh -e

TO_DIVERT="depmod insmod update-modules modinfo"
TO_DIVERT_NOMAN="kallsyms ksyms"
TO_DIVERT_L="lsmod modprobe rmmod"

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
	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
}

remove_compat_symlinks() {
    SYMLINKS_TO_REMOVE="/bin/lsmod.modutils /sbin/ksyms /sbin/kallsyms"
    for file in $SYMLINKS_TO_REMOVE; do
	[ -L $file ] && rm $file
    done
    return 0
}

remove_etc_files() {
    # created by postinst
    # do not remove it if the modutils package is installed
    [ ! -f /etc/init.d/modutils ] && rm -f /etc/modules
    # /etc/modutils.conf is created by update-modutils
    rm -f /etc/modutils.conf /etc/modprobe.d/arch-aliases
    rmdir --ignore-fail-on-non-empty /etc/modprobe.d/
}

case "$1" in
    remove)
    remove_compat_symlinks

    for cmd in $TO_DIVERT; do
    	undivert_gen $cmd /sbin
    	undivert_man $cmd
    done
    for cmd in $TO_DIVERT_NOMAN; do
    	undivert_gen $cmd /sbin
    done
    for cmd in $TO_DIVERT_L; do
	rm -f /sbin/$cmd.modutils
    	undivert_gen $cmd /sbin Lmodutils
    	undivert_man $cmd
    done
    undivert_man modules 5
    ;;

    purge)
    remove_etc_files
    ;;

    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

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

#DEBHELPER#

exit 0