[SCM] Debian package checker branch, master, updated. 2.5.10-139-g186bdd5
The following commit has been merged in the master branch:
commit 5f2907449ffd08e5f2a2dbc0301706d0f1d56ae1
Author: Niels Thykier <niels@thykier.net>
Date: Thu Sep 13 15:15:44 2012 +0200
L::Unpacker: Use the profile better to reduce work
At the same time replace "requested" with "extra-coll" as "requested"
and pack extra arguments to the L::Unpacker constructor in a optional
hashref.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/frontend/lintian b/frontend/lintian
index bd1967a..5fd9fef 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -124,7 +124,8 @@ my $LAB;
my %keep_coll;
my %collection_info;
my %check_abbrev;
-my %requested_unpack;
+my %extra_unpack;
+my %unpack_options;
# Timer handling (by default to nothing)
my $start_timer = sub { 0; };
@@ -1039,23 +1040,18 @@ undef $map;
# {{{ determine which info is needed by the collection scripts
if ($action eq 'check') {
- # determine which info is needed by the checks
- for my $c (@scripts) {
- my $cs = $PROFILE->get_script($c);
- for my $i ($cs->needs_info) {
- $requested_unpack{$i} = 1;
- }
- }
# For overrides we need "overrride-file" as well
unless ($opt{'no-override'}) {
- $requested_unpack{'override-file'} = 1;
+ $extra_unpack{'override-file'} = 1;
}
-
+ # For checking, pass a profile to the unpacker to limit what it
+ # unpacks.
+ $unpack_options{'profile'} = $PROFILE;
+ $unpack_options{'extra-coll'} = \%extra_unpack;
} else {
- # With --unpack we want all of it
- for my $c (keys %collection_info) {
- $requested_unpack{$c} = 1;
- }
+ # With --unpack we want all of them. That's the default so,
+ # "done!"
+ 1;
}
if (@unpack_info) {
@@ -1064,7 +1060,7 @@ if (@unpack_info) {
unless ($collection_info{$i}) {
fail("unknown info specified: $i");
}
- $requested_unpack{$i} = 1;
+ $extra_unpack{$i} = 1;
$keep_coll{$i} = 1;
}
}
@@ -1074,10 +1070,11 @@ if (@unpack_info) {
# {{{ Okay, now really processing the packages in one huge loop
$opt{'jobs'} = default_parallel() unless defined $opt{'jobs'};
+$unpack_options{'jobs'} = $opt{'jobs'};
debug_msg(1,
"Selected action: $action",
- sprintf('Requested data to collect: %s', join(',',sort keys %requested_unpack)),
+ sprintf('Extra data to collect: %s', join(',',sort keys %extra_unpack)),
sprintf('Selected checks: %s', join(',',sort $PROFILE->scripts)),
"Parallization limit: $opt{'jobs'}",
);
@@ -1086,7 +1083,7 @@ debug_msg(1,
# Now action is always either "check" or "unpack"
# these two variables are used by process_package
# and need to persist between invocations.
-my $unpacker = Lintian::Unpacker->new ($collmap, \%requested_unpack, $opt{'jobs'});
+my $unpacker = Lintian::Unpacker->new ($collmap, \%unpack_options);
my %overrides;
foreach my $gname (sort $pool->get_group_names()) {
diff --git a/lib/Lintian/Unpacker.pm b/lib/Lintian/Unpacker.pm
index b2d9617..4aa0e5f 100644
--- a/lib/Lintian/Unpacker.pm
+++ b/lib/Lintian/Unpacker.pm
@@ -71,7 +71,7 @@ available via L<Lintian::Collect>.
=over 4
-=item new (COLLMAP, REQUESTED[, JOBLIMIT])
+=item new (COLLMAP, PROFILE[, OPTIONS])
Creates a new unpacker.
@@ -79,45 +79,72 @@ COLLMAP is a L<Lintian::DepMap::Properties> decribing the dependencies
between the collections. Each node in COLLMAP must have a
L<Lintian::CollScript> as property.
-REQUESTED is either, C<undef> a reference to a hash table or a
-L<Lintian::Profile>. If it is a hash table reference, then the values
-are ignored. The keys are considered names of the requested
-collections.
+OPTIONS is an optional hashref containing optional configurations. If
+a key is not present, its value is assumed to be C<undef> unless
+otherwise stated. The following key/values are available:
-If REQUESTED is a Lintian::Profile, then all collections needed for
-the I<enabled> checks will be considered the requested collections.
+=over 4
+
+=item "profile"
+
+If this key is present and its value is defined, the value must be
+L<Lintian::Profile>. The unpacker will use the enabled checks of the
+Profile to determine what collections to use.
+
+If "profile" is not present or its value is undefined, then all
+collections in COLLMAP will be unpacked.
+
+=item "extra-coll"
+
+If this key is present and its value is defined, it must be a
+reference to a hash table. The keys are considered names of "extra"
+collections to unpack. The values in this table is ignored.
+
+Extra collections will be unpacked on top of other collections.
-If REQUESTED is C<undef> then every collection mentioned in COLLMAP is
-considered "required".
+NB: This value is ignored if "profile" is not given.
-For existing entries, as few collections as possible will be
-processed. The collections mentioned in REQUESTED are considered
-the "minimum requirement".
+=item "jobs"
-JOBLIMIT is the max number of jobs to be run in parallel. Can be
-changed with the L</jobs> method later.
+This value is the max number of jobs to be run in parallel. Can be
+changed with the L</jobs> method later. If omitted, it defaults to
+0. Refer to L</jobs> for more info.
+
+=back
=cut
sub new {
- my ($class, $collmap, $requested, $jobs) = @_;
+ my ($class, $collmap, $options) = @_;
my $ccmap = $collmap->clone;
- my $req_table = $requested;
- $jobs //= 0;
+ my $req_table = undef;
+ my $profile = undef;
+ my $extra = undef;
+ my $jobs = 0;
+ if ($options) {
+ $extra = $options->{'extra-coll'} if exists $options->{'extra-coll'};
+ $profile = $options->{'profile'} if exists $options->{'profile'};
+ $jobs = $options->{'jobs'} if exists $options->{'jobs'};
+ }
my $self = {
'collmap' => $ccmap,
'jobs' => $jobs,
+ 'profile' => $profile,
'running-jobs' => {},
'worktable' => {},
};
- if (defined $requested && blessed $requested &&
- $requested->isa ('Lintian::Profile')) {
+ if (defined $profile) {
$req_table = {};
- foreach my $cname ($requested->scripts) {
- my $check = $requested->get_script ($cname);
+ foreach my $cname ($profile->scripts) {
+ my $check = $profile->get_script ($cname);
$req_table->{$_} = 1 for $check->needs_info;
}
+ if ($extra) {
+ foreach my $ecoll (keys %$extra) {
+ $req_table->{$ecoll} = 1;
+ }
+ }
}
if (defined $req_table) {
# For new entries we take everything in the collmap, which is
@@ -144,7 +171,7 @@ sub new {
fail "Inconsistent collmap after deletion"
if $ccmap->missing;
}
- $self->{'requested'} = $req_table;
+ $self->{'extra-coll'} = $extra;
# Initialise our copy
$ccmap->initialise;
@@ -188,7 +215,8 @@ or manually.
sub prepare_tasks {
my ($self, $errorhandler, @lpkgs) = @_;
my $collmap = $self->{'collmap'};
- my $requested = $self->{'requested'};
+ my $extra = $self->{'extra-coll'};
+ my $profile = $self->{'profile'};
my %worklists = ();
foreach my $lpkg (@lpkgs) {
my $changed = 0;
@@ -200,8 +228,19 @@ sub prepare_tasks {
my %need = ();
my @check;
my $pkg_type = $lpkg->pkg_type;
- @check = keys %$requested if defined $requested;
- @check = keys $collmap->known unless defined $requested;
+ if ($profile) {
+ my %tmp = ();
+ foreach my $cname ($profile->scripts) {
+ my $check = $profile->get_script ($cname);
+ next unless $check->is_check_type ($pkg_type);
+ $tmp{$_} = 1 for $check->needs_info;
+ }
+ @check = keys %tmp;
+ push @check, grep { ! exists $tmp{$_} } keys %$extra
+ if defined $extra;
+ } else {
+ @check = keys $collmap->known;
+ }
while (my $cname = pop @check) {
my $coll = $collmap->getp ($cname);
# Skip collections not relevant to us (they will never
--
Debian package checker
Reply to: