reassign 676717 sgml-base
reassign 678143 sgml-base
# The two problems are actually variants of the same cause.
force-merge 676717 678143
retitle 676717 sgml-base produces broken super catalog when packages are in 
"rc" state
# Breaking other packages.
severity 676717 serious
# Help Rhonda with stable rc bug squashing.
found 676717 sgml-base/1.26+nmu2
tags 676717 + patch
thanks

On Fri, Jun 22, 2012 at 07:45:34AM +0900, Norbert Preining wrote:
> Yeah looks fine. Surely I will not upload something like this ;-)

I attached a revised version (with minor changes) and got the following
reviews:
 * Norbert Preinig (looks fine)
 * Julien Cristau (acked behaviour change, requested --quiet)
 * Alexander Wirt (perl style suggestions)
 * Gregor Herrmann (reviewed perl code)

Thanks to all reviewers for their time. As far as I can tell no reviewer
looked at the syntax of catalog files or built and tested the patch.

Additionally I verified the following aspects:
 * Upgrading from older sgml-base version to nmu4 updates the super
   catalog. (So "broken" systems get repaired.)
 * Installing an "old" package (sgml-data) and removing it results in it
   being removed from the super catalog by the backwards compatibility
   of --remove --super.
 * Installing a "new" package (docutils-common) and removing it results
   in being removed from the super catalog, because the trigger gets
   activated (even though the file doesn't change). (This case was
   highlighted by Joachim Breitner.)

So unless someone speaks up, I will try to get the attached .debdiff
uploaded.

Note that even though this fixes an RC bug I did not set urgency=high
(and don't beat the freeze), because the problem is easily worked around
(by purging packages) and I would like to see unstable break before
migrating this change to wheezy.

Helmut
diff -Nru sgml-base-1.26+nmu3/debian/changelog 
sgml-base-1.26+nmu4/debian/changelog
--- sgml-base-1.26+nmu3/debian/changelog        2012-05-28 21:11:52.000000000 
+0200
+++ sgml-base-1.26+nmu4/debian/changelog        2012-06-22 17:27:58.000000000 
+0200
@@ -1,3 +1,14 @@
+sgml-base (1.26+nmu4) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * update-catalog --update-super ignores catalogs referencing non-existent
+    files. (Closes: #676717)
+  * Remove warning about rebuilding packages as it may confuse users.
+  * Quieten update-catalog during trigger and postinst, to avoid warnings for
+    packages in "rc" state.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Thu, 21 Jun 2012 16:09:07 +0200
+
 sgml-base (1.26+nmu3) unstable; urgency=low
 
   * Non-maintainer upload.
diff -Nru sgml-base-1.26+nmu3/debian/sgml-base.postinst 
sgml-base-1.26+nmu4/debian/sgml-base.postinst
--- sgml-base-1.26+nmu3/debian/sgml-base.postinst       2012-05-28 
13:58:23.000000000 +0200
+++ sgml-base-1.26+nmu4/debian/sgml-base.postinst       2012-06-22 
17:22:31.000000000 +0200
@@ -61,12 +61,12 @@
     fi
 
     ## ------------------------------------------------------------------
-    update-catalog --update-super
+    update-catalog --quiet --update-super
     ln -sf /var/lib/sgml-base/supercatalog /etc/sgml/catalog
 fi
 if [ "$1" = "triggered" ]
 then
-    update-catalog --update-super
+    update-catalog --quiet --update-super
 fi
 
 ## ---------------------------------------------------------------------- 
diff -Nru sgml-base-1.26+nmu3/tools/update-catalog 
sgml-base-1.26+nmu4/tools/update-catalog
--- sgml-base-1.26+nmu3/tools/update-catalog    2012-05-28 21:11:52.000000000 
+0200
+++ sgml-base-1.26+nmu4/tools/update-catalog    2012-06-22 17:29:02.000000000 
+0200
@@ -138,8 +138,6 @@
         print "Invocation of dpkg-trigger failed with status $?.\n";
         print "Forcing update of the super catalog...\n";
         &update_super;
-    } else {
-        print "update-catalog: Please rebuild the package being set up with a 
version of debhelper fixing #477751.\n";
     }
 }
 elsif ( $add )
@@ -240,17 +238,63 @@
 }
 
 ## ----------------------------------------------------------------------
