Control: tag -1 + patch

On Thu, 26 Jan 2012 13:36:43 +0100, Andreas Beckmann wrote:

>   Preparing to replace conserver-client 8.1.16-3 (using 
> .../conserver-client_8.1.18-1_amd64.deb) ...
>   Unpacking replacement conserver-client ...
>   ...
>   Setting up conserver-client (8.1.18-1) ...
>   
>   Configuration file `/etc/conserver/console.cf'
>    ==> Modified (by you or by a script) since installation.
>    ==> Package distributor has shipped an updated version.
>      What would you like to do about it ?  Your options are:
>       Y or I  : install the package maintainer's version
>       N or O  : keep your currently-installed version
>         D     : show the differences between the versions
>         Z     : start a shell to examine the situation
>    The default action is to keep your current version.
>   *** console.cf (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing 
> conserver-client (--configure):
>    EOF on stdin at conffile prompt
>   Errors were encountered while processing:
>    conserver-client

Attached is a first attempt to handle the config file in a better
way.

Feedback welcome.


Cheers,
gregor

-- 
 .''`.  Homepage: http://info.comodo.priv.at/ - OpenPGP key 0xBB3A68018649AA06
 : :' : Debian GNU/Linux user, admin, and developer  -  http://www.debian.org/
 `. `'  Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
   `-   NP: Leonard Cohen: Winter Lady
diff -u conserver-8.1.18/debian/changelog conserver-8.1.18/debian/changelog
--- conserver-8.1.18/debian/changelog
+++ conserver-8.1.18/debian/changelog
@@ -1,3 +1,17 @@
+conserver (8.1.18-2.1) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * Fix "prompting due to modified conffiles which where not modified by
+    the user":
+    - don't install the conffile (but an example that's used in .postinst if
+      the file doesn't exist yet)
+    - read existing values in .config
+    - fix replacement in .postinst
+    - remove the correct file in .postrm
+    (Closes: #657465)
+
+ -- gregor herrmann <gre...@debian.org>  Mon, 03 Sep 2012 23:44:53 +0200
+
 conserver (8.1.18-2) unstable; urgency=low
 
   * added lsb-init patch from Bernhard Schmidt (closes: #672468)
diff -u conserver-8.1.18/debian/conserver-client.config conserver-8.1.18/debian/conserver-client.config
--- conserver-8.1.18/debian/conserver-client.config
+++ conserver-8.1.18/debian/conserver-client.config
@@ -2,6 +2,16 @@
 
 . /usr/share/debconf/confmodule
 
+conf=/etc/conserver/console.cf
+
+if [ -r $conf ]; then
+	SERVER=$(perl -ne 'print $1 if /master\s+([^;]+);/' $conf)
+	PORT=$(perl   -ne 'print $1 if /port\s+([^;]+);/'   $conf)
+
+	db_set conserver-client/server "$SERVER"
+	db_set conserver-client/port   "$PORT"
+fi
+
 db_input medium conserver-client/config || true
 db_go
 
diff -u conserver-8.1.18/debian/conserver-client.install conserver-8.1.18/debian/conserver-client.install
--- conserver-8.1.18/debian/conserver-client.install
+++ conserver-8.1.18/debian/conserver-client.install
@@ -1,2 +1,2 @@
-debian/console.cf	/etc/conserver
+debian/console.cf.ex	/etc/conserver
 console/console		/usr/bin
diff -u conserver-8.1.18/debian/conserver-client.postinst conserver-8.1.18/debian/conserver-client.postinst
--- conserver-8.1.18/debian/conserver-client.postinst
+++ conserver-8.1.18/debian/conserver-client.postinst
@@ -6,14 +6,18 @@
 if [ "$1" = "configure" -a -e /usr/share/debconf/confmodule ]; then
 	. /usr/share/debconf/confmodule
 
+	if [ ! -e $conf ]; then
+		cp $conf.ex $conf
+	fi
+
 	db_get conserver-client/config
 	if [ "$RET" = "true" ]; then
 
 		touch $conf
 		db_get conserver-client/server
-		perl -pi -e "s/\w+;$/$RET;/ if /^master\s/" $conf
+		perl -pi -e "s/master(\s+)(?:[^;]+);/master\1$RET;/" $conf
 		db_get conserver-client/port
-		perl -pi -e "s/\w+;$/$RET;/ if /^port\s/" $conf
+		perl -pi -e "s/port(\s+)(?:[^;]+);/port\1$RET;/"     $conf
 	fi
 fi
 
diff -u conserver-8.1.18/debian/conserver-client.postrm conserver-8.1.18/debian/conserver-client.postrm
--- conserver-8.1.18/debian/conserver-client.postrm
+++ conserver-8.1.18/debian/conserver-client.postrm
@@ -5,7 +5,7 @@
 
 case "$1" in
 purge)
-	rm -f /etc/conserver/console.conf
+	rm -f /etc/conserver/console.cf
 	# try remove the confdirectory (why isn't there a 'prerm purge'?)
 	if [ -d /etc/conserver ]; then
 		rmdir --ignore-fail-on-non-empty /etc/conserver
reverted:
--- conserver-8.1.18/debian/console.cf
+++ conserver-8.1.18.orig/debian/console.cf
@@ -1,6 +0,0 @@
-
-# default config for console
-config * {
-	master	CONSERVER_MASTER;
-	port	CONSERVER_PORT;
-}
only in patch2:
unchanged:
--- conserver-8.1.18.orig/debian/console.cf.ex
+++ conserver-8.1.18/debian/console.cf.ex
@@ -0,0 +1,6 @@
+
+# default config for console
+config * {
+	master	CONSERVER_MASTER;
+	port	CONSERVER_PORT;
+}

Attachment: signature.asc
Description: Digital signature

Reply via email to