5
rename_conffile_prepare () {
6
# syntax: rename_conffile_prepare old_name new_name official_md5sum ...
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.
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.
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.
21
#local conffile current_checksum
25
echo "$0: usage error: rename_conffile_prepare() called with wrong number of arguments (expected at least 3, got $#)." >&2
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.
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"
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