[SCM] Debian package checker branch, master, updated. 2.5.9-27-g9e61a25
The following commit has been merged in the master branch:
commit 3a57854c9e50857e1874796885a9e0886e977fe8
Author: Niels Thykier <niels@thykier.net>
Date: Wed Jun 27 15:21:58 2012 +0200
L::Processable: Add method to return an identifier
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/lib/Lintian/Lab/Entry.pm b/lib/Lintian/Lab/Entry.pm
index 3fe7453..9083e90 100644
--- a/lib/Lintian/Lab/Entry.pm
+++ b/lib/Lintian/Lab/Entry.pm
@@ -128,6 +128,7 @@ sub _new {
$self->_init();
+ $self->_make_identifier;
return $self;
}
diff --git a/lib/Lintian/Processable.pm b/lib/Lintian/Processable.pm
index 153d240..e63c768 100644
--- a/lib/Lintian/Processable.pm
+++ b/lib/Lintian/Processable.pm
@@ -72,9 +72,23 @@ sub new {
$self->{pkg_type} = $pkg_type;
$self->{tainted} = 0;
$self->_init ($pkg_type, @args);
+ $self->_make_identifier unless exists $self->{identifier};
return $self;
}
+sub _make_identifier {
+ my ($self) = @_;
+ my $pkg_type = $self->pkg_type;
+ my $pkg_name = $self->pkg_name;
+ my $pkg_version = $self->pkg_version;
+ my $pkg_arch = $self->pkg_arch;
+ my $id = "$pkg_type:$pkg_name/$pkg_version";
+ if ($pkg_type ne 'source' and $pkg_type ne 'changes') {
+ $id .= "/$pkg_arch";
+ }
+ $self->{identifier} = $id;
+}
+
=item $proc->pkg_name()
@@ -114,9 +128,14 @@ Returns a truth value if one or more fields in this Processable is
tainted. On a best effort basis tainted fields will be sanitized
to less dangerous (but possibly invalid) values.
+=item $proc->identifier
+
+Proceduces an identifier for this processable. The identifier is
+based on the type, name, version and architecture of the package.
+
=cut
-Lintian::Processable->mk_ro_accessors (qw(pkg_name pkg_version pkg_src pkg_arch pkg_path pkg_type pkg_src_version tainted));
+Lintian::Processable->mk_ro_accessors (qw(pkg_name pkg_version pkg_src pkg_arch pkg_path pkg_type pkg_src_version tainted identifier));
=item $proc->group([$group])
diff --git a/lib/Lintian/ProcessableGroup.pm b/lib/Lintian/ProcessableGroup.pm
index b4ae876..d127f5f 100644
--- a/lib/Lintian/ProcessableGroup.pm
+++ b/lib/Lintian/ProcessableGroup.pm
@@ -166,9 +166,7 @@ sub add_processable{
$self->{source} = $processable;
} else {
my $phash;
- my $name = $processable->pkg_name;
- my $version = $processable->pkg_version;
- my $arch = $processable->pkg_arch;
+ my $id = $processable->identifier;
fail "Unknown type $pkg_type"
unless ($pkg_type eq 'binary' or $pkg_type eq 'udeb');
$phash = $self->{$pkg_type};
@@ -177,8 +175,8 @@ sub add_processable{
$self->{$pkg_type} = $phash;
}
# duplicate ?
- return 0 if (exists $phash->{"${name}_${version}_${arch}"});
- $phash->{"${name}_${version}_${arch}"} = $processable;
+ return 0 if (exists $phash->{$id});
+ $phash->{$id} = $processable;
}
$processable->group($self);
return 1;
@@ -240,10 +238,8 @@ sub remove_processable {
delete $self->{$pkg_type};
} elsif (defined $self->{$pkg_type}) {
my $phash = $self->{$pkg_type};
- my $name = $proc->pkg_name();
- my $version = $proc->pkg_version();
- my $arch = $proc->pkg_arch();
- delete $phash->{"${name}_${version}_${arch}"};
+ my $id = $proc->identifier;
+ delete $phash->{$id};
}
return 1;
}
--
Debian package checker
Reply to: