[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-148-gc51662b
The following commit has been merged in the lab-refactor branch:
commit c51662b34335c135c8543943d2bf2792256730f5
Author: Niels Thykier <niels@thykier.net>
Date: Thu Oct 27 14:39:21 2011 +0200
Extended html_reports log regex and used Lab to access manifests
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/lib/Lintian/Lab.pm b/lib/Lintian/Lab.pm
index 2753368..810a99d 100644
--- a/lib/Lintian/Lab.pm
+++ b/lib/Lintian/Lab.pm
@@ -294,6 +294,28 @@ sub get_package {
return wantarray ? @entries : $entries[0];
}
+# Non-API method used by reporting to look up the manifest data via the Lab
+# rather than bypassing it.
+sub _get_lab_manifest_data {
+ my ($self, $pkg_name, $pkg_type, @keys) = @_;
+ my $index = $self->_get_lab_index ($pkg_type);
+ if (scalar @keys >= 2 || (scalar @keys >= 1 && $pkg_type eq 'source')) {
+ # All we need to know
+ return $index->get ($pkg_name, @keys);
+ } else {
+ # Time to guess (or hope)
+ my @result = ();
+ my $searcher = sub {
+ my ($v) = @_;
+ push @result, $v;
+ }; # end searcher
+ $index->visit_all ($searcher, $pkg_name, @keys);
+ return $result[0] if @result;
+ }
+ # Nothing so far, then it does not exists
+ return;
+}
+
# Returns the index of packages in the lab of a given type (of packages).
#
# Unlike $lab->_load_lab_index, this uses the cache'd version if it is
diff --git a/reporting/html_reports b/reporting/html_reports
index b8ad6aa..cbdd594 100755
--- a/reporting/html_reports
+++ b/reporting/html_reports
@@ -50,6 +50,7 @@ $ENV{'LINTIAN_ROOT'} = $LINTIAN_ROOT;
# Import Lintian Perl libraries.
use lib "$ENV{LINTIAN_ROOT}/lib";
+use Lintian::Lab;
use Lintian::Tag::Info ();
use Lintian::Lab::Manifest;
use Text_utils;
@@ -106,22 +107,12 @@ for my $template (qw/head foot clean index maintainer maintainers packages tag
# Read the package lists.
#
-my $binary_info = Lintian::Lab::Manifest->new ('binary');
-my $udeb_info = Lintian::Lab::Manifest->new ('udeb');
+my $LAB = Lintian::Lab->new ($LINTIAN_LAB);
my $source_info = Lintian::Lab::Manifest->new ('source');
-my %bin_src_ref;
-$binary_info->read_list("$LINTIAN_LAB/info/binary-packages");
-$udeb_info->read_list("$LINTIAN_LAB/info/udeb-packages");
+$LAB->open_lab;
$source_info->read_list("$LINTIAN_LAB/info/source-packages");
-$source_info->visit_all (sub {
- my ($entry) = @_;
- my $source = $entry->{'source'};
- foreach my $binary (split m/\s*,\s*+/o, $entry->{'binary'}) {
- $bin_src_ref{$binary} = $source;
- }
-});
# Create output directories.
mkdir($HTML_TMP_DIR, 0777)
@@ -208,10 +199,24 @@ my (%by_maint, %by_uploader, %by_tag);
# just assume that the second maintainer is the same as the first (but warn
# about it).
my (%seen, %saw_maintainer);
+
+# Matches something like: (1:2.0-3) [arch1 arch2]
+# - captures the version and the architectures
+my $verarchre = qr,(?: \s* \(( [^)]++ )\) \s* \[ ( [^]]++ ) \]),xo;
+# ^^^^^^^^ ^^^^^^^^^^^^
+# ( version ) [architecture ]
+
+# matches the full deal:
+# 1 222 3333 4444444 5555 666 777
+# - T: pkg type (version) [arch]: tag [...]
+# ^^^^^^^^^^^^^^^^^^^^^
+# Where the marked part(s) are optional values. The numbers above the example
+# are the capture groups.
+my $fullre = qr/([EWIXOP]): (\S+)(?: (\S+)(?:$verarchre)?)?: (\S+)(?:\s+(.*))?/o;
while (<>) {
chomp;
- next unless m/^([EWIXOP]): (\S+)(?: (\S+))?: (\S+)(?:\s+(.*))?/;
- my ($code, $package, $type, $tag, $extra) = ($1, $2, $3, $4, $5);
+ next unless m/^$fullre/o;
+ my ($code, $package, $type, $pver, $parch, $tag, $extra) = ($1, $2, $3, $4, $5, $6, $7);
$type = 'binary' unless (defined $type);
$extra = '' unless (defined $extra);
next unless ($type eq 'source' || $type eq 'binary' || $type eq 'udeb');
@@ -237,44 +242,41 @@ while (<>) {
# pulling information from a binary package or udeb of the same name if
# there is any.
my ($source, $version, $area, $source_version, $maintainer, $uploaders);
+ my $pkg_data = $LAB->_get_lab_manifest_data ($package, $type, $pver, $parch);
if ($type eq 'source') {
- my $srcdata;
- $source_info->visit_all (sub { $srcdata = $_[0] });
$source = $package;
- if (defined $srcdata) {
- $version = $srcdata->{version};
- $area = $srcdata->{area};
- $maintainer = $srcdata->{maintainer};
- $uploaders = $srcdata->{uploaders};
+ if (defined $pkg_data) {
+ $source_version = $version = $pkg_data->{version};
+ $area = $pkg_data->{area};
+ $maintainer = $pkg_data->{maintainer};
+ $uploaders = $pkg_data->{uploaders};
} else {
warn "source package $package not listed!\n";
+ $source_version = $version = $pver;
}
} else {
- my $srcdata;
- my $bindata;
- $source = $bin_src_ref{$package};
- $source_info->visit_all (sub { $srcdata = $_[0] }) if $source;
- if (defined $srcdata) {
- $maintainer = $srcdata->{maintainer};
- $uploaders = $srcdata->{uploaders};
+ my $src_data;
+ if (defined $pkg_data) {
+ $version = $pkg_data->{version};
+ $area = $pkg_data->{area};
+ $source = $pkg_data->{source}//$package;
+ $source_version = $pkg_data->{'source-version'}//$version;
+ $src_data = $LAB->_get_lab_manifest_data ($source, 'source', $source_version);
} else {
- warn "source for package $package not found!\n";
- $source = $package;
- $maintainer = undef;
+ $version = $pver;
}
- if ($type eq 'binary') {
- $binary_info->visit_all (sub { $bindata = $_[0] });
- } elsif ($type eq 'udeb') {
- $udeb_info->visit_all (sub { $bindata = $_[0] });
+ if (defined $src_data) {
+ $maintainer = $src_data->{maintainer};
+ $uploaders = $src_data->{uploaders};
} else {
- fail "Unknown type or unhandled case ($type).\n";
+ warn "source for package $package not found!\n";
+ $maintainer = undef;
+ $uploaders = undef;
}
- $version = $bindata->{version};
- $area = $bindata->{area};
- $source_version = $bindata->{'source-version'};
}
$maintainer ||= '(unknown)';
$area ||= 'main';
+ $source ||= '';
$version = 'unknown'
unless (defined ($version) and length ($version) > 0);
$source_version = $version
--
Debian package checker
Reply to: