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

[SCM] Debian package checker branch, master, updated. 2.5.10-178-g33ece45



The following commit has been merged in the master branch:
commit dad2f0f4b07906ab97b75486e094933c048f1183
Author: Niels Thykier <niels@thykier.net>
Date:   Wed Sep 26 21:43:11 2012 +0200

    L::Unpacker/CollScript: Support optional collection dependencies
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/lib/Lintian/CollScript.pm b/lib/Lintian/CollScript.pm
index fb77e74..8f90f39 100644
--- a/lib/Lintian/CollScript.pm
+++ b/lib/Lintian/CollScript.pm
@@ -163,10 +163,33 @@ Lintian::CollScript->mk_ro_accessors (qw(name type version auto_remove
 Returns a list of all items listed in the Needs-Info field.  Neither
 the list nor its contents should be modified.
 
+COND is optional and used to determine what conditions are true.  If
+omitted, all "extra" dependencies are returned.  Otherwise, only the
+dependencies required by COND are included.  COND is a hashref and
+with the following key/values:
+
+=over 4
+
+=item type
+
+The value is a package type that determines which package type is
+being unpacked.  This is used to determine if the condition for
+"<dep> [<type>]" relations are true or not.
+
+=back
+
 =cut
 
 sub needs_info {
     my ($self, $cond) = @_;
+    if ($cond && exists $cond->{'type'}) {
+        my $needs = $self->{'needs_info'};
+        my @min = @{ $needs->{'min'} };
+        my $type = $cond->{'type'};
+        push @min, @{ $needs->{'type'}->{$type} }
+            if exists $needs->{'type'}->{$type};
+        return @min;
+    }
     return @{ $self->{'needs_info'}->{'max'} };
 }
 
diff --git a/lib/Lintian/Unpacker.pm b/lib/Lintian/Unpacker.pm
index 3f9b3d5..5241e2f 100644
--- a/lib/Lintian/Unpacker.pm
+++ b/lib/Lintian/Unpacker.pm
@@ -128,6 +128,7 @@ sub new {
         $jobs = $options->{'jobs'} if exists $options->{'jobs'};
     }
     my $self = {
+        'cache' => {},
         'collmap' => $ccmap,
         'jobs' => $jobs,
         'profile' => $profile,
@@ -266,15 +267,38 @@ sub prepare_tasks {
     return 1;
 }
 
+sub _gen_type_coll {
+    my ($self, $pkg_type) = @_;
+    my $collmap = $self->{'collmap'};
+    my $cmap = Lintian::DepMap::Properties->new;
+    my $cond = { 'type' => $pkg_type };
+
+    foreach my $node ($collmap->known) {
+        my $coll = $collmap->getp ($node);
+        $cmap->add ($node, $coll->needs_info ($cond), $coll);
+    }
+
+    $cmap->initialise;
+
+    $self->{'cache'}->{$pkg_type} = $cmap;
+    return $cmap->clone;
+}
+
 sub _requested_colls {
     my ($self, $lpkg, $new) = @_;
     my $profile = $self->{'profile'};
-    my $cmap = $self->{'collmap'}->clone;
+    my $cmap;
     my $extra = $self->{'extra-coll'};
     my $pkg_type = $lpkg->pkg_type;
     my %needed = ();
     my @check;
 
+    unless (exists $self->{'cache'}->{$pkg_type}) {
+        $cmap = $self->_gen_type_coll ($pkg_type);
+    } else {
+        $cmap = $self->{'cache'}->{$pkg_type}->clone;
+    }
+
     # if its new and $profile is undef, we have to run all
     # of collections.  So lets extra early.
     return ($cmap, undef) if $new and not $profile;

-- 
Debian package checker


Reply to: