[SCM] Debian package checker branch, master, updated. 2.5.10-204-g4ea22d8
The following commit has been merged in the master branch:
commit 4ea22d8186ed774fb6e5858bfe67bd14e8cec0fa
Author: Niels Thykier <niels@thykier.net>
Date: Mon Oct 15 15:03:25 2012 +0200
L::Profile: Allow checks to be symlinks
Gracefully handle checks that are a symlink to a check with a
different name. Lintian does not enforce that the "loaded-via" name
matches the name in the desc file.
In case these did not match it would in some cases lead to "use of
undefined value" errors.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/lib/Lintian/Profile.pm b/lib/Lintian/Profile.pm
index 81f2d8d..ed5787f 100644
--- a/lib/Lintian/Profile.pm
+++ b/lib/Lintian/Profile.pm
@@ -510,21 +510,36 @@ sub _load_check {
}
}
croak "$profile references unknown $check" unless defined $desc;
- $self->_parse_check ($desc);
+ $self->_parse_check ($desc, $check);
}
sub _parse_check {
- my ($self, $desc) = @_;
+ my ($self, $desc, $gcname) = @_;
+ # Have we already tried to load this before? Possibly via an alias
+ # or symlink
+ return $self->{'check-scripts'}->{$gcname}
+ if exists $self->{'check-scripts'}->{$gcname};
+
my $c = Lintian::CheckScript->new ($desc);
- return if $self->{'check-scripts'}->{$c->name};
- $self->{'check-scripts'}->{$c->name} = $c;
+ my $cname = $c->name;
+ if (exists $self->{'check-scripts'}->{$cname}) {
+ # We have loaded the check under a different name
+ $c = $self->{'check-scripts'}->{$cname};
+ # Record the alias so we don't have to parse the check file again.
+ $self->{'check-scripts'}->{$gcname} = $c;
+ return $c;
+ }
+ $self->{'check-scripts'}->{$cname} = $c;
+ $self->{'check-scripts'}->{$gcname} = $c if $gcname ne $cname;
+
for my $tn ($c->tags) {
if ($self->{'known-tags'}->{$tn}) {
my $ocn = $self->{'known-tags'}->{$tn}->script;
- croak $c->name . " redefined tag $tn which was defined by $ocn";
+ croak "$cname redefined tag $tn which was defined by $ocn";
}
$self->{'known-tags'}->{$tn} = $c->get_tag ($tn);
}
+ return $c;
}
sub _load_checks {
@@ -533,9 +548,10 @@ sub _load_checks {
next unless -d $checkdir;
opendir my $dirfd, $checkdir or croak "opendir $checkdir: $!";
for my $desc (sort readdir $dirfd) {
- next unless $desc =~ m/\.desc$/o;
+ my $cname = $desc;
+ next unless $cname =~ s/\.desc$//o;
# _parse_check ignores duplicates, so we don't have to check for it.
- $self->_parse_check ("$checkdir/$desc");
+ $self->_parse_check ("$checkdir/$desc", $cname);
}
closedir $dirfd;
}
--
Debian package checker
Reply to: