~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to debian/preinst

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
rename_conffile_prepare () {
 
6
# syntax: rename_conffile_prepare old_name new_name official_md5sum ...
 
7
#
 
8
# Check a conffile "old_name" against a list of canonical MD5 checksums.  If
 
9
# the file's current MD5 checksum matches one of the "official_md5sum"
 
10
# operands provided, then rename the conffile to "new_file" and create a
 
11
# flag file indicating that we have done so.
 
12
#
 
13
# We leave the flag file around until the package is configured so that we
 
14
# can roll this operation back if package installation fails.
 
15
#
 
16
# Call this function from a preinst script in the event $1 is "upgrade" or
 
17
# "install" and verify $2 to ensure the package is being upgraded from a
 
18
# version (or installed over a version removed-but-not-purged) prior to the
 
19
# one in which the conffile was renamed.
 
20
 
 
21
        #local conffile current_checksum
 
22
 
 
23
        # Validate arguments.
 
24
        if [ $# -lt 3 ]; then
 
25
                echo "$0: usage error: rename_conffile_prepare() called with wrong number of arguments (expected at least 3, got $#)." >&2
 
26
                exit 2
 
27
        fi
 
28
 
 
29
        _old_conffile="$1"
 
30
        shift
 
31
 
 
32
        _new_conffile="$1"
 
33
        shift
 
34
 
 
35
        # We only have something to do if the _old_conffile exists and the
 
36
        # _new_conffile doesn't.
 
37
        if [ -e "$_old_conffile" ] && ! [ -e "$_new_conffile" ]; then
 
38
                # Calculate _old_conffile's checksum.
 
39
                _current_checksum=$(md5sum < "$_old_conffile" | sed 's/[[:space:]].*//')
 
40
                # Compare it to each supplied checksum.
 
41
                while [ -n "$1" ]; do
 
42
 
 
43
                        _old_checksum="$1"
 
44
                        shift
 
45
 
 
46
                        _old_pkgver="$1"
 
47
                        shift
 
48
 
 
49
                        if [ "$_current_checksum" = "$_old_checksum" ]; then
 
50
                                # We found a match; rename the conffile and stop looking.
 
51
                                echo "Found old conffile (version $_old_pkgver): Renaming from $_old_conffile to $_new_conffile." >&2
 
52
                                mv "$_old_conffile" "$_new_conffile" \
 
53
                                        > "$_old_conffile.python-moinmoin.moved"
 
54
                                break
 
55
                        fi
 
56
                done
 
57
        fi
 
58
}
 
59
 
 
60
#DEBHELPER#
 
61
 
 
62
if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then
 
63
        if dpkg --compare-versions "$2" lt "1.5.2"; then
 
64
                rename_conffile_prepare \
 
65
                        /etc/moin/moinmaster.py /etc/moin/mywiki.py \
 
66
                        0691ca2ee1a91d81e6010f92e5eb4e62 1.3.4-3 \
 
67
                        53921d5995c4f8f7ee2dc75868837248 'unknown' \
 
68
                        342a585c1a0255e8cbfaca607d068276 1.4.99+1.5.0rc1-1
 
69
        fi
 
70
fi