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 | |
---|
66 | case "$1" in |
---|
67 | install|upgrade) |
---|
68 | cleanup_old_diversion /etc/gdm/PreSession/Default |
---|
69 | cleanup_old_diversion /etc/gdm/PostSession/Default |
---|
70 | if dpkg --compare-versions "$2" lt-nl 2.0~ && \ |
---|
71 | [ -w /etc/schroot/schroot.conf ] && \ |
---|
72 | grep -q '###ATHENA-BEGIN###' /etc/schroot/schroot.conf; then |
---|
73 | sed -i -e '/###ATHENA-BEGIN###/,/###ATHENA-END###/d' /etc/schroot/schroot.conf |
---|
74 | fi |
---|
75 | ;; |
---|
76 | |
---|
77 | abort-upgrade) |
---|
78 | ;; |
---|
79 | |
---|
80 | *) |
---|
81 | echo "preinst called with unknown argument \`$1'" >&2 |
---|
82 | exit 1 |
---|
83 | ;; |
---|
84 | esac |
---|
85 | |
---|
86 | # dh_installdeb will replace this with shell code automatically |
---|
87 | # generated by other debhelper scripts. |
---|
88 | |
---|
89 | #DEBHELPER# |
---|
90 | |
---|
91 | exit 0 |
---|