[xml/sgml-pkgs] Bug#477751: tackling this bug
Helmut Grohne
helmut at subdivi.de
Mon Dec 12 13:51:49 UTC 2011
Hi Daniel and Joey,
I took some more time to look at Daniel's proposal and managed to come
up with an implementation which consists of one debdiff to only
debhelper (no sgml-base changes).
On Mon, Dec 05, 2011 at 12:05:26AM +0100, Daniel Leidert wrote:
> (1) Register the catalog, if it exists (and unregister any registered
> catalog, if it doesn't exist anymore). So users can remove the package
> catalog file.
>
> (2) Register the catalog only during installation, but not during
> upgrade. Usually we only add a catalog reference to the super
> catalog.
>
> (3) Catalog files should be written at build time not during
> installation. Instead of creating /etc/sgml/package.cat during
> installation, this should be created during package build. So the user
> can edit /etc/sgml/package.cat and /etc/sgml/catalog and we preserve
> these changes.
>
> If the user now changes /etc/sgml/package.cat and we need to ship an
> updated file, he should usually be asked, if he wishes to update the
> file during installation.
I implemented the above description. The details are:
* prerm will no longer remove the package catalog from the root catalog
during upgrade.
* postrm will only remove the .old file on purge (dpkg remove the
conffile /etc/sgml/$package.cat).
* postinst will no longer regenerate /etc/sgml/$package.cat and only
add the package catalog to the root catalog during installation (as
it is no longer removed during upgrade).
* dh_installcatalogs will create a /etc/sgml/$package.cat containing
the same contents (without the comment header).
* preinst will do the tricky transition part. If it is called during an
upgrade and /etc/sgml/$package.cat is not owned by any package (this
is currently the case), then it fixes up the installation. The old
prerm will have the package catalog removed from the root catalog, so
it is readded here. The old postinst would recreate
/etc/sgml/$package.cat. This file is removed during preinst. The
advantage of this approach is that the conffile can be installed
without asking the user. The disadvantage of this approach is that
we are overwriting user changes one more time.
There is a debhelper.debdiff attached which implements the above
description. I have rebuild xml-core using this patched debhelper and
tried to upgrade and reinstall xml-core. However downgrading xml-core
and upgrading it again results in a broken installation. Even when
downgrading a package a conffile stays to be a conffile, so the preinst
hook is only executed during the first upgrade. After the second upgrade
the /etc/sgml/$package.cat is left untouched (being a conffile) and
missing from /etc/sgml/catalog.
What do you think about this approach?
Helmut
-------------- next part --------------
diff -Nru debhelper-8.9.13/autoscripts/postinst-sgmlcatalog debhelper-8.9.13+nmu1/autoscripts/postinst-sgmlcatalog
--- debhelper-8.9.13/autoscripts/postinst-sgmlcatalog 2011-08-07 02:46:45.000000000 +0200
+++ debhelper-8.9.13+nmu1/autoscripts/postinst-sgmlcatalog 2011-12-12 13:26:14.000000000 +0100
@@ -1,7 +1,3 @@
-if [ "$1" = "configure" ]; then
- rm -f #CENTRALCAT#
- for ordcat in #ORDCATS#; do
- update-catalog --quiet --add #CENTRALCAT# ${ordcat}
- done
+if [ "$1" = "configure" ] && [ -z "$2" ]; then
update-catalog --quiet --add --super #CENTRALCAT#
fi
diff -Nru debhelper-8.9.13/autoscripts/postrm-sgmlcatalog debhelper-8.9.13+nmu1/autoscripts/postrm-sgmlcatalog
--- debhelper-8.9.13/autoscripts/postrm-sgmlcatalog 2011-08-07 02:46:45.000000000 +0200
+++ debhelper-8.9.13+nmu1/autoscripts/postrm-sgmlcatalog 2011-12-12 12:12:48.000000000 +0100
@@ -1,3 +1,3 @@
if [ "$1" = "purge" ]; then
- rm -f #CENTRALCAT# #CENTRALCAT#.old
+ rm -f #CENTRALCAT#.old
fi
diff -Nru debhelper-8.9.13/autoscripts/preinst-sgmlcatalog debhelper-8.9.13+nmu1/autoscripts/preinst-sgmlcatalog
--- debhelper-8.9.13/autoscripts/preinst-sgmlcatalog 1970-01-01 01:00:00.000000000 +0100
+++ debhelper-8.9.13+nmu1/autoscripts/preinst-sgmlcatalog 2011-12-12 14:04:43.000000000 +0100
@@ -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 and needs to be cleaned up.
+ rm -f #CENTRALCAT#
+ update-catalog --quiet --add --super #CENTRALCAT#
+fi
diff -Nru debhelper-8.9.13/autoscripts/prerm-sgmlcatalog debhelper-8.9.13+nmu1/autoscripts/prerm-sgmlcatalog
--- debhelper-8.9.13/autoscripts/prerm-sgmlcatalog 2011-08-07 02:46:45.000000000 +0200
+++ debhelper-8.9.13+nmu1/autoscripts/prerm-sgmlcatalog 2011-12-12 12:12:07.000000000 +0100
@@ -1,3 +1,3 @@
-if [ "$1" = "remove" ] || [ "$1" = "upgrade" ]; then
+if [ "$1" = "remove" ]; then
update-catalog --quiet --remove --super #CENTRALCAT#
fi
diff -Nru debhelper-8.9.13/debian/changelog debhelper-8.9.13+nmu1/debian/changelog
--- debhelper-8.9.13/debian/changelog 2011-12-09 18:53:42.000000000 +0100
+++ debhelper-8.9.13+nmu1/debian/changelog 2011-12-12 14:22:58.000000000 +0100
@@ -1,3 +1,11 @@
+debhelper (8.9.13+nmu1) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Turn /etc/sgml/$package.cat into conffiles and do not touch
+ /etc/sgml/catalog during upgrads. Closes: #88010
+
+ -- Helmut Grohne <helmut at subdivi.de> Mon, 12 Dec 2011 14:21:36 +0100
+
debhelper (8.9.13) unstable; urgency=low
* Pass CPPFLAGS to qmake. Closes: #646129 Thanks, Felix Geyert
diff -Nru debhelper-8.9.13/dh_installcatalogs debhelper-8.9.13+nmu1/dh_installcatalogs
--- debhelper-8.9.13/dh_installcatalogs 2011-09-12 18:01:19.000000000 +0200
+++ debhelper-8.9.13+nmu1/dh_installcatalogs 2011-12-12 14:05:49.000000000 +0100
@@ -96,11 +96,19 @@
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, "preinst", "preinst-sgmlcatalog",
+ "s%#CENTRALCAT#%$centralcat%g;");
autoscript($package, "postinst", "postinst-sgmlcatalog",
- "s%#CENTRALCAT#%$centralcat%g; s%#ORDCATS#%$ordcats%g;");
+ "s%#CENTRALCAT#%$centralcat%g;");
autoscript($package, "prerm", "prerm-sgmlcatalog",
"s%#CENTRALCAT#%$centralcat%g;");
autoscript($package, "postrm", "postrm-sgmlcatalog",
More information about the debian-xml-sgml-pkgs
mailing list