[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.10-171-g2531823



The following commit has been merged in the master branch:
commit 253182324bc2aec1a8bf9e93263412c97e8f8a65
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Sep 27 20:27:51 2012 +0200

    L::C::Source: Split binaries into two methods
    
    Split "binaries" into a method returning the list of binaries and
    another for querying the package type of those binaries.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/control-file b/checks/control-file
index 6e8f89c..3081d98 100644
--- a/checks/control-file
+++ b/checks/control-file
@@ -99,7 +99,7 @@ if ($@) {
     return;
 }
 
-my @package_names = sort keys %{ $info->binaries };
+my @package_names = sort $info->binaries;
 
 foreach my $bin (@package_names) {
     my $bfields = $info->binary_field ($bin);
@@ -214,7 +214,7 @@ foreach my $bin (@package_names) {
     # Accumulate the description.
     my $desc = $info->binary_field ($bin, 'description');
     my $bin_area;
-    if ($desc and $info->binaries->{$bin} ne 'udeb') {
+    if ($desc and $info->binary_package_type ($bin) ne 'udeb') {
         push @descriptions, [ $bin, split("\n", $desc, 2) ];
     }
 
diff --git a/checks/copyright-file b/checks/copyright-file
index 9c6a66b..51cb61f 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -312,8 +312,7 @@ sub check_cross_link {
     my $src = $group->get_source_processable();
     if ( $src ) {
         # source package is available; check it's list of binary
-        my $bin = $src->info->binaries;
-        return if $bin->{$fpkg};
+        return if defined $src->info->binary_package_type ($fpkg);
         tag 'usr-share-doc-symlink-to-foreign-package', $fpkg;
     } else {
         # The source package is not available, but the binary could
diff --git a/checks/debhelper b/checks/debhelper
index 9d5bc61..18451f2 100644
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -217,11 +217,11 @@ unless ($inclcdbs){
 
 return unless $seencommand;
 
-my $pkgs = $info->binaries;
-my $single_pkg = keys(%$pkgs) == 1 ? $pkgs->{(keys(%$pkgs))[0]} : '';
+my @pkgs = $info->binaries;
+my $single_pkg = scalar @pkgs == 1 ? $info->binary_package_type ($pkgs[0]) : '';
 
-for my $binpkg (keys %$pkgs) {
-    next if $pkgs->{$binpkg} ne 'deb';
+for my $binpkg (@pkgs) {
+    next if $info->binary_package_type ($binpkg) ne 'deb';
     my $strong = $info->binary_relation ($binpkg, 'strong');
     my $all = $info->binary_relation ($binpkg, 'all');
 
@@ -307,8 +307,9 @@ foreach my $file (sort readdir(DEBIAN)) {
         }
         close IN;
         if (!$seentag) {
-            unless (($binpkg && exists($pkgs->{$binpkg})
-                     && ($pkgs->{$binpkg} eq 'udeb'))
+            my $binpkg_type = $info->binary_package_type ($binpkg);
+            unless (($binpkg && defined $binpkg_type
+                     && ($binpkg_type eq 'udeb'))
                     or (!$binpkg && ($single_pkg eq 'udeb'))) {
                 tag 'maintainer-script-lacks-debhelper-token', "debian/$file";
             }
@@ -444,7 +445,7 @@ if ($seen_python_helper == -1 and $level >= 9) {
 }
 if ($seen_dh and $seen_python_helper != 1) {
     my %python_depends = ();
-    for my $binpkg (keys %$pkgs) {
+    for my $binpkg (@pkgs) {
         if ($info->binary_relation($binpkg, 'all')->implies('${python:Depends}')) {
             $python_depends{$binpkg} = 1;
         }
@@ -460,7 +461,7 @@ if ($seen_dh and $seen_python_helper != 1) {
 }
 if ($seen_dh and $seen_python3_helper != 1) {
     my %python3_depends = ();
-    for my $binpkg (keys %$pkgs) {
+    for my $binpkg (@pkgs) {
         if ($info->binary_relation($binpkg, 'all')->implies('${python3:Depends}')) {
             $python3_depends{$binpkg} = 1;
         }
diff --git a/checks/fields b/checks/fields
index 2f537f3..3804a00 100644
--- a/checks/fields
+++ b/checks/fields
@@ -732,12 +732,12 @@ if (($type eq 'binary') || ($type eq 'udeb')) {
 
 if ($type eq 'source') {
 
-    my $binpkgs = $info->binaries;
+    my @binpkgs = $info->binaries;
 
     #Get number of arch-indep packages:
     my $arch_indep_packages = 0;
     my $arch_dep_packages = 0;
-    foreach my $binpkg (keys %$binpkgs) {
+    foreach my $binpkg (@binpkgs) {
         my $arch = $info->binary_field($binpkg, 'architecture', '');
         if ($arch eq 'all') {
             $arch_indep_packages++;
@@ -851,7 +851,7 @@ if ($type eq 'source') {
     }
 
     my (@arch_dep_pkgs, @dbg_pkgs);
-    foreach my $binpkg (keys %$binpkgs) {
+    foreach my $binpkg (@binpkgs) {
         if ($binpkg =~ m/-dbg$/) {
             push @dbg_pkgs, $binpkg;
         } elsif ($info->binary_field ($binpkg, 'architecture', '') ne 'all') {
diff --git a/checks/source-copyright b/checks/source-copyright
index 6804335..4c57c9b 100644
--- a/checks/source-copyright
+++ b/checks/source-copyright
@@ -51,14 +51,14 @@ if (-l $copyright_filename) {
 }
 
 if (not -f $copyright_filename) {
-    my $pkgs = $info->binaries;
+    my @pkgs = $info->binaries;
     tag 'no-debian-copyright';
     $copyright_filename = undef;
-    if (keys(%$pkgs) == 1) {
+    if (scalar @pkgs == 1) {
         # If debian/copyright doesn't exist, and the only a single binary
         # package is built, there's a good chance that the copyright file is
         # available as debian/<pkgname>.copyright.
-        $copyright_filename = $info->debfiles((keys(%$pkgs))[0] . '.copyright');
+        $copyright_filename = $info->debfiles ($pkgs[0] . '.copyright');
         if (not -f $copyright_filename or -l $copyright_filename) {
             $copyright_filename = undef;
         }
diff --git a/checks/standards-version b/checks/standards-version
index ebd54dd..2a7fb87 100644
--- a/checks/standards-version
+++ b/checks/standards-version
@@ -25,6 +25,7 @@ use strict;
 use warnings;
 
 use POSIX qw(strftime);
+use List::Util qw(first);
 use Date::Parse qw(str2time);
 
 use Lintian::Data;
@@ -57,14 +58,10 @@ my (undef, undef, $info) = @_;
 # udebs aren't required to conform to policy, so they don't need
 # Standards-Version. (If they have it, though, it should be valid.)
 my $version = $info->field('standards-version');
-my $pkgs = $info->binaries;
 my $all_udeb = 1;
-foreach my $bin_type (values %$pkgs) {
-    if ($bin_type ne 'udeb') {
-        $all_udeb = 0;
-        last;
-    }
-}
+$all_udeb = 0
+     if first { $info->binary_package_type ($_) ne 'udeb' } $info->binaries;
+
 if (not defined $version) {
     tag 'no-standards-version-field' unless $all_udeb;
     return 0;
diff --git a/checks/version-substvars b/checks/version-substvars
index cc5c3ae..7a1141f 100644
--- a/checks/version-substvars
+++ b/checks/version-substvars
@@ -45,11 +45,9 @@ sub run {
 
 my (undef, undef, $info) = @_;
 
-my $binpkgs = $info->binaries;
-
 my @dep_fields = qw(depends pre-depends recommends suggests conflicts replaces);
 
-foreach my $pkg1 (sort keys %$binpkgs) {
+foreach my $pkg1 (sort $info->binaries) {
     my ($pkg1_is_any, $pkg2, $pkg2_is_any, $substvar_strips_binNMU);
 
     $pkg1_is_any = ($info->binary_field($pkg1, 'architecture', '') ne 'all');
diff --git a/lib/Lintian/Collect/Source.pm b/lib/Lintian/Collect/Source.pm
index d05fb8a..592a45d 100644
--- a/lib/Lintian/Collect/Source.pm
+++ b/lib/Lintian/Collect/Source.pm
@@ -173,17 +173,39 @@ sub native {
 
 =item binaries
 
-Returns a hash reference with the binary package names as keys and the
-(X-)Package-Type as value (which should be either C<deb> or C<udeb>
-currently).  The debfiles collection script must have been run to make
-the F<debfiles/control> file available.
+Returns a list of the binary and udeb packages listed in the
+F<debian/control>.
 
 =cut
 
-# sub binaries Needs-Info :binary_field
+# sub binaries Needs-Info :binary_package_type
 sub binaries {
     my ($self) = @_;
-    return $self->{binaries} if exists $self->{binaries};
+    # binary_package_type does all the work for us.
+    $self->binary_package_type ('') unless exists $self->{binaries};
+    return keys %{ $self->{binaries} };
+}
+
+=item binary_package_type (BINARY)
+
+Returns package type based on value of the Package-Type (or if absent,
+X-Package-Type) field.  If the field is omitted, the default value
+"deb" is used.
+
+If the BINARY is not a binary listed in the source packages
+F<debian/control> file, this method return C<undef>.
+
+=cut
+
+# sub binary_package_type Needs-Info :binary_field
+
+sub binary_package_type {
+    my ($self, $binary) = @_;
+    if (exists $self->{binaries}) {
+        return $self->{binaries}->{$binary}
+            if exists $self->{binaries}->{$binary};
+        return;
+    }
     # we need the binary fields for this.
     $self->_load_dctrl unless exists $self->{binary_field};
 
@@ -195,7 +217,8 @@ sub binaries {
     }
 
     $self->{binaries} = \%binaries;
-    return $self->{binaries};
+    return $binaries{$binary} if exists $binaries{$binary};
+    return;
 }
 
 =item source_field([FIELD[, DEFAULT]])

-- 
Debian package checker


Reply to: