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

[SCM] Debian package checker branch, master, updated. 2.2.2-24-g0beb00a



The following commit has been merged in the master branch:
commit 4a7782c12ac312f364eddb2f2fd6a6ea42bb2de7
Author: Russ Allbery <rra@debian.org>
Date:   Sat Feb 7 17:05:49 2009 -0800

    New Lintian::Collect methods for Lintian::Relation objects
    
    * lib/Lintian/Collect/Binary.pm:
      + [RA] New method relation() to return a Lintian::Relation object for
        a given relationship field or set of relationship fields.
    * lib/Lintian/Collect/Source.pm:
      + [RA] New methods relation() and relation_noarch() to return
        Lintian::Relation objects for a given build relationship field or
        set of fields.  New method binary_relation() to return a
        Lintian::Relation object for a given relationship field in a binary
        package built from this source package.

diff --git a/debian/changelog b/debian/changelog
index a95a7d5..dd27a82 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -56,6 +56,15 @@ lintian (2.2.3) UNRELEASED; urgency=low
   * lib/Lintian/Collect.pm:
     + [RA] Defer loading of the subclasses until the constructor to avoid
       circular dependencies at compilation time.
+  * lib/Lintian/Collect/Binary.pm:
+    + [RA] New method relation() to return a Lintian::Relation object for
+      a given relationship field or set of relationship fields.
+  * lib/Lintian/Collect/Source.pm:
+    + [RA] New methods relation() and relation_noarch() to return
+      Lintian::Relation objects for a given build relationship field or
+      set of fields.  New method binary_relation() to return a
+      Lintian::Relation object for a given relationship field in a binary
+      package built from this source package.
   * lib/Lintian/Relation.pm:
     + [RA] New class based on the existing Dep module that handles package
       relationship analysis.  Now includes documentation, uses a more
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index d847786..e054655 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -18,12 +18,14 @@
 # this program.  If not, see <http://www.gnu.org/licenses/>.
 
 package Lintian::Collect::Binary;
+
 use strict;
+use warnings;
+use base 'Lintian::Collect';
 
-use Lintian::Collect;
-use Util;
+use Carp qw(croak);
 
-our @ISA = qw(Lintian::Collect);
+use Util;
 
 # Initialize a new binary package collect object.  Takes the package name,
 # which is currently unused.
@@ -41,6 +43,7 @@ sub native {
     return $self->{native} if exists $self->{native};
     my $version = $self->field('version');
     $self->{native} = ($version !~ m/-/);
+    return $self->{native};
 }
 
 # Get the changelog file of a binary package as a Parse::DebianChangelog
@@ -249,6 +252,40 @@ sub objdump_info {
     return $self->{objdump_info};
 }
 
+# Return a Lintian::Relation object for the given relationship field.  In
+# addition to all the normal relationship fields, the following special
+# field names are supported: all (pre-depends, depends, recommends, and
+# suggests), strong (pre-depends and depends), and weak (recommends and
+# suggests).
+sub relation {
+    my ($self, $field) = @_;
+    $field = lc $field;
+    return $self->{relation}->{$field} if exists $self->{relation}->{$field};
+
+    my %special = (all    => [ qw(pre-depends depends recommends suggests) ],
+                   strong => [ qw(pre-depends depends) ],
+                   weak   => [ qw(recommends suggests) ]);
+    my $result;
+    if ($special{$field}) {
+        my $merged;
+        for my $f (@{ $special{$field} }) {
+            my $value = $self->field($f);
+            $merged .= ', ' if (defined($merged) and defined($value));
+            $merged .= $value if defined($value);
+        }
+        $result = $merged;
+    } else {
+        my %known = map { $_ => 1 }
+            qw(pre-depends depends recommends suggests enhances breaks
+               conflicts provides replaces);
+        croak("unknown relation field $field") unless $known{$field};
+        my $value = $self->field($field);
+        $result = $value if defined($value);
+    }
+    $self->{relation}->{$field} = Lintian::Relation->new($result);
+    return $self->{relation}->{$field};
+}
+
 =head1 NAME
 
 Lintian::Collect::Binary - Lintian interface to binary package data collection
@@ -358,13 +395,40 @@ directory contains.
 
 =back
 
+=item relation(FIELD)
+
+Returns a Lintian::Relation object for the specified FIELD, which should
+be one of the possible relationship fields of a Debian package or one of
+the following special values:
+
+=over 4
+
+=item all
+
+The concatenation of Pre-Depends, Depends, Recommends, and Suggests.
+
+=item strong
+
+The concatenation of Pre-Depends and Depends.
+
+=item weak
+
+The concatenation of Recommends and Suggests.
+
+=back
+
+If FIELD isn't present in the package, the returned Lintian::Relation
+object will be empty (always satisfied and implies nothing).
+
+=back
+
 =head1 AUTHOR
 
 Originally written by Frank Lichtenheld <djpig@debian.org> for Lintian.
 
 =head1 SEE ALSO
 
-lintian(1), Lintian::Collect(3)
+lintian(1), Lintian::Collect(3), Lintian::Relation(3)
 
 =cut
 
diff --git a/lib/Lintian/Collect/Source.pm b/lib/Lintian/Collect/Source.pm
index c7249d0..32c9e81 100644
--- a/lib/Lintian/Collect/Source.pm
+++ b/lib/Lintian/Collect/Source.pm
@@ -18,10 +18,13 @@
 # this program.  If not, see <http://www.gnu.org/licenses/>.
 
 package Lintian::Collect::Source;
+
 use strict;
+use warnings;
+use base 'Lintian::Collect';
 
-use Lintian::Collect;
 use Parse::DebianChangelog;
+
 use Util;
 
 our @ISA = qw(Lintian::Collect);
@@ -101,6 +104,102 @@ sub binary_field {
     return $self->{binary_field}{$package}{$field};
 }
 
+# Return a Lintian::Relation object for the given relationship field in a
+# binary package.  In addition to all the normal relationship fields, the
+# following special field names are supported:  all (pre-depends, depends,
+# recommends, and suggests), strong (pre-depends and depends), and weak
+# (recommends and suggests).
+sub binary_relation {
+    my ($self, $package, $field) = @_;
+    $field = lc $field;
+    return $self->{binary_relation}->{$package}->{$field}
+        if exists $self->{binary_relation}->{$package}->{$field};
+
+    my %special = (all    => [ qw(pre-depends depends recommends suggests) ],
+                   strong => [ qw(pre-depends depends) ],
+                   weak   => [ qw(recommends suggests) ]);
+    my $result;
+    if ($special{$field}) {
+        my $merged;
+        for my $f (@{ $special{$field} }) {
+            my $value = $self->binary_field($f);
+            $merged .= ', ' if (defined($merged) and defined($value));
+            $merged .= $value if defined($value);
+        }
+        $result = $merged;
+    } else {
+        my %known = map { $_ => 1 }
+            qw(pre-depends depends recommends suggests enhances breaks
+               conflicts provides replaces);
+        croak("unknown relation field $field") unless $known{$field};
+        my $value = $self->binary_field($field);
+        $result = $value if defined($value);
+    }
+    $result = Lintian::Relation->new($result);
+    $self->{binary_relation}->{$package}->{$field} = $result;
+    return $self->{binary_relation}->{$field};
+}
+
+# Return a Lintian::Relation object for the given build relationship
+# field.  In addition to all the normal build relationship fields, the
+# following special field names are supported:  build-depends-all
+# (build-depends and build-depends-indep) and build-conflicts-all
+# (build-conflicts and build-conflicts-indep).
+sub relation {
+    my ($self, $field) = @_;
+    $field = lc $field;
+    return $self->{relation}->{$field} if exists $self->{relation}->{$field};
+
+    my $result;
+    if ($field =~ /^build-(depends|conflicts)-all$/) {
+        my $type = $1;
+        my $merged;
+        for my $f ("build-$type", "build-$type-indep") {
+            my $value = $self->field($f);
+            $merged .= ', ' if (defined($merged) and defined($value));
+            $merged .= $value if defined($value);
+        }
+        $result = $merged;
+    } elsif ($field =~ /^build-(depends|conflicts)(-indep)?$/) {
+        my $value = $self->field($field);
+        $result = $value if defined($value);
+    } else {
+        croak("unknown relation field $field");
+    }
+    $self->{relation}->{$field} = Lintian::Relation->new($result);
+    return $self->{relation}->{$field};
+}
+
+# Similar to relation(), return a Lintian::Relation object for the given build
+# relationship field, but ignore architecture restrictions.  It supports the
+# same special field names.
+sub relation_noarch {
+    my ($self, $field) = @_;
+    $field = lc $field;
+    return $self->{relation_noarch}->{$field}
+        if exists $self->{relation_noarch}->{$field};
+
+    my $result;
+    if ($field =~ /^build-(depends|conflicts)-all$/) {
+        my $type = $1;
+        my $merged;
+        for my $f ("build-$type", "build-$type-indep") {
+            my $value = $self->field($f);
+            $merged .= ', ' if (defined($merged) and defined($value));
+            $merged .= $value if defined($value);
+        }
+        $result = $merged;
+    } elsif ($field =~ /^build-(depends|conflicts)(-indep)?$/) {
+        my $value = $self->field($field);
+        $result = $value if defined($value);
+    } else {
+        croak("unknown relation field $field");
+    }
+    $self->{relation_noarch}->{$field}
+        = Lintian::Relation->new_noarch($result);
+    return $self->{relation_noarch}->{$field};
+}
+
 =head1 NAME
 
 Lintian::Collect::Source - Lintian interface to source package data collection
