On Tue, Jan 20, 2009 at 11:02:42AM +0200, Niko Tyni wrote:
> The attached new patch seems to work for me, but please verify. It uses ucf
> for config file handling, which simplifies things IMO.
I'm attaching an improved version that handles listen_port better.
I do intend to NMU this when I've had some sleep and can find the time
for final tests. If somebody wants to take over, be my guest.
I'm a bit surprised the package is still a candidate for lenny at this point.
--
Niko Tyni [email protected]
diff -u up-imapproxy-1.2.6/debian/control up-imapproxy-1.2.6/debian/control
--- up-imapproxy-1.2.6/debian/control
+++ up-imapproxy-1.2.6/debian/control
@@ -9,7 +9,7 @@
Package: imapproxy
Architecture: any
-Depends: lsb-base, ${shlibs:Depends}, ${misc:Depends}
+Depends: lsb-base, ${shlibs:Depends}, ${misc:Depends}, ucf (>= 0.28)
Description: IMAP protocol proxy
UP-ImapProxy proxies IMAP transactions between an IMAP client and an IMAP
server. The general idea is that the client should never know that it is
diff -u up-imapproxy-1.2.6/debian/rules up-imapproxy-1.2.6/debian/rules
--- up-imapproxy-1.2.6/debian/rules
+++ up-imapproxy-1.2.6/debian/rules
@@ -67,6 +67,10 @@
mv debian/imapproxy/usr/sbin/in.imapproxyd \
debian/imapproxy/usr/sbin/imapproxyd
+ # prepare the default configuration file
+ perl debian/prepare-config-file < scripts/imapproxy.conf \
+ > debian/imapproxy/usr/share/imapproxy/imapproxy.conf.default
+
dh_installexamples
chmod 644 $(CURDIR)/debian/imapproxy/usr/share/doc/imapproxy/examples/imapproxy.conf
diff -u up-imapproxy-1.2.6/debian/changelog up-imapproxy-1.2.6/debian/changelog
--- up-imapproxy-1.2.6/debian/changelog
+++ up-imapproxy-1.2.6/debian/changelog
@@ -1,3 +1,11 @@
+up-imapproxy (1.2.6-4.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * Don't overwrite the config file on upgrades. (Closes: #510432)
+ + now depends on ucf (>= 0.28)
+
+ -- Niko Tyni <[email protected]> Tue, 03 Feb 2009 22:46:51 +0200
+
up-imapproxy (1.2.6-4) unstable; urgency=medium
* 'postinst' script: configuration file processing
diff -u up-imapproxy-1.2.6/debian/imapproxy.config up-imapproxy-1.2.6/debian/imapproxy.config
--- up-imapproxy-1.2.6/debian/imapproxy.config
+++ up-imapproxy-1.2.6/debian/imapproxy.config
@@ -12,9 +12,14 @@
set -e
+CONFIG=/etc/imapproxy.conf
case "$1" in
configure|reconfigure)
+ if [ -f $CONFIG ]; then
+ SERVER="$(perl -ne '/^\s*server_hostname\s*(\S+)$/ && print $1' $CONFIG)"
+ [ -z "$SERVER" ] || db_set imapproxy/imap-server "$SERVER"
+ fi
db_input medium imapproxy/imap-server || true
db_go
;;
diff -u up-imapproxy-1.2.6/debian/imapproxy.dirs up-imapproxy-1.2.6/debian/imapproxy.dirs
--- up-imapproxy-1.2.6/debian/imapproxy.dirs
+++ up-imapproxy-1.2.6/debian/imapproxy.dirs
@@ -2,6 +2,7 @@
etc/default
usr/sbin
var/lib/imapproxy/chroot
+usr/share/imapproxy
usr/share/doc/imapproxy
usr/share/doc/imapproxy/examples
var/run
diff -u up-imapproxy-1.2.6/debian/imapproxy.postinst up-imapproxy-1.2.6/debian/imapproxy.postinst
--- up-imapproxy-1.2.6/debian/imapproxy.postinst
+++ up-imapproxy-1.2.6/debian/imapproxy.postinst
@@ -29,14 +29,7 @@
# `abort-remove' or `abort-deconfigure'.
DESTFILE=/etc/imapproxy.conf
-CFGFILE=imapproxy.conf
-
-PARAMS="server_hostname proc_username proc_groupname chroot_directory listen_port"
-server_hostname="localhost"
-proc_username="nobody"
-proc_groupname="nogroup"
-chroot_directory="/var/lib/imapproxy/chroot"
-listen_port=143
+SRCFILE=/usr/share/imapproxy/imapproxy.conf.default
case "$1" in
configure)
@@ -45,34 +38,26 @@
db_get imapproxy/imap-server || true
server_hostname="$RET"
+ # this should really be a debconf setting too, but it's too
+ # late to do that for lenny, so parse it here
+ if [ -r $DESTFILE ]
+ then
+ CONFIGURED_PORT=$(perl -ne '/^\s*listen_port\s*(\S+)$/ && print $1' $DESTFILE)
+ fi
+
if [ "$server_hostname" = "localhost" ]; then
# change bind port if localhost (#470431)
- listen_port=1143;
+ listen_port=${CONFIGURED_PORT:-1143}
+ else
+ listen_port=${CONFIGURED_PORT:-143}
fi
- test -f $DESTFILE || cp /usr/share/doc/imapproxy/examples/$CFGFILE $DESTFILE;
TMPFILE=`tempfile`
- mv $DESTFILE $TMPFILE
- export PARAMS
- export $PARAMS
-
-/usr/bin/perl -- - $DESTFILE $TMPFILE << 'EOSCRIPT'
-use warnings;
-use strict;
-
-my $CFG;
-open(CFG, '>', shift) or die "imapproxy.postint: could not open: $!";
-
-my %params = map { $_ => undef } split(/\s/, $ENV{'PARAMS'});
-
-while (<>)
-{
- my ($key) = m/^#?(\w+)/;
- if ( defined $key and exists $params{$key} ) { print CFG "$key $ENV{$key}\n"; }
- else { print CFG $_; }
-}
-
-EOSCRIPT
+ sed "s/^server_hostname .*/server_hostname ${server_hostname}/ ;
+ s/^listen_port .*/listen_port ${listen_port}/" \
+ < $SRCFILE > $TMPFILE
+ chmod 644 $TMPFILE
+ ucf --debconf-ok $TMPFILE $DESTFILE
# prevent incorrect time zone config (#436555)
if [ ! -f ${chroot_directory}/etc/localtime ]; then
@@ -80,14 +65,14 @@
cp /etc/localtime ${chroot_directory}/etc
fi
+ ucfr imapproxy $DESTFILE
- # Clean env. & temp file
- for p in $PARAMS PARAMS; do export $p= ; done
+ # Clean temp file
rm -f $TMPFILE
else # -e /usr/share/debconf/confmodule
-
- test -f $DESTFILE || cp /usr/share/doc/imapproxy/examples/$CFGFILE $DESTFILE;
+ # this should never happen, really
+ test -f $DESTFILE || cp $SRCFILE $DESTFILE;
fi
;;
diff -u up-imapproxy-1.2.6/debian/imapproxy.postrm up-imapproxy-1.2.6/debian/imapproxy.postrm
--- up-imapproxy-1.2.6/debian/imapproxy.postrm
+++ up-imapproxy-1.2.6/debian/imapproxy.postrm
@@ -22,6 +22,12 @@
;;
purge)
rm -f /etc/imapproxy.conf
+ if which ucf >/dev/null 2>&1; then
+ ucf --purge /etc/imapproxy.conf
+ fi
+ if which ucfr >/dev/null 2>&1; then
+ ucfr --purge imapproxy /etc/imapproxy.conf
+ fi
;;
*)
only in patch2:
unchanged:
--- up-imapproxy-1.2.6.orig/debian/prepare-config-file
+++ up-imapproxy-1.2.6/debian/prepare-config-file
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+use strict;
+
+# server_hostname and server_port are handled by the postinst
+
+my %params=(
+ proc_username => "nobody",
+ proc_groupname => "nogroup",
+ chroot_directory => "/var/lib/imapproxy/chroot",
+);
+
+while (<>)
+{
+ my ($key) = m/^#?(\w+)/;
+ if ( defined $key and exists $params{$key} ) { print "$key $params{$key}\n"; }
+ else { print $_; }
+}