1 | #!/bin/sh |
---|
2 | # preinst script for debathena-reactivate |
---|
3 | # |
---|
4 | # see: dh_installdeb(1) |
---|
5 | |
---|
6 | set -e |
---|
7 | |
---|
8 | # summary of how this script can be called: |
---|
9 | # * <new-preinst> `install' |
---|
10 | # * <new-preinst> `install' <old-version> |
---|
11 | # * <new-preinst> `upgrade' <old-version> |
---|
12 | # * <old-preinst> `abort-upgrade' <new-version> |
---|
13 | # for details, see http://www.debian.org/doc/debian-policy/ or |
---|
14 | # the debian-policy package |
---|
15 | |
---|
16 | |
---|
17 | package=debathena-reactivate |
---|
18 | ours=.debathena |
---|
19 | theirs=.debathena-orig |
---|
20 | |
---|
21 | undivert_unlink_symlink() |
---|
22 | { |
---|
23 | file="$1" |
---|
24 | ourfile="$2" |
---|
25 | theirfile="$3" |
---|
26 | if [ ! -L "$file" ] || \ |
---|
27 | [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \ |
---|
28 | "$(readlink "$file")" != "$(basename "$theirfile")" ]; then |
---|
29 | echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2 |
---|
30 | else |
---|
31 | rm -f "$file" |
---|
32 | fi |
---|
33 | } |
---|
34 | |
---|
35 | undivert_unlink_divert() |
---|
36 | { |
---|
37 | file="$1" |
---|
38 | if [ ! -L "$file" ] && [ ! -e "$file" ]; then |
---|
39 | dpkg-divert --remove --rename --package "$package" "$file" |
---|
40 | else |
---|
41 | echo "Not removing diversion of $file by $package" >&2 |
---|
42 | fi |
---|
43 | } |
---|
44 | |
---|
45 | undivert_unlink() |
---|
46 | { |
---|
47 | prefix=$1 |
---|
48 | suffix=$2 |
---|
49 | |
---|
50 | file=$prefix$suffix |
---|
51 | ourfile=$prefix$ours$suffix |
---|
52 | theirfile=$prefix$theirs$suffix |
---|
53 | |
---|
54 | undivert_unlink_symlink "$file" "$ourfile" "$theirfile" |
---|
55 | undivert_unlink_divert "$file" "$package" |
---|
56 | } |
---|
57 | |
---|
58 | cleanup_old_diversion() { |
---|
59 | file="$1" |
---|
60 | if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then |
---|
61 | undivert_unlink "$file" |
---|
62 | fi |
---|
63 | } |
---|
64 | |
---|
65 | if dpkg-maintscript-helper supports rm_conffile 2> /dev/null; then |
---|
66 | dpkg-maintscript-helper rm_conffile /etc/athena/sudo-error 2.0.39 -- "$@" |
---|
67 | dpkg-maintscript-helper rm_conffile /etc/athena/su-error 2.0.39 -- "$@" |
---|
68 | else |
---|
69 | # From http://wiki.debian.org/DpkgConffileHandling |
---|
70 | rm_conffile() { |
---|
71 | local PKGNAME="$1" |
---|
72 | local CONFFILE="$2" |
---|
73 | |
---|
74 | [ -e "$CONFFILE" ] || return 0 |
---|
75 | |
---|
76 | local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')" |
---|
77 | local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \ |
---|
78 | sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")" |
---|
79 | if [ "$md5sum" != "$old_md5sum" ]; then |
---|
80 | echo "Obsolete conffile $CONFFILE has been modified by you." |
---|
81 | echo "Saving as $CONFFILE.dpkg-bak ..." |
---|
82 | mv -f "$CONFFILE" "$CONFFILE".dpkg-bak |
---|
83 | else |
---|
84 | echo "Removing obsolete conffile $CONFFILE ..." |
---|
85 | mv -f "$CONFFILE" "$CONFFILE".dpkg-del |
---|
86 | fi |
---|
87 | } |
---|
88 | case "$1" in |
---|
89 | install|upgrade) |
---|
90 | if dpkg --compare-versions "$2" le-nl 2.0.39; then |
---|
91 | rm_conffile debathena-reactivate "/etc/athena/sudo-error" |
---|
92 | rm_conffile debathena-reactivate "/etc/athena/su-error" |
---|
93 | fi |
---|
94 | esac |
---|
95 | fi |
---|
96 | |
---|
97 | case "$1" in |
---|
98 | install|upgrade) |
---|
99 | cleanup_old_diversion /etc/gdm/PreSession/Default |
---|
100 | cleanup_old_diversion /etc/gdm/PostSession/Default |
---|
101 | if dpkg --compare-versions "$2" lt-nl 2.0~ && \ |
---|
102 | [ -w /etc/schroot/schroot.conf ] && \ |
---|
103 | grep -q '###ATHENA-BEGIN###' /etc/schroot/schroot.conf; then |
---|
104 | sed -i -e '/###ATHENA-BEGIN###/,/###ATHENA-END###/d' /etc/schroot/schroot.conf |
---|
105 | fi |
---|
106 | ;; |
---|
107 | |
---|
108 | abort-upgrade) |
---|
109 | ;; |
---|
110 | |
---|
111 | *) |
---|
112 | echo "preinst called with unknown argument \`$1'" >&2 |
---|
113 | exit 1 |
---|
114 | ;; |
---|
115 | esac |
---|
116 | |
---|
117 | # dh_installdeb will replace this with shell code automatically |
---|
118 | # generated by other debhelper scripts. |
---|
119 | |
---|
120 | #DEBHELPER# |
---|
121 | |
---|
122 | exit 0 |
---|