This more or less untested patch should hopefully help. Please note that there are more policy violations here, like not respecting removed config files. Shipping the config file and modifying it in place is probably a better idea then copying it from documentation/examples directory.
-- Regards, Andreas Henriksson
diff -uri up-imapproxy-1.2.6/debian/imapproxy.postinst up-imapproxy-1.2.6-fixed/debian/imapproxy.postinst --- up-imapproxy-1.2.6/debian/imapproxy.postinst 2009-01-02 19:49:35.000000000 +0100 +++ up-imapproxy-1.2.6-fixed/debian/imapproxy.postinst 2009-01-02 19:49:08.000000000 +0100 @@ -41,7 +41,7 @@ case "$1" in configure) if [ -e /usr/share/debconf/confmodule ]; then - + db_get imapproxy/imap-server || true server_hostname="$RET" @@ -50,6 +50,38 @@ listen_port=1143; fi + TMPFILE=`tempfile` + +/usr/bin/perl -- - $DESTFILE $TMPFILE << 'PCSCRIPT' +use warnings; +use strict; + +my $CFG; +my $TMP; + +open(CFG, '<', shift) or exit; +open(TMP, '>', shift) or die "imapproxy.postint: could not open: $!"; + +my %params = map { $_ => undef } split(/\s/, $ENV{'PARAMS'}); + +while (<CFG>) +{ + my ($key) = m/^#?(\w+)/; + if ( defined $key and exists $params{$key} ) { + my $v = $_; + $v =~ s/^#?(\w+) \(.*\)/\1/; + chomp($v); + print TMP "$key=$v\n"; + } +} + +PCSCRIPT + + if [ -f $TMPFILE ]; then + source $TMPFILE + rm -f $TMPFILE + fi + test -f $DESTFILE || cp /usr/share/doc/imapproxy/examples/$CFGFILE $DESTFILE; TMPFILE=`tempfile` mv $DESTFILE $TMPFILE