#!/bin/sh
set -e
#DEBHELPER#

# Remove the conffile unless modified
rm_unchanged_conffile() {
    CONFFILE="$1"

    if [ -e "$CONFFILE" ]; then
	md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
	old_md5sum=`dpkg-query -W -f='${Conffiles} ' llgal | grep "$CONFFILE[[:space:]]" | cut -d' ' -f3`
	if [ "$md5sum" = "$old_md5sum" ]; then
	    rm -f "$CONFFILE"
	fi
    fi
}

# Prepare to move a conffile without triggering a dpkg question
prep_mv_conffile() {
    rm_unchanged_conffile "$1"
}

case "$1" in
install|upgrade)
    if dpkg --compare-versions "$2" le "0.11-1"; then
	prep_mv_conffile "/etc/llgalrc"
    else if dpkg --compare-versions "$2" le "0.13.10-1"; then
	rm_unchanged_conffile "/etc/llgal/llgalrc"
    fi fi
esac
