Bug#460174: [PATCH 3/3] Push to Lintian::data checking of rules
Push to an external data the checking of required/recommended rule.
---
checks/rules.pm | 37 ++++++++++++++-----------------------
data/rules/policy-rules | 15 +++++++++++++++
2 files changed, 29 insertions(+), 23 deletions(-)
create mode 100644 data/rules/policy-rules
diff --git a/checks/rules.pm b/checks/rules.pm
index e27bc34..21fc8f1 100644
--- a/checks/rules.pm
+++ b/checks/rules.pm
@@ -34,6 +34,7 @@ our $ANYPYTHON_DEPEND
my $KNOWN_MAKEFILES = Lintian::Data->new('rules/known-makefiles', '\|\|');
my $DEPRECATED_MAKEFILES = Lintian::Data->new('rules/deprecated-makefiles');
+our $POLICYRULES = Lintian::Data->new('rules/policy-rules', qr/\s++/);
# Certain build tools must be listed in Build-Depends even if there are no
# arch-specific packages because they're required in order to run the clean
@@ -94,17 +95,6 @@ my @RULE_CLEAN_DEPENDS =(
[quilt => qr'^\t\s*(\S+=\S+\s+)*quilt\s'],
);
-# The following targets are required per Policy.
-my %required = map { $_ => 'required' } qw(build binary binary-arch binary-indep clean);
-
-# The following targets are recommended per Policy.
-my %recommendedbuild = map { $_ => 'recommended_allindep' } qw(build-arch build-indep);
-
-my %goodpracticedfsg = map { $_ => 'goodpractice_dfsg' } qw(get-orig-source);
-
-# The following rules are required or recommended per policy
-my %policyrules = ( %required, %recommendedbuild, %goodpracticedfsg);
-
# Rules about required debhelper command ordering. Each command is put into a
# class and the tag is issued if they're called in the wrong order for the
# classes. Unknown commands won't trigger this flag.
@@ -176,7 +166,7 @@ sub run {
my $targets = $KNOWN_MAKEFILES->value($makefile);
if (defined $targets){
foreach my $target (split m/\s*+,\s*+/o, $targets){
- $seen{$target}++ if $policyrules{$target};
+ $seen{$target}++ if $POLICYRULES->known($target);
}
} else {
$includes = 1;
@@ -265,13 +255,13 @@ sub run {
# we ought to "delay" it was a "=" variable rather
# than ":=" or "+=".
for (split m/\s++/o, rstrip($val)) {
- $seen{$_}++ if $policyrules{$_};
+ $seen{$_}++ if $POLICYRULES->known($_);
}
last;
}
# We don't know, so just mark the target as seen.
}
- $seen{$_}++ if $policyrules{$_};
+ $seen{$_}++ if $POLICYRULES->known($_);
}
next; #.PHONY implies the rest will not match
}
@@ -288,8 +278,8 @@ sub run {
if ($target =~ m/%/o) {
my $pattern = quotemeta $target;
$pattern =~ s/\\%/.*/g;
- for my $policyrules (keys %policyrules) {
- $seen{$policyrules}++ if $policyrules =~ m/$pattern/;
+ foreach(my $rulebypolicy = $POLICYRULES->all) {
+ $seen{$rulebypolicy}++ if $rulebypolicy =~ m/$pattern/;
}
} else {
# Is it $(VAR) ?
@@ -302,13 +292,13 @@ sub run {
# than ":=" or "+=".
local $_;
for (split m/\s++/o, rstrip($val)) {
- $seen{$_}++ if $policyrules{$_};
+ $seen{$_}++ if $POLICYRULES->known($_);
}
last;
}
# We don't know, so just mark the target as seen.
}
- $seen{$target}++ if $policyrules{$target};
+ $seen{$target}++ if $POLICYRULES->known($target);
}
if (any { $target =~ /$_/ } @arch_rules) {
push(@arch_rules, @depends);
@@ -366,19 +356,20 @@ sub run {
unless ($includes) {
my $rec_allindep = 0;
# Make sure all the required rules were seen.
- for my $target (sort keys %policyrules) {
+ foreach my $target ($POLICYRULES->all) {
unless ($seen{$target}) {
- if($policyrules{$target} eq 'required') {
+ my $typerule = $POLICYRULES->value($target);
+ if($typerule eq 'required') {
tag 'debian-rules-missing-required-target', $target;
- } elsif ($policyrules{$target} eq 'recommended_allindep') {
+ } elsif ($typerule eq 'recommended_allindep') {
tag 'debian-rules-missing-recommended-target', $target;
$rec_allindep++;
- } elsif ($policyrules{$target} eq 'goodpractice_dfsg') {
+ } elsif ($typerule eq 'goodpractice_dfsg') {
if ($version =~ /(dfsg|debian|ds)/) {
tag 'debian-rules-missing-good-practice-target-dfsg', $target;
}
} else {
- croak 'unknown type of policy rules';
+ croak 'unknown type of policy rules: '.($typerule || '""');
}
}
}
diff --git a/data/rules/policy-rules b/data/rules/policy-rules
new file mode 100644
index 0000000..80072f3
--- /dev/null
+++ b/data/rules/policy-rules
@@ -0,0 +1,15 @@
+# add required/recommended rules
+# format is
+# name-of-rules type
+# with type is:
+# - required for required rules
+# - recommended_allindep for recommended rules that will benefit for spliting in all/indep variant
+# - goodpractice_dfsg for recommended rules for non dfsg package
+build required
+binary required
+binary-arch required
+binary-indep required
+clean required
+build-arch recommended_allindep
+build-indep recommended_allindep
+get-orig-source goodpractice_dfsg
--
1.7.10.4
Reply to: