From: Joey Hess <joey@kitenet.net>
Date: Mon, 28 May 2012 17:40:05 +0000 (-0400)
Subject: dh_installcatalogs: Turn /etc/sgml/$package.cat into conffiles and introduce dependen... 
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0ecce5d6f0ea6e7fd91216bb293d8ec769172c4c;p=debhelper.git

dh_installcatalogs: Turn /etc/sgml/$package.cat into conffiles and introduce dependency on trigger-based sgml-base. Closes: #477751 Thanks, Helmut Grohne
---

diff --git a/autoscripts/postinst-sgmlcatalog b/autoscripts/postinst-sgmlcatalog
deleted file mode 100644
index 100dee2..0000000
--- a/autoscripts/postinst-sgmlcatalog
+++ /dev/null
@@ -1,7 +0,0 @@
-if [ "$1" = "configure" ]; then
-	rm -f #CENTRALCAT#
-	for ordcat in #ORDCATS#; do
-		update-catalog --quiet --add #CENTRALCAT# ${ordcat}
-	done
-	update-catalog --quiet --add --super #CENTRALCAT#
-fi
diff --git a/autoscripts/postrm-sgmlcatalog b/autoscripts/postrm-sgmlcatalog
index 168a694..f8278e6 100644
--- a/autoscripts/postrm-sgmlcatalog
+++ b/autoscripts/postrm-sgmlcatalog
@@ -1,3 +1,3 @@
 if [ "$1" = "purge" ]; then
-	rm -f #CENTRALCAT# #CENTRALCAT#.old
+	rm -f #CENTRALCAT#.old
 fi
diff --git a/autoscripts/preinst-sgmlcatalog b/autoscripts/preinst-sgmlcatalog
new file mode 100644
index 0000000..41f55d6
--- /dev/null
+++ b/autoscripts/preinst-sgmlcatalog
@@ -0,0 +1,7 @@
+if [ "$1" = "upgrade" ] && ! dpkg-query -S #CENTRALCAT# >/dev/null 2>&1; then
+	# If the dpkg-query command returns non-zero, the central catalog is
+	# not owned by any package. This is due to an old behaviour of
+	# debhelper. Now that file becomes a conffile. In order to avoid a
+	# question during installation, we remove the old non-conffile.
+	rm -f #CENTRALCAT#
+fi
diff --git a/autoscripts/prerm-sgmlcatalog b/autoscripts/prerm-sgmlcatalog
deleted file mode 100644
index d6f6fa7..0000000
--- a/autoscripts/prerm-sgmlcatalog
+++ /dev/null
@@ -1,3 +0,0 @@
-if [ "$1" = "remove" ] || [ "$1" = "upgrade" ]; then
-	update-catalog --quiet --remove --super #CENTRALCAT#
-fi
diff --git a/debian/changelog b/debian/changelog
index 053aa1e..8248204 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+debhelper (9.20120524) UNRELEASED; urgency=low
+
+  * dh_installcatalogs: Turn /etc/sgml/$package.cat into conffiles
+    and introduce dependency on trigger-based sgml-base. Closes: #477751
+    Thanks, Helmut Grohne
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 28 May 2012 13:37:44 -0400
+
 debhelper (9.20120523) unstable; urgency=low
 
   * Spanish translation update. Closes: #673629 Thanks, Omar Campagne
diff --git a/dh_installcatalogs b/dh_installcatalogs
index b33f897..b3aaf5e 100755
--- a/dh_installcatalogs
+++ b/dh_installcatalogs
@@ -9,7 +9,7 @@ dh_installcatalogs - install and register SGML Catalogs
 use strict;
 use Debian::Debhelper::Dh_Lib;
 
-my $sgmlbasever = "1.17";
+my $sgmlbasever = "1.26+nmu2";
 
 =head1 SYNOPSIS
 
@@ -96,12 +96,16 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			doit("install","-d","-m755","$tmpdir/etc/sgml");
 		}
 
+		my $centralcat = "/etc/sgml/$package.cat";
+
+		open(CENTRALCAT, ">", "$tmpdir$centralcat") || error("failed to write to $tmpdir$centralcat");
+		foreach my $sgmldest (@sgmlinstalled) {
+			print CENTRALCAT "CATALOG " . $sgmldest . "\n";
+		}
+		close CENTRALCAT;
+
 		if (! $dh{NOSCRIPTS}) {
-			my $ordcats = join(" ", @sgmlinstalled);
-			my $centralcat = "/etc/sgml/$package.cat";
-			autoscript($package, "postinst", "postinst-sgmlcatalog",
-				   "s%#CENTRALCAT#%$centralcat%g; s%#ORDCATS#%$ordcats%g;");
-			autoscript($package, "prerm", "prerm-sgmlcatalog",
+			autoscript($package, "preinst", "preinst-sgmlcatalog",
 				   "s%#CENTRALCAT#%$centralcat%g;");
 			autoscript($package, "postrm", "postrm-sgmlcatalog",
 				   "s%#CENTRALCAT#%$centralcat%g;");