[xml/sgml-pkgs] Bug#678902: proposed sgml-base 1.16+nmu4 fixing #676717 and #678902

Helmut Grohne helmut at subdivi.de
Wed Jun 27 19:33:28 UTC 2012


Here is my next attempt to fixing #676717 and #678902.

I incorporated the parser Jakub Wilk proposed and tested it on a variety
of catalog files. See the discussion on #676717 for why update-catalog
is starting to parse catalog files.

In addition I added a Pre-Dependency on dpkg >= 1.16.4 to close #678902.
Which highlights that the fixed dpkg trigger bug #675613, #676061,
#676062, #676107, #676118, #676122 still shows up. As per policy section
7.2 I raise this Pre-Depends on -devel. 

So the attached NMU is to fix all the known issues that have come up as
a result of fixing #88010. Comments welcome.

Please CC my in replies as I am not subscribed to -devel.

Helmut
-------------- next part --------------
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-27 21:04:29.000000000 +0200
@@ -1,3 +1,16 @@
+sgml-base (1.26+nmu4) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * update-catalog --update-super ignores catalogs referencing non-existent
+    files. (Closes: #676717) Thanks to Jakub Wilk for contributing the parser.
+  * 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.
+  * Pre-Depend on dpkg >= 1.16.4 (Closes: #678902). Removed dependency on
+    dpkg >= 1.14.18. sgml-base highlights a bug in dpkg's trigger processing. 
+
+ -- Helmut Grohne <helmut at 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/control sgml-base-1.26+nmu4/debian/control
--- sgml-base-1.26+nmu3/debian/control	2012-05-28 13:58:23.000000000 +0200
+++ sgml-base-1.26+nmu4/debian/control	2012-06-27 20:38:49.000000000 +0200
@@ -11,7 +11,8 @@
 Priority: optional
 Architecture: all
 Conflicts: sgml-data (<= 0.02), sgmltools-2 (<= 2.0.2-4)
-Depends: ${perl:Depends}, dpkg (>= 1.14.18)
+Depends: ${perl:Depends}
+Pre-Depends: dpkg (>= 1.16.4)
 Suggests: sgml-base-doc
 Description: SGML infrastructure and SGML catalog file support
  This package creates the SGML infrastructure directories and provides
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-27 21:04:45.000000000 +0200
@@ -4,6 +4,7 @@
 ## ----------------------------------------------------------------------
 ## Copyright (c) 2001-2004 Ardo van Rangelrooij
 ## Copyright (c) 2012 Helmut Grohne
+## Copyright (c) 2012 Jakub Wilk
 ##
 ## This is free software; see the GNU General Public Licence version 2
 ## or later for copying conditions.  There is NO warranty.
@@ -138,8 +139,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 +239,71 @@
 }
 
 ## ----------------------------------------------------------------------
+# Reference: https://www.oasis-open.org/specs/a401.htm
+sub check_catalog($)
+{
+    my($catalog)=shift;
+    my $base = $catalog;
+    $base =~ s,/[^/]+$,,;
+    my $catalog_tokens = qr{
+        ( (?: \s+ | -- .*? --)+ # whitespace and comments
+        | ' .*? ' | " .*? " # literal
+        | \S+ # other tokens
+        )
+        }sx;
+    unless(open(PKGCAT, "<", $catalog)) {
+        print "Warning: Ignoring unreadable catalog file `$catalog'.\n"
+            unless $quiet;
+        return 0;
+    };
+    local $/;
+    my $contents = <PKGCAT>;
+    close PKGCAT;
+    my $prevtoken = 0;
+    while ($contents =~ m/$catalog_tokens/g) {
+        my $token = $1;
+        if ($prevtoken) {
+            next if $token =~ m/^\s|^--/;
+            $token =~ s/^(['"])(.*)\1$/$2/;
+            if($prevtoken eq 'base') {
+                $base = $token;
+            } elsif($prevtoken eq 'catalog') {
+                my $path;
+                if($token =~ m,^/,) {
+                    $path = $token;
+                } else {
+                    $path = "$base/$token";
+                }
+                if(not -f $path) {
+                    print "Warning ignoring catalog `$catalog' which references non-existent catalogs. See man update-catalog for details.\n"
+                        unless $quiet;
+                    return 0;
+                }
+            }
+            $prevtoken = 0;
+        } elsif ("\L$token" eq 'catalog') {
+            $prevtoken = 'catalog';
+        } elsif ("\L$token" eq 'base') {
+            $prevtoken = 'base';
+        }
+    }
+    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-27 21:07:21.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,26 @@
 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 it is parsed and verified in order to not corrupt the super catalog.
+All referenced catalogs are verified to actually 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 <ardo at debian.org>
 .\"


More information about the debian-xml-sgml-pkgs mailing list