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

Revision 25727, 3.2 KB checked in by jdreed, 12 years ago (diff)
In reactivate: * Cleanup from r24057, where we had to special-case quickstations via su-error and sudo-error, and cleanup those conffiles in a Debian-esque way * Add a trailing NUL to the end of sudo-warning to workaround a bug in sudo 1.8.3p1 (fixed upstream, but not in Precise)
  • Property svn:executable set to *
RevLine 
[24028]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       
[25727]65if 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 -- "$@"
68else
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
95fi
[24028]96
97case "$1" in
98    install|upgrade)
99        cleanup_old_diversion /etc/gdm/PreSession/Default
100        cleanup_old_diversion /etc/gdm/PostSession/Default
[24350]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
[24150]104            sed -i -e '/###ATHENA-BEGIN###/,/###ATHENA-END###/d' /etc/schroot/schroot.conf
105        fi
[24028]106    ;;
107
108    abort-upgrade)
109    ;;
110
111    *)
112        echo "preinst called with unknown argument \`$1'" >&2
113        exit 1
114    ;;
115esac
116
117# dh_installdeb will replace this with shell code automatically
118# generated by other debhelper scripts.
119
120#DEBHELPER#
121
122exit 0
Note: See TracBrowser for help on using the repository browser.