@@ -161,6 +260,37 @@ 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_relation(PACKAGE, FIELD)
+
+Returns a Lintian::Relation object for the specified FIELD in the binary
+package PACKAGE in the F<debian/control> file.  FIELD should be one of the
+possible relationship fields of a Debian package or one of the following
+special values:
+
+=over 4
+
+=item all
+
+The concatenation of Pre-Depends, Depends, Recommends, and Suggests.
+
+=item strong
+
+The concatenation of Pre-Depends and Depends.
+
+=item weak
+
+The concatenation of Recommends and Suggests.
+
+=back
+
+If FIELD isn't present in the package, the returned Lintian::Relation
+object will be empty (always satisfied and implies nothing).
+
+Any substvars in F<debian/control> will be represented in the returned
+relation as packages named after the substvar.
+
+=back
+
 =item changelog()
 
 Returns the changelog of the source package as a Parse::DebianChangelog
@@ -172,6 +302,32 @@ file, which this method expects to find in F<debfiles/changelog>.
 
 Returns true if the source package is native and false otherwise.
 
+=item relation(FIELD)
+
+Returns a Lintian::Relation object for the given build relationship field
+FIELD.  In addition to the normal build relationship fields, the
+following special field names are supported:
+
+=over 4
+
+=item build-depends-all
+
+The concatenation of Build-Depends and Build-Depends-Indep.
+
+=item build-conflicts-all
+
+The concatenation of Build-Conflicts and Build-Conflicts-Indep.
+
+=back
+
+If FIELD isn't present in the package, the returned Lintian::Relation
+object will be empty (always satisfied and implies nothing).
+
+=item relation_noarch(FIELD)
+
+The same as relation(), but ignores architecture restrictions in the
+FIELD field.
+
 =back
 
 =head1 AUTHOR
@@ -180,7 +336,7 @@ Originally written by Russ Allbery <rra@debian.org> for Lintian.
 
 =head1 SEE ALSO
 
-lintian(1), Lintian::Collect(3)
+lintian(1), Lintian::Collect(3), Lintian::Relation(3)
 
 =cut
 

-- 
Debian package checker


Reply to: