[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-93-gdeeb4f2
The following commit has been merged in the lab-refactor branch:
commit deeb4f289f9d391ce3887e5adc10df0ada8de8d7
Author: Niels Thykier <niels@thykier.net>
Date: Sun Oct 2 17:56:46 2011 +0200
Re-add support "remove package from lab"
Admittedly it is broken, since the Lab does not update its state
files when a new entry is added. But with this, the removal code
is there and will work when the Lab is fixed.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/frontend/lintian b/frontend/lintian
index 3aa11d4..f5a0f40 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -940,6 +940,7 @@ while (my $arg = shift) {
# special case: search only in lab if action is `remove'
my $search;
+ my @res;
if ($action eq 'remove') {
# search only in lab--see below
$search = 'lab';
@@ -976,49 +977,33 @@ while (my $arg = shift) {
# nothing found so far, so search the lab
- # FIXME: needs "remove by name"
-
- my $b = "$opt{'LINTIAN_LAB'}/binary/$arg";
- my $s = "$opt{'LINTIAN_LAB'}/source/$arg";
- my $u = "$opt{'LINTIAN_LAB'}/udeb/$arg";
+ if ($pkg_mode eq 'b' or $pkg_mode eq 'a') {
+ my @pkgs = $LAB->get_package ($arg, 'binary');
+ push @res, @pkgs;
+ }
+ if ($pkg_mode eq 's' or $pkg_mode eq 'a') {
+ my @pkgs = $LAB->get_package ($arg, 'source');
+ push @res, @pkgs;
+ }
+ if ($pkg_mode eq 'u' or $pkg_mode eq 'a') {
+ my @pkgs = $LAB->get_package ($arg, 'udeb');
+ push @res, @pkgs;
+ }
+ if ($pkg_mode eq 'c' or $pkg_mode eq 'a') {
+ my @pkgs = $LAB->get_package ($arg, 'changes');
+ push @res, @pkgs;
+ }
- if ($pkg_mode eq 'b') {
- unless (-d $b) {
- warn "error: cannot find binary package $arg in $search (skipping)\n";
- $exit_code = 2;
- next;
- }
- } elsif ($pkg_mode eq 's') {
- unless (-d $s) {
- warning("cannot find source package $arg in $search (skipping)");
- $exit_code = 2;
- next;
- }
- } elsif ($pkg_mode eq 'u') {
- unless (-d $u) {
- warning("cannot find udeb package $arg in $search (skipping)");
- $exit_code = 2;
- next;
+ if (@res) {
+ foreach my $p (@res) {
+ $pool->add_proc ($p);
}
} else {
- # $pkg_mode eq 'a'
- unless (-d $b or -d $s or -d $u) {
- warning("cannot find binary, udeb or source package $arg in $search (skipping)");
- $exit_code = 2;
- next;
- }
+ warning("cannot find binary, udeb or source package $arg in $search (skipping)");
+ $exit_code = 2;
+ next;
}
- # FIXME: Use Lab to find the deb/dsc instead?
- if (($pkg_mode eq 'b') or (($pkg_mode eq 'a') and (-d $b))) {
- $pool->add_file("$b/deb");
- }
- if (($pkg_mode eq 's') or (($pkg_mode eq 'a') and (-d $s))) {
- $pool->add_file("$s/dsc");
- }
- if (($pkg_mode eq 'u') or (($pkg_mode eq 'a') and (-d $u))) {
- $pool->add_file("$u/deb");
- }
}
}
diff --git a/lib/Lintian/ProcessablePool.pm b/lib/Lintian/ProcessablePool.pm
index 179428b..c0c8c90 100644
--- a/lib/Lintian/ProcessablePool.pm
+++ b/lib/Lintian/ProcessablePool.pm
@@ -22,6 +22,8 @@ package Lintian::ProcessablePool;
use strict;
use warnings;
+use Carp qw(croak);
+
use Cwd();
use Util;
@@ -73,45 +75,60 @@ processables from the same source package (if any).
sub add_file {
my ($self, $file) = @_;
- my ($pkg_path, $pkg_type, $tmap, $proc, $procid);
- my ($group, $groupid);
- fail "$file does not exist" unless -e $file;
- $pkg_path = Cwd::abs_path($file);
+ my ($pkg_path, $pkg_type, $proc, $procid);
+ croak "$file does not exist" unless -e $file;
+ $pkg_path = Cwd::abs_path ($file);
if ($pkg_path =~ m/\.changes$/o){
- return $self->_add_changes_file($pkg_path);
+ return $self->_add_changes_file ($pkg_path);
}
- if ($pkg_path =~ m/\.dsc$/o){
+ if ($pkg_path =~ m/\.dsc$/o) {
$pkg_type = 'source';
- } elsif ($pkg_path =~ m/\.deb$/o){
+ } elsif ($pkg_path =~ m/\.deb$/o) {
$pkg_type = 'binary';
- } elsif ($pkg_path =~ m/\.udeb$/o){
+ } elsif ($pkg_path =~ m/\.udeb$/o) {
$pkg_type = 'udeb';
} else {
- fail "$pkg_path is not a known type of package.";
+ croak "$pkg_path is not a known type of package.";
}
- # Just insert these for now.
- $tmap = $self->{$pkg_type};
- $proc = Lintian::Processable::Package->new($pkg_type, $pkg_path);
- if ($proc->tainted()){
- warn(sprintf("warning: tainted %1\$s package '%2\$s', skipping\n",
- $pkg_type, $proc->pkg_name()));
+
+ $proc = Lintian::Processable::Package->new ($pkg_type, $pkg_path);
+ return $self->add_proc ($proc);
+}
+
+=item $pool->add_proc ($proc)
+
+Adds a L<Lintian::Processable|processable> to the pool.
+
+=cut
+
+sub add_proc {
+ my ($self, $proc) = @_;
+ my $procid;
+ my ($group, $groupid);
+ my $pkg_type = $proc->pkg_type;
+ my $tmap = $self->{$pkg_type};
+
+
+ if ($proc->tainted) {
+ warn (sprintf ("warning: tainted %1\$s package '%2\$s', skipping\n",
+ $pkg_type, $proc->pkg_name));
return 0;
}
- $procid = $self->_get_proc_id($proc);
+ $procid = $self->_get_proc_id ($proc);
return 0 if exists $tmap->{$procid};
- $groupid = $self->_get_group_id($proc);
+ $groupid = $self->_get_group_id ($proc);
$group = $self->{groups}->{$groupid};
if (defined $group){
if ($pkg_type eq 'source'){
# if this is a source pkg, then this is a duplicate
# assuming the group already has a source package.
- return 0 if (defined($group->get_source_processable()));
+ return 0 if defined $group->get_source_processable;
}
# else add the binary/udeb proc to the group
- return $group->add_processable($proc);
+ return $group->add_processable ($proc);
} else {
# Create a new group
- $group = Lintian::ProcessableGroup->new();
+ $group = Lintian::ProcessableGroup->new;
$group->add_processable($proc);
$self->{groups}->{$groupid} = $group;
}
--
Debian package checker
Reply to: