Bug#282147: update-inetd interaction

2006-11-01 Thread md
OK then, if you have tested it feel free to NMU.

-- 
ciao,
Marco


signature.asc
Description: Digital signature


Bug#282147: update-inetd interaction

2006-11-01 Thread Roland Stigge
tag 282147 patch
thanks

Hi,

attached you will find a patch that modifies update-inetd to use debconf
for interaction (and therefore non-interaction if non-interactive, with
reasonable defaults).

Submitters of the respective bugs, and maintainers, please review. I can
upload the fix if necessary.

bye,
  Roland
diff -ruN update-inetd-4.27.orig/debian/control update-inetd-4.27/debian/control
--- update-inetd-4.27.orig/debian/control	2006-09-10 21:53:05.0 +0200
+++ update-inetd-4.27/debian/control	2006-11-01 13:45:31.0 +0100
@@ -10,6 +10,7 @@
 Package: update-inetd
 Architecture: all
 Conflicts: netbase (<< 4.27)
+Depends: debconf
 Description: inetd.conf updater
  This package provides a program used by other packages to automatically
  update /etc/inetd.conf.
diff -ruN update-inetd-4.27.orig/debian/postinst update-inetd-4.27/debian/postinst
--- update-inetd-4.27.orig/debian/postinst	1970-01-01 01:00:00.0 +0100
+++ update-inetd-4.27/debian/postinst	2006-11-01 13:46:35.0 +0100
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+# Abort if any command returns an error value
+set -e
+
+if [ "$1" == "configure" -o "$1" == "reconfigure" ] ; then
+	. /usr/share/debconf/confmodule
+	db_capb
+fi
diff -ruN update-inetd-4.27.orig/debian/rules update-inetd-4.27/debian/rules
--- update-inetd-4.27.orig/debian/rules	2006-09-10 21:53:01.0 +0200
+++ update-inetd-4.27/debian/rules	2006-11-01 13:45:31.0 +0100
@@ -22,6 +22,7 @@
 
 	dh_installchangelogs
 	dh_installdocs
+	dh_installdebconf
 	dh_installman DebianNet.3pm update-inetd.8
 	dh_compress
 	dh_fixperms
diff -ruN update-inetd-4.27.orig/debian/templates update-inetd-4.27/debian/templates
--- update-inetd-4.27.orig/debian/templates	1970-01-01 01:00:00.0 +0100
+++ update-inetd-4.27/debian/templates	2006-11-01 14:21:06.0 +0100
@@ -0,0 +1,37 @@
+Template: update-inetd/ask-several-entries
+Type: select
+Choices: yes, no
+Default: yes
+Description: Ignore multiple entries and continue without changes?
+ There are several entries for ${sservice} in ${inetdcf}.
+
+Template: update-inetd/ask-entry-present
+Type: select
+Choices: yes, no
+Default: yes
+Description: Leave existing entry and continue without changes?
+ Trying to add the following entry:
+ .
+ ${newentry}
+ .
+ There is already an entry for ${sservice} in ${inetdcf},
+ but I don't recognise it.  Here is what it looks like:
+ .
+ ${lookslike}
+
+Template: update-inetd/ask-remove-entries
+Type: select
+Choices: yes, no
+Default: no
+Description: Remove inetd entries?
+ ${inetdcf} contains multiple entries for
+ the `${service}' service. You're about to remove these entries.
+
+Template: update-inetd/ask-disable-entries
+Type: select
+Choices: yes, no
+Default: no
+Description: Disable inetd entries?
+ ${inetdcf} contains multiple entries for
+ the `${service}' service. You're about to disable these entries.
+
diff -ruN update-inetd-4.27.orig/DebianNet.pm update-inetd-4.27/DebianNet.pm
--- update-inetd-4.27.orig/DebianNet.pm	2005-03-21 19:54:31.0 +0100
+++ update-inetd-4.27/DebianNet.pm	2006-11-01 14:24:27.0 +0100
@@ -14,6 +14,8 @@
 
 require 5.000;
 
+use Debconf::Client::ConfModule ':all';
+
 $inetdcf="/etc/inetd.conf";
 $sep = "## ";
 $version = "1.11";
@@ -46,12 +48,31 @@
 } else {
 if (grep(m/^$sservice\s+/,@inetd)) {
 if (grep(m/^$sservice\s+/,@inetd) > 1) {
-&inetde("There are several entries for $sservice in $inetdcf\n");
+		set("update-inetd/ask-several-entries", "yes");
+		fset("update-inetd/ask-several-entries", "seen", "false");
+		subst("update-inetd/ask-several-entries", "sservice", "$sservice");
+		subst("update-inetd/ask-several-entries", "inetdcf", "$inetdcf");
+		input("high", "update-inetd/ask-several-entries");
+		@ret = go();
+		if ($ret[0] == 0) {
+		@ret = get("update-inetd/ask-several-entries");
+			exit(1) if ($ret[1] !~ m/y/i);
+		}
 } elsif (!grep(m:^#?.*$searchentry.*:, @inetd)) {
-print"\nTrying to add the following entry:\n\n $newentry\n\n";
-&inetde("There is already an entry for $sservice in $inetdcf,
-but I don't recognise it.  Here is what it looks like:\n
- ".join(' ',grep(m/^$sservice\s+/,@inetd)));
+		set("update-inetd/ask-entry-present", "yes");
+		fset("update-inetd/ask-entry-present", "seen", "false");
+		subst("update-inetd/ask-entry-present", "newentry", "$newentry");
+		subst("update-inetd/ask-entry-present", "sservice", "$sservice");
+		subst("update-inetd/ask-entry-present", "inetdcf", "$inetdcf");
+		my $lookslike = (grep(m/^$sservice\s+/,@inetd))[0];
+		$lookslike =~ s/\n//g;
+		subst("update-inetd/ask-entry-present", "lookslike", "$lookslike");
+		input("high", "update-inetd/ask-entry-present");
+		@ret = go();
+		if ($ret[0] == 0) {
+		@ret = get("update-inetd/ask-entry-present");
+			exit(1) if ($ret[1] !~ m/y