summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Dumont <dod@debian.org>2021-10-17 16:55:31 +0200
committerDominique Dumont <dod@debian.org>2021-10-17 17:01:22 +0200
commit388fb392d2d8698a9e8278641e742d21a72c2c78 (patch)
tree556f5fff25dfbf5e024db44ad53982a28310884e
parent6109904275a4d8e5639eed687bea8c127ab6fb3d (diff)
Lintian checker: fix parsing of lintian tag
Closes: 996697 DpkgSyntax parser provided with Config::Model is not used because: - it's implemented as a role tied that uses Config::Model exceptions - the returned data structure is slightly more complex than the one returned by Parse::DebControl
-rw-r--r--lib/Config/Model/Dpkg/Lintian/Overrides.pm24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Config/Model/Dpkg/Lintian/Overrides.pm b/lib/Config/Model/Dpkg/Lintian/Overrides.pm
index ad9cfa62..6ec0944b 100644
--- a/lib/Config/Model/Dpkg/Lintian/Overrides.pm
+++ b/lib/Config/Model/Dpkg/Lintian/Overrides.pm
@@ -5,6 +5,8 @@ use warnings;
use Mouse;
use Path::Tiny;
use Log::Log4perl qw(get_logger :levels);
+use Parse::DebControl;
+
use 5.20.1;
extends qw/Config::Model::Value/ ;
@@ -22,23 +24,23 @@ my %tags;
my %renames;
my $tag_dir = path('/usr/share/lintian/tags');
+my $parser = Parse::DebControl->new;
if ($tag_dir->is_dir) {
$tag_dir->visit(
sub {
my ($path, $state) = @_;
- return unless $path->basename('.tag');
- my $tag;
- foreach my $line ($path->lines) {
- if ($line =~ /^Tag:\s+([\w-]+)/) {
- $tag = $1;
- $tags{$1}=1;
- }
- if ($line =~ /^Renamed-From:\s+([\w-]+)/) {
- warn "Got Renamed-From without tag in file $path" unless defined $tag;
- $renames{$1}=$tag;
+ return unless $path =~ /\.tag$/;
+
+ my $data = $parser->parse_file($path->stringify, {stripComments => 1});
+ my $hash = $data->[0];
+ $tags{ $hash->{Tag} }=1;
+
+ if ($hash->{'Renamed-From'}) {
+ my @rnf = grep { /\w/} split /[\s\n]+/, $hash->{'Renamed-From'};
+ foreach my $old_name ( @rnf ) {
+ $renames{$old_name} = $hash->{Tag};
}
- last if $line =~ /^Explanation:/;
}
},
{ recurse => 1 }