1 | #!/bin/sh |
---|
2 | # postinst script for debathena-kerberos-config |
---|
3 | # |
---|
4 | # see: dh_installdeb(1) |
---|
5 | |
---|
6 | set -e |
---|
7 | |
---|
8 | # summary of how this script can be called: |
---|
9 | # * <postinst> `configure' <most-recently-configured-version> |
---|
10 | # * <old-postinst> `abort-upgrade' <new version> |
---|
11 | # * <conflictor's-postinst> `abort-remove' `in-favour' <package> |
---|
12 | # <new-version> |
---|
13 | # * <postinst> `abort-remove' |
---|
14 | # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' |
---|
15 | # <failed-install-package> <version> `removing' |
---|
16 | # <conflicting-package> <version> |
---|
17 | # for details, see http://www.debian.org/doc/debian-policy/ or |
---|
18 | # the debian-policy package |
---|
19 | |
---|
20 | # dh_installdeb will replace this with shell code automatically |
---|
21 | # generated by other debhelper scripts. |
---|
22 | |
---|
23 | #DEBHELPER# |
---|
24 | |
---|
25 | package=debathena-kerberos-config |
---|
26 | ours=.debathena |
---|
27 | theirs=.debathena-orig |
---|
28 | |
---|
29 | undivert_unlink_symlink() |
---|
30 | { |
---|
31 | file="$1" |
---|
32 | ourfile="$2" |
---|
33 | theirfile="$3" |
---|
34 | if [ ! -L "$file" ] || \ |
---|
35 | [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \ |
---|
36 | "$(readlink "$file")" != "$(basename "$theirfile")" ]; then |
---|
37 | echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2 |
---|
38 | else |
---|
39 | rm -f "$file" |
---|
40 | fi |
---|
41 | } |
---|
42 | |
---|
43 | undivert_unlink_divert() |
---|
44 | { |
---|
45 | file="$1" |
---|
46 | if [ ! -L "$file" ] && [ ! -e "$file" ]; then |
---|
47 | dpkg-divert --remove --rename --package "$package" "$file" |
---|
48 | else |
---|
49 | echo "Not removing diversion of $file by $package" >&2 |
---|
50 | fi |
---|
51 | } |
---|
52 | |
---|
53 | undivert_unlink() |
---|
54 | { |
---|
55 | prefix=$1 |
---|
56 | suffix=$2 |
---|
57 | |
---|
58 | file=$prefix$suffix |
---|
59 | ourfile=$prefix$ours$suffix |
---|
60 | theirfile=$prefix$theirs$suffix |
---|
61 | |
---|
62 | undivert_unlink_symlink "$file" "$ourfile" "$theirfile" |
---|
63 | undivert_unlink_divert "$file" "$package" |
---|
64 | } |
---|
65 | |
---|
66 | cleanup_old_diversion() { |
---|
67 | file="$1" |
---|
68 | if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then |
---|
69 | undivert_unlink "$file" |
---|
70 | fi |
---|
71 | } |
---|
72 | |
---|
73 | cleanup_old_removal() { |
---|
74 | file="$1" |
---|
75 | removedfile="$2" |
---|
76 | if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${removedfile} by ${package}"; then |
---|
77 | undivert_unlink_divert "$file" |
---|
78 | fi |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | case "$1" in |
---|
83 | configure) |
---|
84 | if dpkg-query -f '${Conffiles}\n' -W debathena-kerberos-config | grep '/etc/apparmor.d/usr.sbin.cups.debathena' | awk '{ print $2" "$1 }' | md5sum -c >/dev/null 2>&1; then |
---|
85 | rm -f /etc/apparmor.d/usr.sbin.cups.debathena |
---|
86 | fi |
---|
87 | |
---|
88 | # The cupsd config can be removed, but not diverted; the |
---|
89 | # kerberosclient config can be diverted but not removed. Since |
---|
90 | # both files have been both at various points in the package's |
---|
91 | # history, if one of them is wrong, fix it. |
---|
92 | cleanup_old_removal /etc/apparmor.d/usr.sbin.cupsd /usr/share/debathena-kerberos-config/etc++apparmor.d++usr.sbin.cupsd |
---|
93 | cleanup_old_diversion /etc/apparmor.d/usr.sbin.cupsd |
---|
94 | cleanup_old_removal /etc/apparmor.d/abstractions/kerberosclient /usr/share/debathena-kerberos-config/etc++apparmor.d++abstractions++kerberosclient |
---|
95 | cleanup_old_diversion /etc/apparmor.d/abstractions/kerberosclient |
---|
96 | |
---|
97 | # Handle upgrading from a system with krb4 to one without |
---|
98 | krb5_version="$(dpkg-query -W -f '${Version}' krb5-user)" |
---|
99 | if dpkg --compare-versions "$krb5_version" ge "1.7~"; then |
---|
100 | cleanup_old_diversion /etc/krb.conf |
---|
101 | cleanup_old_diversion /etc/krb.realms |
---|
102 | fi |
---|
103 | |
---|
104 | if dpkg --compare-versions "$2" lt-nl "1.10~" && \ |
---|
105 | hash apparmor_status 2>/dev/null && \ |
---|
106 | apparmor_status --enabled; then |
---|
107 | if hash invoke-rc.d 2>/dev/null; then |
---|
108 | invoke-rc.d apparmor reload |
---|
109 | else |
---|
110 | /etc/init.d/apparmor reload |
---|
111 | fi |
---|
112 | fi |
---|
113 | ;; |
---|
114 | |
---|
115 | abort-upgrade|abort-remove|abort-deconfigure) |
---|
116 | ;; |
---|
117 | |
---|
118 | *) |
---|
119 | echo "postinst called with unknown argument \`$1'" >&2 |
---|
120 | exit 1 |
---|
121 | ;; |
---|
122 | esac |
---|
123 | |
---|
124 | exit 0 |
---|
125 | |
---|
126 | |
---|