[SCM] Debian package checker branch, master, updated. 2.5.0-rc2-122-g12888e8
The following commit has been merged in the master branch:
commit 75b003a292eeb5ff5d38e51fcf244df04cef5432
Author: Niels Thykier <niels@thykier.net>
Date: Tue Feb 22 15:50:47 2011 +0100
Processable support for multiple versions of same package
diff --git a/lib/Lintian/Processable.pm b/lib/Lintian/Processable.pm
index 006f8a0..babf8b9 100644
--- a/lib/Lintian/Processable.pm
+++ b/lib/Lintian/Processable.pm
@@ -77,7 +77,7 @@ sub new {
Returns the package name.
-=item $proc->pkg_version();
+=item $proc->pkg_version()
Returns the version of the package.
@@ -95,6 +95,14 @@ Returns the type of package (e.g. binary, source, udeb ...)
Returns the architecture(s) of the package. May return multiple values
from source and changes processables.
+=item $proc->pkg_src()
+
+Returns the name of the source package.
+
+=item $proc->pkg_src_version()
+
+Returns the version of the source package.
+
=item $proc->group()
Returns the L<Lintain::ProcessableGroup|group> $proc is in,
@@ -102,7 +110,7 @@ if any. If the processable is not in a group, this returns C<undef>.
=cut
-Lintian::Processable->mk_accessors (qw(pkg_name pkg_version pkg_src pkg_arch pkg_path pkg_type group));
+Lintian::Processable->mk_accessors (qw(pkg_name pkg_version pkg_src pkg_arch pkg_path pkg_type pkg_src_version group));
=pod
@@ -128,36 +136,47 @@ sub _init{
my $pkg_name = $dinfo->{package} or
fail "$pkg_path ($pkg_type) is missing mandatory \"Package\" field";
my $pkg_src = $dinfo->{source};
+ my $pkg_version = $dinfo->{version};
+ my $pkg_src_version = $pkg_version;
# Source may be left out if it is the same as $pkg_name
$pkg_src = $pkg_name unless ( defined $pkg_src && length $pkg_src );
# Source may contain the version (in parentheses)
- $pkg_src =~ s/\s*\(.+$//o;
+ if ($pkg_src =~ m/(\S++)\s*\(([^\)]+)\)/o){
+ $pkg_src = $1;
+ $pkg_src_version = $2;
+ }
$self->{pkg_name} = $pkg_name;
- $self->{pkg_version} = $dinfo->{version};
+ $self->{pkg_version} = $pkg_version;
$self->{pkg_arch} = $dinfo->{architecture};
$self->{pkg_src} = $pkg_src;
+ $self->{pkg_src_version} = $pkg_src_version;
} elsif ($pkg_type eq 'source'){
my $dinfo = get_dsc_info ($pkg_path) or fail "$pkg_path is not valid dsc file";
my $pkg_name = $dinfo->{source} or fail "$pkg_path is missing or has empty source field";
+ my $pkg_version = $dinfo->{version};
$self->{pkg_name} = $pkg_name;
- $self->{pkg_version} = $dinfo->{version};
+ $self->{pkg_version} = $pkg_version;
$self->{pkg_arch} = 'source';
$self->{pkg_src} = $pkg_name; # it is own source pkg
+ $self->{pkg_src_version} = $pkg_version;
} elsif ($pkg_type eq 'changes'){
my $cinfo = get_dsc_info ($pkg_path) or fail "$pkg_path is not a valid changes file";
my $pkg_name = $pkg_path;
- $pkg_name =~ s,.*/([^/]+)\.changes$,$1,;
+ my $pkg_version = $cinfo->{version};
+ $pkg_name =~ s,.*/([^/_]+)_[^/]+\.changes$,$1,;
$self->{pkg_name} = $pkg_name;
- $self->{pkg_version} = $cinfo->{version};
+ $self->{pkg_version} = $pkg_version;
$self->{pkg_src} = $cinfo->{source}//$pkg_name;
+ $self->{pkg_src_version} = $pkg_version;
$self->{pkg_arch} = $cinfo->{architecture};
} else {
fail "Unknown package type $pkg_type";
}
# make sure these are not undefined
- $self->{pkg_version} = '' unless (defined $self->{pkg_version});
- $self->{pkg_arch} = '' unless (defined $self->{pkg_arch});
+ $self->{pkg_version} = '' unless (defined $self->{pkg_version});
+ $self->{pkg_src_version} = '' unless (defined $self->{pkg_src_version});
+ $self->{pkg_arch} = '' unless (defined $self->{pkg_arch});
return 1;
}
diff --git a/private/processable-prototype.pl b/private/processable-prototype.pl
index 687b0cf..28a0bf8 100755
--- a/private/processable-prototype.pl
+++ b/private/processable-prototype.pl
@@ -33,6 +33,7 @@ foreach my $file (@ARGV) {
my $type;
my $proc;
my $tmap;
+ my $prockey;
$file = "$cwd/$file" unless ($file =~ m@^/@o);
if ($file =~ m/\.changes$/o){
@@ -42,7 +43,7 @@ foreach my $file (@ARGV) {
# get_processables
foreach my $gmember (@{$group->get_processables()}){
my $mtype = $gmember->pkg_type();
- my $mname = $gmember->pkg_name();
+ my $mname = gen_proc_key($gmember);
my $tmap = $type_map{$mtype};
if (exists $tmap->{$mname}){
if ($mtype eq 'changes'){
@@ -67,7 +68,7 @@ foreach my $file (@ARGV) {
#
# ... and for crafted packages we have more to worry about
# than suboptimal check accuracy.
- $group_map{$src_proc->pkg_src()} = $group;
+ $group_map{gen_src_proc_key($src_proc)} = $group;
next;
}
@@ -81,11 +82,12 @@ foreach my $file (@ARGV) {
fail "cannot handle $file";
}
$proc = Lintian::Processable->new($type, $file);
+ $prockey = gen_proc_key($proc);
$tmap = $type_map{$type};
- if (exists $tmap->{$proc->pkg_name()}){
- warning ("Skipping " . $proc->pkg_name() . " ($type) - duplicate package");
+ if (exists $tmap->{$prockey}){
+ warning ("Skipping " . $prockey . " ($type) - duplicate package");
} else {
- $tmap->{$proc->pkg_name()} = $proc;
+ $tmap->{$prockey} = $proc;
}
}
@@ -94,20 +96,20 @@ foreach my $file (@ARGV) {
foreach my $source (values %{ $type_map{'source'} }) {
my $group;
next if defined $source->group();
- print STDERR "Creating group for " . $source->pkg_src(), "\n";
+ debug(1, 'Creating group for ' . $source->pkg_src());
$group = Lintian::ProcessableGroup->new();
$group->add_processable($source);
- $group_map{$source->pkg_src()} = $group;
+ $group_map{gen_src_proc_key($source)} = $group;
}
foreach my $bin (values %{ $type_map{'binary'} }, values %{ $type_map{'udeb'} }){
- my $src_name = $bin->pkg_src();
- my $group = $group_map{$src_name};
+ my $src_key = gen_src_proc_key($bin);
+ my $group = $group_map{$src_key};
if (! defined $group){
# Create a new group based on the name of the source package
# - perhaps we will get more binaries from the same source.
$group = Lintian::ProcessableGroup->new();
- $group_map{$src_name} = $group;
+ $group_map{$src_key} = $group;
}
$group->add_processable($bin);
}
@@ -128,9 +130,8 @@ sub stringify_proc {
my ($proc) = @_;
my $pkg_name = $proc->pkg_name();
my $pkg_type = $proc->pkg_type();
- my $pkg_arch = $proc->pkg_arch();
my $pkg_version = $proc->pkg_version();
- return "${pkg_name} ($pkg_type)";
+ return "${pkg_name} $pkg_version ($pkg_type)";
}
sub debug {
@@ -144,3 +145,13 @@ sub warning {
print STDERR "$msg\n";
}
+sub gen_proc_key{
+ my ($proc) = @_;
+ return $proc->pkg_name() . '_' . $proc->pkg_version();
+}
+
+sub gen_src_proc_key{
+ my ($proc) = @_;
+ return $proc->pkg_src() . '_' . $proc->pkg_src_version();
+}
+
--
Debian package checker
Reply to: