[lintian] 01/01: Check for override_dh_clean targets that are missing calls to dh_clean. Thanks to Andreas Beckmann for the idea. (Closes: #884817)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit edd65158f2b8f02760cd2c5ef377b0e04188fb3f
Author: Chris Lamb <lamby@debian.org>
Date: Wed Dec 20 17:19:48 2017 +0000
Check for override_dh_clean targets that are missing calls to dh_clean. Thanks to Andreas Beckmann for the idea. (Closes: #884817)
---
checks/rules.desc | 11 +++++++++++
checks/rules.pm | 11 +++++++++--
debian/changelog | 3 +++
.../debian/debian/rules | 8 ++++++++
.../rules-override-dh-clean-does-not-call-dh-clean-unrel/desc | 5 +++++
.../rules-override-dh-clean-does-not-call-dh-clean-unrel/tags | 0
.../debian/debian/rules | 7 +++++++
t/tests/rules-override-dh-clean-does-not-call-dh-clean/desc | 5 +++++
t/tests/rules-override-dh-clean-does-not-call-dh-clean/tags | 1 +
9 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/checks/rules.desc b/checks/rules.desc
index 483d0d4..86b57fe 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -282,3 +282,14 @@ Info: The <tt>debian/rules</tt> file for this package appears to set
<tt>noopt</tt>.
.
This has been obsoleted in favour of <tt>dpkg-buildflags</tt>.
+
+Tag: override_dh_clean-does-not-call-dh_clean
+Severity: normal
+Certainty: certain
+Info: The <tt>debian/rules</tt> file for this package uses
+ the <tt>override_dh_clean</tt> but this target does not reference
+ <tt>dh_clean</tt>. This can result in packages not cleaning up properly via
+ <tt>debian/rules clean</tt>.
+ .
+ Please add a call to <tt>dh_clean</tt>.
+Ref: #884419, #884815
diff --git a/checks/rules.pm b/checks/rules.pm
index cf34465..5c0754b 100644
--- a/checks/rules.pm
+++ b/checks/rules.pm
@@ -19,7 +19,7 @@ use warnings;
use autodie;
use Carp qw(croak);
-use List::MoreUtils qw(any);
+use List::MoreUtils qw(any none);
use Lintian::Data;
use Lintian::Tags qw(tag);
@@ -165,7 +165,7 @@ sub run {
my @arch_rules = (qr/^clean$/, qr/^binary-arch$/, qr/^build-arch$/);
my @indep_rules = (qr/^build$/, qr/^build-indep$/, qr/^binary-indep$/);
my (@current_targets, %rules_per_target, %debhelper_group);
- my %seen;
+ my (%seen, %overridden);
my $maybe_skipping;
my %variables;
my $uses_makefile_pl = 0;
@@ -308,6 +308,7 @@ sub run {
qr/^$_$/;
} split(' ', $target_dependencies);
for my $target (@current_targets) {
+ $overridden{$1}++ if $target =~ m/override_(.+)/;
if ($target =~ m/%/o) {
my $pattern = quotemeta $target;
$pattern =~ s/\\%/.*/g;
@@ -425,6 +426,12 @@ sub run {
tag 'binary-arch-rules-but-pkg-is-arch-indep' if $nonempty;
}
+ tag 'override_dh_clean-does-not-call-dh_clean'
+ if (
+ $overridden{'dh_clean'}
+ and none { m/^\t\s*-?dh_clean\b/ }
+ @{$rules_per_target{'override_dh_clean'}});
+
# Make sure that all the required build dependencies are there. Don't
# issue missing-build-dependency errors for debhelper, since there's
# another test that does that and it would just be a duplicate.
diff --git a/debian/changelog b/debian/changelog
index b73da40..331a40c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,9 @@ lintian (2.5.66) UNRELEASED; urgency=medium
+ [CL] Warn about Python 2.x packages using ${python3:Depends} and
Python 3.x packages using ${python:Depends}. Thanks to Mattia
Rizzolo for the idea. (Closes: #884676)
+ * checks/rules.{desc,pm}:
+ + [CL] Check for override_dh_clean targets that are missing calls to
+ dh_clean. Thanks to Andreas Beckmann for the idea. (Closes: #884817)
* checks/standards-version.pm:
+ [CL] Avoid misleading tag descriptions when emitting valid
timewarp-standards-version warnings if the date parts are identical
diff --git a/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/debian/debian/rules b/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/debian/debian/rules
new file mode 100755
index 0000000..3236e08
--- /dev/null
+++ b/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/debian/debian/rules
@@ -0,0 +1,8 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@
+
+override_dh_clean:
+ true
+ dh_clean # This rule is a false positive
diff --git a/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/desc b/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/desc
new file mode 100644
index 0000000..b89e55e
--- /dev/null
+++ b/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/desc
@@ -0,0 +1,5 @@
+Testname: rules-override-dh-clean-does-not-call-dh-clean-unrel
+Version: 1.0
+Description: Test for missing calls to dh_clean in override_dh_clean (false positive)
+Test-Against:
+ override_dh_clean-does-not-call-dh_clean
diff --git a/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/tags b/t/tests/rules-override-dh-clean-does-not-call-dh-clean-unrel/tags
new file mode 100644
index 0000000..e69de29
diff --git a/t/tests/rules-override-dh-clean-does-not-call-dh-clean/debian/debian/rules b/t/tests/rules-override-dh-clean-does-not-call-dh-clean/debian/debian/rules
new file mode 100755
index 0000000..b3cb63d
--- /dev/null
+++ b/t/tests/rules-override-dh-clean-does-not-call-dh-clean/debian/debian/rules
@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@
+
+# Empty target
+override_dh_clean:
diff --git a/t/tests/rules-override-dh-clean-does-not-call-dh-clean/desc b/t/tests/rules-override-dh-clean-does-not-call-dh-clean/desc
new file mode 100644
index 0000000..0900e2c
--- /dev/null
+++ b/t/tests/rules-override-dh-clean-does-not-call-dh-clean/desc
@@ -0,0 +1,5 @@
+Testname: rules-override-dh-clean-does-not-call-dh-clean
+Version: 1.0
+Description: Test for missing calls to dh_clean in override_dh_clean
+Test-For:
+ override_dh_clean-does-not-call-dh_clean
diff --git a/t/tests/rules-override-dh-clean-does-not-call-dh-clean/tags b/t/tests/rules-override-dh-clean-does-not-call-dh-clean/tags
new file mode 100644
index 0000000..57015b2
--- /dev/null
+++ b/t/tests/rules-override-dh-clean-does-not-call-dh-clean/tags
@@ -0,0 +1 @@
+W: rules-override-dh-clean-does-not-call-dh-clean source: override_dh_clean-does-not-call-dh_clean
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: