The following commit has been merged in the master branch:
commit ebdac3152275cc56dcbe0504530a724809b921bf
Author: Russ Allbery <[email protected]>
Date:   Fri Dec 25 16:08:59 2009 -0800

    Support multiple versions of a package in the archive
    
    * unpack/list-{bin,src,udeb}pkg:
      + [RA] Support multiple versions of a package in the archive and
        include only the latest version in the Lintian package list.

diff --git a/debian/changelog b/debian/changelog
index 6562997..3ac82f9 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -201,6 +201,9 @@ lintian (2.3.0) UNRELEASED; urgency=low
     + [RA] Suppress checking the syntax of the lintian output if neither
       Test-For nor Test-Against are set and Sort: no is set.
 
+  * unpack/list-{bin,src,udeb}pkg:
+    + [RA] Support multiple versions of a package in the archive and
+      include only the latest version in the Lintian package list.
   * unpack/unpack-binpkg-l2:
     + [RA] Report errors from dpkg-deb or tar on stderr if either exit
       with non-zero status.
diff --git a/unpack/list-binpkg b/unpack/list-binpkg
index 81d5501..0ccd7f2 100755
--- a/unpack/list-binpkg
+++ b/unpack/list-binpkg
@@ -2,17 +2,17 @@
 # list-binpkg -- lintian helper script
 
 # Copyright (C) 1998 Christian Schwarz
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, you can find it on the World Wide
 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
@@ -21,6 +21,9 @@
 
 use strict;
 
+use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Lintian::Relation::Version qw(versions_lte);
+
 # turn file buffering off:
 $| = 1;
 
