[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-79-gbd375b8
The following commit has been merged in the lab-refactor branch:
commit bd375b89b124b4466af7aad4a99f2c4a9c8edf00
Author: Niels Thykier <niels@thykier.net>
Date: Wed Sep 28 12:19:20 2011 +0200
Migrate unpack/list-*pkg to Lintian::Lab::Manifest
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/unpack/list-binpkg b/unpack/list-binpkg
index 55a978a..ea1b412 100755
--- a/unpack/list-binpkg
+++ b/unpack/list-binpkg
@@ -23,7 +23,7 @@ use strict;
use warnings;
use lib "$ENV{'LINTIAN_ROOT'}/lib";
-use Lintian::Internal::PackageList;
+use Lintian::Lab::Manifest;
use Lintian::Relation::Version qw(versions_lte);
use Util;
@@ -79,19 +79,19 @@ my $LINTIAN_AREA = $ENV{'LINTIAN_AREA'};
my $LINTIAN_LAB = $ENV{'LINTIAN_LAB'};
# read old list file (this command does nothing if the file does not exist)
-my $plist = Lintian::Internal::PackageList->new($type);
+my $plist = Lintian::Lab::Manifest->new ($type);
# This stores all the new ones (allows us to use $plist to find old entries)
-my $nlist = Lintian::Internal::PackageList->new($type);
+my $nlist = Lintian::Lab::Manifest->new ($type);
# ignore the contents if the contents cannot be read - that is what we
# used to do!
eval { $plist->read_list($output_file) };
my %pkgfile;
-# map filenames to package names
-for my $pkg ($plist->get_all) {
- my $entry = $plist->get($pkg);
- $pkgfile{$entry->{'file'}} = $pkg;
-}
+# map filenames to package keys (so we can look them up later)
+$plist->visit_all (sub {
+ my ($v, @k) = @_;
+ $pkgfile{$v->{'file'}} = \@k;
+});
# parse Packages file to get list of packages
my @packages_files;
@@ -113,7 +113,7 @@ foreach my $area (split /\s*,\s*/,$LINTIAN_AREA) {
}
my $total = 0;
-my %status_map;
+my @status_list;
foreach my $packages_file (@packages_files) {
my $pkgs_file = $packages_file->{'file'};
@@ -149,13 +149,14 @@ foreach my $packages_file (@packages_files) {
next;
}
my $timestamp = $stat[9];
- my ($status, $pkg, $data);
+ my ($status, $data);
+ my @keys;
# was package already included in last list?
if (exists $pkgfile{$deb_file}) {
# yes!
- $pkg = $pkgfile{$deb_file};
- $data = $plist->get($pkg);
+ @keys = @{ $pkgfile{$deb_file} };
+ $data = $plist->get (@keys);
# file changed since last run?
if ($timestamp == $data->{'timestamp'}) {
@@ -163,7 +164,7 @@ foreach my $packages_file (@packages_files) {
$status = 'unchanged';
} else {
$status = 'changed';
- $plist->delete($pkg);
+ $plist->delete (@keys);
}
} else {
# new package, get info
@@ -171,17 +172,9 @@ foreach my $packages_file (@packages_files) {
}
if (($status eq 'new') or ($status eq 'changed')) {
- $data = &safe_get_deb_info($deb_file);
+ $data = &safe_get_deb_info ($deb_file);
next if not defined $data;
- $pkg = $data->{'package'};
- }
-
- # Check for duplicates. In the case of a duplicate, we take the one
- # with the latest version.
- if ($nlist->get($pkg)) {
- if (versions_lte($data->{version}, $nlist->get($pkg)->{version})) {
- next;
- }
+ @keys = ($data->{'package'}, $data->{'version'}, $data->{'architecture'});
}
unless (exists $data->{'source-version'}) {
@@ -197,27 +190,25 @@ foreach my $packages_file (@packages_files) {
$data->{file} = $deb_file;
$data->{timestamp} = $timestamp;
$data->{area} = $packages_file->{area};
- $status_map{$pkg} = $status;
- $nlist->set($pkg, $data);
+ push @status_list, [$status, @keys];
+ $nlist->set ($data);
# remove record
- plist->delete($pkg) if $status eq 'unchanged';
+ plist->delete (@keys) if $status eq 'unchanged';
$total++;
}
close(IN) or fail("cannot close input pipe: $!");
}
$nlist->write_list($output_file);
-foreach my $pkg (sort $nlist->get_all) {
- printf "N: Listed %s $type package %s %s\n", $status_map{$pkg},
- $pkg, $nlist->get($pkg)->{version} if $verbose;
-}
if ($verbose) {
+ foreach my $status (@status_list) {
+ print "N: Listed %s $type package %s %s %s\n", @$status;
+ }
+
# All packages that are still included in $plist have disappeared
# from the archive.
- for my $pkg (sort $plist->get_all) {
- print "N: Removed $type package $pkg from list\n";
- }
+ $plist->visit_all (sub { print "N: Removed $type $_[1] $_[2] $_[3] from list\n" });
printf "N: Listed %d $type packages\n",$total;
}
diff --git a/unpack/list-srcpkg b/unpack/list-srcpkg
index ab710ad..1f6eb1a 100755
--- a/unpack/list-srcpkg
+++ b/unpack/list-srcpkg
@@ -23,7 +23,7 @@ use strict;
use warnings;
use lib "$ENV{'LINTIAN_ROOT'}/lib";
-use Lintian::Internal::PackageList;
+use Lintian::Lab::Manifest;
use Lintian::Relation::Version qw(versions_lte);
# turn file buffering off:
@@ -68,20 +68,20 @@ my $LINTIAN_LAB = $ENV{'LINTIAN_LAB'};
my $LINTIAN_AREA = $ENV{'LINTIAN_AREA'};
# read old list file (this command does nothing if the file does not exist)
-my $plist = Lintian::Internal::PackageList->new('source');
-my $nlist = Lintian::Internal::PackageList->new('source');
+my $plist = Lintian::Lab::Manifest->new ('source');
+my $nlist = Lintian::Lab::Manifest->new ('source');
# ignore the contents if the contents cannot be read - that is what we
# used to do!
eval { $plist->read_list($output_file) };
-my %status_map;
+my @status_list;
my %pkgfile;
-# map filenames to package names
-for my $pkg ($plist->get_all) {
- my $entry = $plist->get($pkg);
- $pkgfile{$entry->{'file'}} = $pkg;
-}
+# map filenames to package keys (so we can look them up later)
+$plist->visit_all (sub {
+ my ($v, @k) = @_;
+ $pkgfile{$v->{'file'}} = \@k;
+});
# parse Sources.gz to get list of packages
my @sources;
@@ -125,13 +125,14 @@ foreach my $sources (@sources) {
}
my $timestamp = $stat[9];
- my ($status,$pkg,$data);
+ my ($status,$data);
+ my @keys;
# was package already included in last list?
if (exists $pkgfile{$dsc_file}) {
# yes!
- $pkg = $pkgfile{$dsc_file};
- $data = $plist->get($pkg);
+ @keys = @{ $pkgfile{$dsc_file} };
+ $data = $plist->get (@keys);
# file changed since last run?
if ($timestamp == $data->{'timestamp'}) {
@@ -139,7 +140,7 @@ foreach my $sources (@sources) {
$status = 'unchanged';
} else {
$status = 'changed';
- $plist->delete($pkg);
+ $plist->delete (@keys);
}
} else {
# new package, get info
@@ -156,38 +157,21 @@ foreach my $sources (@sources) {
print "E: general: bad-source-package $dsc_file\n";
next;
}
- my @f = ();
- for my $fs (split(/\n/,$data->{'files'})) {
- next if $fs =~ /^\s*$/o;
- my @t = split(/\s+/o,$fs);
- push(@f,$t[2]);
- }
- $data->{'files'} = join(',',@f);
- $data->{'standards-version'} ||= '';
- $pkg = $data->{'source'};
- }
-
- # Check for duplicates. In the case of a duplicate, we take the one with
- # the latest version.
- if ($nlist->get($pkg)) {
- if (versions_lte($data->{version}, $nlist->get($pkg)->{version})) {
- next;
- }
+ @keys = ($data->{'source'}, $data->{'version'});
}
# Save entry for writing to output file.
$data->{file} = $dsc_file;
$data->{area} = $sources->{area};
$data->{timestamp} = $timestamp;
- for (qw(version maintainer uploaders architecture standards-version
- binary files)) {
+ for (qw(version maintainer uploaders binary)) {
$data->{$_} =~ tr/;\n/_ / if $data->{$_};
}
- $status_map{$pkg} = $status;
- $nlist->set($pkg, $data);
+ push @status_list, [$status, @keys];
+ $nlist->set ($data);
# remove record from hash
- $plist->delete($pkg) if $status eq 'unchanged';
+ $plist->delete (@keys) if $status eq 'unchanged';
$total++;
}
close(IN) or fail("cannot close input pipe: $!");
@@ -195,17 +179,14 @@ foreach my $sources (@sources) {
$nlist->write_list($output_file);
-foreach my $pkg (sort $nlist->get_all) {
- printf "N: Listed %s source package %s %s\n", $status_map{$pkg},
- $pkg, $nlist->get($pkg)->{version} if $verbose;
-}
-
if ($verbose) {
- # All packages that are still included in %source_info have disappeared from
- # the archive.
- for my $pkg (sort $plist->get_all) {
- print "N: Removed source package $pkg from list\n";
+ foreach my $status (@status_list) {
+ print "N: Listed %s source package %s %s\n", @$status;
}
+
+ # All packages that are still included in $plist have disappeared
+ # from the archive.
+ $plist->visit_all (sub { print "N: Removed source $_[1] $_[2] $_[3] from list\n" });
printf "N: Listed %d source packages\n",$total;
}
--
Debian package checker
Reply to: