source: trunk/debathena/config/reactivate/debian/debathena-reactivate.preinst @ 24206

Revision 24206, 2.0 KB checked in by geofft, 15 years ago (diff)
Inspired by r24205, tweak the version check in various postinsts. The version check should take into account Debathena's ~distro version tags. Like the previous commit, this is for reference and does not necessitate a rebuild, if for no other reason than we've advanced well past the version in question.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2# preinst script for debathena-reactivate
3#
4# see: dh_installdeb(1)
5
6set -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
17package=debathena-reactivate
18ours=.debathena
19theirs=.debathena-orig
20
21undivert_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
35undivert_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
45undivert_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
58cleanup_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
66case "$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 2.0~; then
71            sed -i -e '/###ATHENA-BEGIN###/,/###ATHENA-END###/d' /etc/schroot/schroot.conf
72        fi
73    ;;
74
75    abort-upgrade)
76    ;;
77
78    *)
79        echo "preinst called with unknown argument \`$1'" >&2
80        exit 1
81    ;;
82esac
83
84# dh_installdeb will replace this with shell code automatically
85# generated by other debhelper scripts.
86
87#DEBHELPER#
88
89exit 0
Note: See TracBrowser for help on using the repository browser.