#!/bin/sh

set -e

rename_conffile_commit () {
# syntax: rename_conffile_commit filename
#
# Complete the renaming of a conffile "filename" that has been renamed.
#
# Call this function from a postinst script after having used
# rename_conffile_prepare() in the preinst.

	#local conffile

	# validate arguments
	if [ $# -ne 1 ]; then
		echo "$0: usage error: rename_conffile_commit() called with wrong number of arguments (expected 1, got $#)." >&2
		exit 2
	fi

	_conffile="$1"

	# If the temporary file created by rename_conffile_prepare() exists, remove
	# it.
	if [ -e "$_conffile.python-moinmoin.moved" ]; then
		rm "$_conffile.python-moinmoin.moved"
	fi
}

#DEBHELPER#

rename_conffile_commit /etc/moin/moinmaster.py

# Change this when some incompatible change is made that requires
# rebuilding all wikis.
firstcompat=1.9.0~

if [ "$1" = configure ] && dpkg --compare-versions "$2" lt "$firstcompat"; then
	moin-mass-migrate
fi
