#!/bin/sh

set -e

export DEBCONF_DEBUG=developer

# debconf fails when DEBCONF_PACKAGE is set, but without it the
# template entry in /var/cache/dpkg/config.dat has an unkown Owner,
# which means that we can't remove it when apt-listbugs is purged.
#export DEBCONF_PACKAGE="apt-listbugs"

# other values: text, dialog, kde, web (the two latter hang for me)
#export DEBIAN_FRONTEND=gnome

# source debconf libary.
. /usr/share/debconf/confmodule

# to be constructed on the fly, based on apt & bts input
PACKAGES="package0 #abcdef (short description), package1 #abcdef (short description)"

# ask debconf to *always* show this question. without this, the
# question will be shown only the first time, even for different
# value sof $PACKAGES
db_fset apt-listbugs/select-packages seen false

# populate the template question with the list of RC-buggy packages
# and associated bug numbers
db_subst apt-listbugs/select-packages packages "$PACKAGES"

# priority has to be high-enough, otherwise priority overrides the "seen: false" false
db_input critical apt-listbugs/select-packages || true
db_go || true

db_get apt-listbugs/select-packages || true
PACKAGES_TO_UPGRADE="$RET"

# Close all fd's
db_stop

exit 0
