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

[SCM] Debian package checker branch, master, updated. 2.2.0-27-gae9eeae



The following commit has been merged in the master branch:
commit 76b6d6a4ded5c1a00685651b389e499a41e3bf3d
Author: Russ Allbery <rra@debian.org>
Date:   Sat Jan 31 10:34:10 2009 -0800

    Add binary_field() to Lintian::Collect::Source
    
    * lib/Lintian/Collect/Source.pm:
      + [RA] Add binary_field() method to return a binary package field from
        debian/control for a source package.  Based on a patch by Raphael
        Geissert.
      + [RA] Rewrite the binaries() method to use binary_field().  Based on
        a patch by Raphael Geissert.

diff --git a/debian/changelog b/debian/changelog
index 2184727..baa9663 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -21,6 +21,12 @@ lintian (2.2.1) UNRELEASED; urgency=low
     + [RA] Provide details on how to manually check some of the shared
       library problems that Lintian diagnoses.  (Closes: #513086)
 
+  * lib/Lintian/Collect/Source.pm:
+    + [RA] Add binary_field() method to return a binary package field from
+      debian/control for a source package.  Based on a patch by Raphael
+      Geissert.
+    + [RA] Rewrite the binaries() method to use binary_field().  Based on
+      a patch by Raphael Geissert.
   * lib/Lintian/Output.pm:
     + [ADB] Add a colour for pedantic tags to avoid warnings when colourised
       output is used and make the combination more useful.  Thanks, gregor
diff --git a/debian/copyright b/debian/copyright
index 008f23a..50c36e1 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -40,7 +40,7 @@ Portions Copyright (C) 2006 Adeodato Simó
 Portions Copyright (C) 2007-2009 Russ Allbery
 Portions Copyright (C) 2008 Patrick Schoenfeld
 Portions Copyright (C) 2008 Niko Tyni
-Portions Copyright (C) 2008 Raphael Geissert
+Portions Copyright (C) 2008-2009 Raphael Geissert
 Portions Copyright (C) 2008-2009 Adam D. Barratt
 
 This program is free software; you may redistribute it and/or modify
diff --git a/lib/Lintian/Collect/Source.pm b/lib/Lintian/Collect/Source.pm
index 4a7d6c2..97c3c8d 100644
--- a/lib/Lintian/Collect/Source.pm
+++ b/lib/Lintian/Collect/Source.pm
@@ -2,6 +2,7 @@
 # Lintian::Collect::Source -- interface to source package data collection
 
 # Copyright (C) 2008 Russ Allbery
+# Copyright (C) 2009 Raphael Geissert
 #
 # 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
@@ -67,35 +68,39 @@ sub native {
     return $self->{native};
 }
 
-# List of binary packages and their type if specified
+# Returns a hash of binaries to the package type, assuming a type of deb
+# unless the package type field is present.
 sub binaries {
     my ($self) = @_;
     return $self->{binaries} if exists $self->{binaries};
-
-    my %pkgs;
-    opendir(BINPKGS, 'control')
-        or fail("Can't open control directory.");
-    while (my $binpkg = readdir(BINPKGS)) {
+    my %binaries;
+    opendir(BINPKGS, 'control') or fail("can't open control directory: $!");
+    for my $package (readdir BINPKGS) {
         next if $binpkg =~ /^\.\.?$/;
-        if (-d "control/$binpkg") {
-            if (open TYPE, "<", "control/$binpkg/xc-package-type") {
-                my $type = <TYPE> || '';
-                chomp $type;
-                $type = lc $type;
-                $pkgs{$binpkg} = $type || 'deb';
-                close TYPE;
-            } else {
-                $pkgs{$binpkg} = 'deb';
-            }
-        }
+        my $type = $self->binary_field($package, 'xc-package-type') || 'deb';
+        $binaries{$package} = lc $type;
     }
     closedir BINPKGS;
-
-    $self->{binaries} = \%pkgs;
-
+    $self->{binaries} = \%binaries;
     return $self->{binaries};
 }
 
+# Returns the value of a control field for a binary package or the empty
+# string if that control field isn't present.  This does not implement
+# inheritance from the settings in the source stanza.
+sub binary_field {
+    my ($self, $package, $field) = @_;
+    return $self->{binary_field}{$package}{$field}
+        if exists $self->{binary_field}{$package}{$field};
+    my $value = '';
+    if (-f "control/$package/$field") {
+        $value = slurp_entire_file("control/$package/$field");
+        chomp $value;
+    }
+    $self->{binary_field}{$package}{$field} = $value;
+    return $self->{binary_field}{$package}{$field};
+}
+
 =head1 NAME
 
 Lintian::Collect::Source - Lintian interface to source package data collection
@@ -137,6 +142,25 @@ documented in the Lintian::Collect module are also available.
 
 =over 4
 
+=item binaries()
+
+Returns a hash reference with the binary package names as keys and the
+Package-Type as value (which should be either C<deb> or C<udeb>
+currently).  The source-control-file collection script must have been run
+to parse the F<debian/control> file and put the fields in the F<control>
+directory in the lab.
+
+=item binary_field(PACKAGE, FIELD)
+
+Returns the content of the field FIELD for the binary package PACKAGE in
+the F<debian/control> file, or an empty string if that field isn't set.
+Inheritance of field values from the source section of the control file is
+not implemented.  Only the literal value of the field is returned.
+
+The source-control-file collection script must have been run to parse the
+F<debian/control> file and put the fields in the F<control> directory in
+the lab.
+
 =item changelog()
 
 Returns the changelog of the source package as a Parse::DebianChangelog
@@ -148,11 +172,6 @@ file, which this method expects to find in F<debfiles/changelog>.
 
 Returns true if the source package is native and false otherwise.
 
-=item binaries()
-
-Returns a hash reference with the binary package names as keys and the
-Package-Type as value (which should be either 'deb' or 'udeb' currently).
-
 =back
 
 =head1 AUTHOR

-- 
Debian package checker


Reply to: