source: trunk/debathena/config/auto-update/debian/debathena-auto-update.preinst @ 25005

Revision 25005, 1.7 KB checked in by jdreed, 14 years ago (diff)
In auto-update: * Use the correct version notation when removing obsolete conffiles
Line 
1#!/bin/sh
2# preinst script for debathena-auto-update
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
17if dpkg-maintscript-helper supports rm_conffile 2> /dev/null; then
18    dpkg-maintscript-helper rm_conffile \
19        /etc/cron.d/debathena-auto-update 1.22.2 -- "$@"
20else
21    # From http://wiki.debian.org/DpkgConffileHandling
22    rm_conffile() {
23        local PKGNAME="$1"
24        local CONFFILE="$2"
25       
26        [ -e "$CONFFILE" ] || return 0
27       
28        local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
29        local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \
30            sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
31        if [ "$md5sum" != "$old_md5sum" ]; then
32            echo "Obsolete conffile $CONFFILE has been modified by you."
33            echo "Saving as $CONFFILE.dpkg-bak ..."
34            mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
35        else
36            echo "Removing obsolete conffile $CONFFILE ..."
37            mv -f "$CONFFILE" "$CONFFILE".dpkg-del
38        fi
39    }
40    case "$1" in
41        install|upgrade)
42            if dpkg --compare-versions "$2" le-nl 1.22.2; then
43                rm_conffile debathena-auto-update "/etc/cron.d/debathena-auto-update"
44            fi
45    esac
46fi
47
48case "$1" in
49    install|upgrade)
50    ;;
51
52    abort-upgrade)
53    ;;
54
55    *)
56        echo "preinst called with unknown argument \`$1'" >&2
57        exit 1
58    ;;
59esac
60
61# dh_installdeb will replace this with shell code automatically
62# generated by other debhelper scripts.
63
64#DEBHELPER#
65
66exit 0
Note: See TracBrowser for help on using the repository browser.