@@ -102,24 +105,29 @@ my $total = 0;
 foreach my $packages_file (@packages_files) {
     my $pkgs_file = $packages_file->{'file'};
     if (-e $pkgs_file) {
-           print "N: Parsing $pkgs_file ...\n" if $verbose;
-           open(IN, '<', $pkgs_file) or fail("cannot open Packages file 
$pkgs_file: $!");
+       print "N: Parsing $pkgs_file ...\n" if $verbose;
+       open(IN, '<', $pkgs_file)
+           or fail("cannot open Packages file $pkgs_file: $!");
     } elsif (-e "$pkgs_file.gz") {
-           print "N: Parsing $pkgs_file.gz ...\n" if $verbose;
-           open (IN, '-|', 'gzip', '-dc', "$pkgs_file.gz")
-               or fail("cannot open Packages file $pkgs_file.gz: $!");
+       print "N: Parsing $pkgs_file.gz ...\n" if $verbose;
+       open (IN, '-|', 'gzip', '-dc', "$pkgs_file.gz")
+           or fail("cannot open Packages file $pkgs_file.gz: $!");
     } else {
-           fail("No packages file $pkgs_file");
+       fail("No packages file $pkgs_file");
     }
 
     my $line;
 
     while (!eof(IN)) {
-       do { $line = <IN> } until ($line =~ m/^Architecture: (.*)$/m);
-       my $arch = $1;
-       do { $line = <IN> } until ($line =~ m/^Filename: (.*)$/m);
-       my $deb_file = $1;
-       do { $line = <IN> } until ($line =~ m/^\s*$/m);
+       my ($arch, $deb_file);
+       do {
+           $line = <IN>;
+           if ($line =~ /^Architecture: (.*)$/m) {
+               $arch = $1;
+           } elsif ($line =~ /^Filename: (.*)$/m) {
+               $deb_file = $1;
+           }
+       } until (not defined($line) or $line =~ /^\s*$/m);
 
        my @stat;
        # get timestamp...
@@ -155,10 +163,12 @@ foreach my $packages_file (@packages_files) {
            $pkg = $data->{'package'};
        }
 
-       # check for duplicates
+       # Check for duplicates.  In the case of a duplicate, we take the one
+       # with the latest version.
        if (exists $packages{$pkg}) {
-           print "E: general: duplicate-binary-package $pkg\n";
-           next;
+           if (versions_lte($data->{version}, $packages{$pkg}{version})) {
+               next;
+           }
        }
 
        unless (exists $data->{'source-version'}) {
@@ -170,30 +180,37 @@ foreach my $packages_file (@packages_files) {
            }
        }
 
-       # write entry to output file
-       print OUT join(';',
-                      $pkg,
-                      $data->{'version'},
-                      $data->{'source'},
-                      $data->{'source-version'},
-                      $deb_file,
-                      $timestamp,
-                      $packages_file->{'area'}
-                      ),"\n";
-       printf "N: Listed %s binary package %s 
%s\n",$status,$pkg,$data->{'version'} if $verbose;
+       # Save entry for writing to output file.
+       $data->{file} = $deb_file;
+       $data->{timestamp} = $timestamp;
+       $data->{area} = $packages_file->{area};
+       $data->{status} = $status;
+       $packages{$pkg} = $data;
 
        # remove record from hash
        delete $binary_info{$pkg} if $status eq 'unchanged';
-       $packages{$pkg} = 1;
        $total++;
     }
     close(IN) or fail("cannot close input pipe: $!");
 }
-
+for my $pkg (sort keys %packages) {
+    print OUT join(';',
+                  $pkg,
+                  $packages{$pkg}{version},
+                  $packages{$pkg}{source},
+                  $packages{$pkg}{'source-version'},
+                  $packages{$pkg}{file},
+                  $packages{$pkg}{timestamp},
+                  $packages{$pkg}{area}
+                 ),"\n";
+    printf "N: Listed %s binary package %s %s\n", $packages{$pkg}{status},
+       $pkg, $packages{$pkg}{version} if $verbose;
+}
 close(OUT) or fail("cannot close output pipe: $!");
 
 if ($verbose) {
-    # all packages that are still included in %binary_info have disappeared 
from the archive...
+    # All packages that are still included in %binary_info have disappeared
+    # from the archive.
     for my $pkg (sort keys %binary_info) {
        print "N: Removed binary package $pkg from list\n";
     }
@@ -216,3 +233,9 @@ sub safe_get_deb_info {
     $data->{'source'} or ($data->{'source'} = $data->{'package'});
     return $data;
 }
+
+# Local Variables:
+# indent-tabs-mode: t
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 ts=4 noet shiftround
diff --git a/unpack/list-srcpkg b/unpack/list-srcpkg
index c926aa0..cfe2ce1 100755
--- a/unpack/list-srcpkg
+++ b/unpack/list-srcpkg
@@ -2,17 +2,17 @@
 # list-srcpkg -- lintian helper script
 
 # Copyright (C) 1998 Christian Schwarz
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, you can find it on the World Wide
 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
@@ -21,6 +21,9 @@
 
 use strict;
 
+use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Lintian::Relation::Version qw(versions_lte);
+
 # turn file buffering off:
 $| = 1;
 
@@ -159,42 +162,53 @@ foreach my $sources (@sources) {
       $pkg = $data->{'source'};
     }
 
-    # check for duplicates
+    # Check for duplicates.  In the case of a duplicate, we take the one with
+    # the latest version.
     if (exists $packages{$pkg}) {
-      print "E: general: duplicate-source-package $pkg\n";
-      next;
+      if (versions_lte($data->{version}, $packages{$pkg}{version})) {
+        next;
+      }
     }
 
-    # write entry to output file
-    for (qw/version maintainer uploaders architecture standards-version binary 
files/) {
+    # Save entry for writing to output file.
+    $data->{file} = $dsc_file;
+    $data->{area} = $sources->{area};
+    $data->{timestamp} = $timestamp;
+    $data->{status} = $status;
+    for (qw(version maintainer uploaders architecture standards-version
+            binary files)) {
       $data->{$_} =~ tr/;\n/_ / if $data->{$_};
     }
-    print OUT join(';',
-                  $pkg,
-                  $data->{'version'},
-                  $data->{'maintainer'},
-                  $data->{'uploaders'} || '',
-                  $data->{'architecture'},
-                  $sources->{'area'},
-                  $data->{'standards-version'},
-                  $data->{'binary'},
-                  $data->{'files'},
-                  $dsc_file,
-                  $timestamp,
-                  ),"\n";
-    printf "N: Listed %s source package %s 
%s\n",$status,$pkg,$data->{'version'} if $verbose;
+    $packages{$pkg} = $data;
 
     # remove record from hash
     delete $source_info{$pkg} if $status eq 'unchanged';
-    $packages{$pkg} = 1;
     $total++;
   }
   close(IN) or fail("cannot close input pipe: $!");
 }
+for my $pkg (sort keys %packages) {
+  print OUT join(';',
+                 $pkg,
+                 $packages{$pkg}{version},
+                 $packages{$pkg}{maintainer},
+                 $packages{$pkg}{uploaders} || '',
+                 $packages{$pkg}{architecture},
+                 $packages{$pkg}{area},
+                 $packages{$pkg}{'standards-version'},
+                 $packages{$pkg}{binary},
+                 $packages{$pkg}{files},
+                 $packages{$pkg}{file},
+                 $packages{$pkg}{timestamp},
+                ),"\n";
+  printf "N: Listed %s source package %s %s\n", $packages{$pkg}{status},
+      $pkg, $packages{$pkg}{version} if $verbose;
+}
 close(OUT) or fail("cannot close output pipe: $!");
 
 if ($verbose) {
-  # all packages that are still included in %source_info have disappeared from 
the archive...
+  # All packages that are still included in %source_info have disappeared from
+  # the archive.
   for my $pkg (sort keys %source_info) {
     print "N: Removed source package $pkg from list\n";
   }
diff --git a/unpack/list-udebpkg b/unpack/list-udebpkg
index c8597eb..3de3f00 100755
--- a/unpack/list-udebpkg
+++ b/unpack/list-udebpkg
@@ -3,17 +3,17 @@
 
 # Copyright (C) 1998 Christian Schwarz
 # Copyright (C) 2004 Frank Lichtenheld
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, you can find it on the World Wide
 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
@@ -22,6 +22,9 @@
 
 use strict;
 
+use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Lintian::Relation::Version qw(versions_lte);
+
 # turn file buffering off:
 $| = 1;
 
@@ -104,10 +107,11 @@ foreach my $packages_file (@packages_files) {
     my $pkgs_file = $packages_file->{'file'};
     if (-e $pkgs_file) {
         print "N: Parsing $pkgs_file ...\n" if $verbose;
-        open(IN, '<', $pkgs_file) or fail("cannot open Packages file 
$pkgs_file: $!");
+        open(IN, '<', $pkgs_file)
+            or fail("cannot open Packages file $pkgs_file: $!");
     } elsif (-e "$pkgs_file.gz") {
         print "N: Parsing $pkgs_file.gz ...\n" if $verbose;
-         open(IN, '-|', 'gzip', '-dc', "$pkgs_file.gz")
+        open(IN, '-|', 'gzip', '-dc', "$pkgs_file.gz")
             or fail("cannot open Packages file $pkgs_file.gz: $!");
     } else {
         warn("No packages file $pkgs_file, skipping");
@@ -157,13 +161,15 @@ foreach my $packages_file (@packages_files) {
            $pkg = $data->{'package'};
         }
 
-        # check for duplicates
+        # Check for duplicates.  In the case of a duplicate, we take the one
+        # with the latest version.
         if (exists $packages{$pkg}) {
-           print "E: general: duplicate-udeb-package $pkg\n";
-           next;
+            if (versions_lte($data->{version}, $packages{$pkg}{version})) {
+                next;
+            }
         }
 
-         unless (exists $data->{'source-version'}) {
+        unless (exists $data->{'source-version'}) {
            if ($data->{'source'} =~ /^([-+\.\w]+)\s+\((.+)\)$/) {
                $data->{'source'} = $1;
                $data->{'source-version'} = $2;
@@ -172,29 +178,36 @@ foreach my $packages_file (@packages_files) {
            }
         }
 
-        # write entry to output file
-        print OUT join(';',
-                      $pkg,
-                      $data->{'version'},
-                      $data->{'source'},
-                      $data->{'source-version'},
-                      $deb_file,
-                      $timestamp,
-                      $packages_file->{'area'},
-                      ),"\n";
-        printf "N: Listed %s udeb package %s 
%s\n",$status,$pkg,$data->{'version'} if $verbose;
+        # Save entry for writing to output file.
+        $data->{file} = $deb_file;
+        $data->{timestamp} = $timestamp;
+        $data->{area} = $packages_file->{area};
+        $data->{status} = $status;
+        $packages{$pkg} = $data;
 
         # remove record from hash
         delete $udeb_info{$pkg} if $status eq 'unchanged';
-        $packages{$pkg} = 1;
         $total++;
     }
     close(IN) or fail("cannot close input pipe: $!");
 }
+for my $pkg (sort keys %packages) {
+    print OUT join(';',
+                   $pkg,
+                   $packages{$pkg}{version},
+                   $packages{$pkg}{source},
+                   $packages{$pkg}{'source-version'},
+                   $packages{$pkg}{file},
+                   $packages{$pkg}{timestamp},
+                   $packages{$pkg}{area}
+                  ),"\n";
+    printf "N: Listed %s udeb package %s %s\n", $packages{$pkg}{status},
+        $pkg, $packages{$pkg}{version} if $verbose;
+}
 close(OUT) or fail("cannot close output pipe: $!");
-
 if ($verbose) {
-    # all packages that are still included in %udeb_info have disappeared from 
the archive...
+    # All packages that are still included in %udeb_info have disappeared from
+    # the archive.
     for my $pkg (sort keys %udeb_info) {
        print "N: Removed udeb package $pkg from list\n";
     }
@@ -217,3 +230,9 @@ sub safe_get_deb_info {
     $data->{'source'} or ($data->{'source'} = $data->{'package'});
     return $data;
 }
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 ts=4 et shiftround

-- 
Debian package checker


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to