+sub check_catalog($)
+{
+    my($catalog)=shift;
+    my($incomment)=0;
+    unless(open(PKGCAT, "<", $catalog)) {
+        print "Warning: Ignoring unreadable catalog file `$catalog'.\n"
+            unless $quiet;
+        return 0;
+    };
+    while(<PKGCAT>)
+    {
+        if((not $incomment) and m/^-- update-catalog:nocheck --$/)
+        {
+            close(PKGCAT);
+            return 1;
+        }
+        s/--.*?--/ /g;
+        if(m/--/) {
+            if($incomment) {
+                s/.*?--//;
+            } else {
+                s/--.*//;
+            }
+            $incomment = 1 - $incomment;
+        }
+        if(m/CATALOG\s+(\S+)/) {
+            if(not -f $1) {
+                close(PKGCAT);
+                print "Warning: Ignoring catalog `$catalog' which references 
non-existent catalogs. See man update-catalog for details.\n"
+                    unless $quiet;
+                return 0;
+            }
+        }
+    }
+    close(PKGCAT);
+    if($incomment) {
+        print "Warning: Ignoring catalog `$catalog' with unclosed comment. See 
man update-catalog for details.\n"
+            unless $quiet;
+        return 0;
+    }
+    return 1;
+}
+## ----------------------------------------------------------------------
 sub update_super
 {
     my(@cats);
     my($catdir)="/etc/sgml";
     my($supercat)="/var/lib/sgml-base/supercatalog";
+    my $catfile;
     opendir(CATDIR, $catdir)
         or die "cannot open catalog directory $catdir: $!";
     while( readdir CATDIR )
     {
         m/^[^.].*\.cat$/ or next;
-        push(@cats, $catdir . "/" . $_);
+        $catfile = $catdir . "/" . $_;
+        check_catalog($catfile) or next;
+        push(@cats, $catfile);
     }
     closedir(CATDIR)
         or die "cannot close catalog directory $catdir: $!";
diff -Nru sgml-base-1.26+nmu3/tools/update-catalog.8 
sgml-base-1.26+nmu4/tools/update-catalog.8
--- sgml-base-1.26+nmu3/tools/update-catalog.8  2012-05-28 13:58:23.000000000 
+0200
+++ sgml-base-1.26+nmu4/tools/update-catalog.8  2012-06-21 17:17:34.000000000 
+0200
@@ -45,6 +45,9 @@
 extension or remove (or move) existing centralized catalogs and regenerate the 
super catalog using the
 .B --update-super
 option.
+See section
+.B SUPER CATALOG
+for details on the generation process.
 .\"
 .\" ----------------------------------------------------------------------
 .SH OPTIONS
@@ -64,10 +67,10 @@
 .B --update-super
 Regenerates the SGML super catalog from the contents of the
 .IR /etc/sgml
-directory including all files having a
-.B .cat
-extension.
-Files ending in .disabled or .old for instance are not considered.
+directory.
+See section
+.B SUPER CATALOG
+for details on the super catalog generation.
 .TP
 .B --quiet
 Prevents the usual diagnostic output.
@@ -83,6 +86,31 @@
 Display the usage information and exits.
 .\"
 .\" ----------------------------------------------------------------------
+.SH SUPER CATALOG
+The super-catalog located in
+.IR /etc/sgml/catalog
+cannot be directly modified.
+It is generated by the
+.IR update-catalog
+.IR --update-super
+command.
+The generation considers files in the
+.IR /etc/sgml
+directory that have a
+.B .cat
+extension.
+For instance files ending in .old or .disabled are not considered.
+Before adding a catalog to the super catalog some checks are done in order to 
not corrupt the super catalog.
+You can disable those checks by placing a line
+.B "-- update-catalog:nocheck --"
+at the top of your catalog.
+This might be necessary if your catalog file contains non-catalog entries.
+Catalogs shipped with packages must not disable the checks.
+The check verifies that all catalogs referenced from the catalog do indeed 
exist.
+If the check fails, a message is printed and the complete catalog is ignored.
+This check ensures that a catalog from a package, which is removed but not 
purged, is removed from the super catalog.
+.\"
+.\" ----------------------------------------------------------------------
 .SH AUTHOR
 Ardo van Rangelrooij <a...@debian.org>
 .\"

Reply via email to