File: module-init-tools.preinst

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 (103 lines) | stat: -rw-r--r-- 2,414 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh -e

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
}

rm_conffile_md5() {
  local file=$1
  local md5=$2
  if [ -f $file ] && echo "$md5  $file" | md5sum -c 2> /dev/null; then
    rm $file
  fi
}

rm_conffile() {
  mv_conffile "$1" "$1.dpkg-bak"
}

mv_conffile() {
  local package='module-init-tools'
  local name="$1"
  local newname="$2"

  [ -e "$name" ] || return 0

  local md5="$(md5sum $name | sed -e 's/ .*//')"
  oldmd5="$(dpkg-query -W -f='${Conffiles}' $package | \
    sed -n -e "\' $name ' { s/ obsolete$//; s/.* //; p }")"

  if [ "$md5" = "$oldmd5" ]; then
    rm -f "$name"
  else
    mv "$name" "$newname"
  fi
}

upgrade_quirks() {
  # $2 is non-empty when installing from the "config-files" state
  [ "$2" ] || return 0

  if dpkg --compare-versions $2 lt 3.10-3; then
  if dpkg --compare-versions $2 lt 3.1-pre11-1; then
  if dpkg --compare-versions $2 lt 3.2-pre9-4; then
  if dpkg --compare-versions $2 lt 3.1-pre2-1; then

  echo 'Upgrading from packages older than 3.1-pre2-1 is not supported.'
  echo 'Please purge module-init-tools before installing this package.'
  exit 1

  fi # lt 3.1-pre2-1

  rm -f /usr/share/man/man8/kallsyms.8.gz /usr/share/man/man8/ksyms.8.gz
  for cmd in kallsyms ksyms; do
    undivert_man $cmd
  done

  fi # lt 3.2-pre9-4

  # remove an obsolete conffile, which was replaced by .../x86_64
  if [ "$(dpkg --print-architecture)" = amd64 ]; then
    rm_conffile_md5 /etc/modprobe.d/arch/i386 688ef8c36b20113c46ec631e6c9effd4
  fi

  fi # lt 3.1-pre11-1

  for file in i386 x86_64 mips s390 parisc sparc powerpc.apus \
       powerpc.generic powerpc.pmac m68k.amiga m68k.atari m68k.generic; do
    rm_conffile /etc/modprobe.d/arch/$file
  done
  rmdir /etc/modprobe.d/arch/ 2> /dev/null || true
  if [ -L /etc/modprobe.d/arch-aliases \
      -a ! -e /etc/modprobe.d/arch-aliases ]; then
    rm /etc/modprobe.d/arch-aliases
  fi

  mv_conffile /etc/modprobe.d/aliases /etc/modprobe.d/aliases.conf

  fi # lt 3.10-3
}

case "$1" in
    install|upgrade)

    upgrade_quirks "$@"
    ;;

    abort-upgrade)
    ;;

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

#DEBHELPER#

exit 0