#!/bin/sh -e

set -e

# Source debconf library
. /usr/share/debconf/confmodule

db_input medium apt-listchanges/frontend || true
db_input low apt-listchanges/save-seen || true
db_input low apt-listchanges/email-address || true

if [ "$1" = "configure" ]; then
    if [ -n "$2" ] && dpkg --compare-versions "$2" le 2.51; then
        # Preserve behaviour for users upgrading from older versions
        db_set apt-listchanges/which both
    fi
fi

db_input low apt-listchanges/which || true
db_go

db_get apt-listchanges/frontend
case "$RET" in
    none|mail)
        db_set apt-listchanges/confirm "false"
        ;;
    *)
        db_input low apt-listchanges/confirm || true
        db_go
        ;;
esac

# Clean up questions we used to ask
# 2.3 and earlier
db_unregister apt-listchanges/apt-hook-p || true

exit 0
