[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#885790: Add DH_EXTRA_ADDON check



Package: lintian
Severity: wishlist
Tags: patch
thanks

I wrote a small patch to check for any use of DH_EXTRA_ADDON in a
rules file. This may not be needed, but I figured i'd write to to
ensure I help try and address some of the feedback regarding usage of
this flag in Debian itself.

If this isn't going to trigger enough to be useful, feel free to close wontfix!

  Paul




-- 
:wq
From 8f5da088eb9e5e3f83af6bab32eaf3bef5807813 Mon Sep 17 00:00:00 2001
From: Paul Tagliamonte <tag@pault.ag>
Date: Fri, 29 Dec 2017 16:32:13 -0500
Subject: [PATCH] Add a check for DH_EXTRA_ADDON usage in rules files

The DH_EXTRA_ADDON environment variable was added to debhelper
for local and/or downstream use. Use in a rules file is almost
universally wrong, and a massive anti-pattern. The --with argument
should be used in it's place.
---
 checks/rules.desc                         | 7 +++++++
 data/rules/rules-should-not-use           | 2 +-
 t/tests/rules-general/debian/debian/rules | 1 +
 t/tests/rules-general/desc                | 3 ++-
 t/tests/rules-general/tags                | 7 ++++---
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/checks/rules.desc b/checks/rules.desc
index 48a5b65b9..d4b134574 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -117,6 +117,13 @@ Info: The standard environment variable for build options is
  DEB_BUILD_OPTIONS.  Usually, referring to DEB_BUILD_OPTS is a mistake and
  DEB_BUILD_OPTIONS was intended instead.
 
+Tag: debian-rules-should-not-use-DH_EXTRA_ADDONS
+Severity: normal
+Certainty: certain
+Info: DH_EXTRA_ADDONS is designed for local or downstream build use, not for
+ use in debian/rules.  This is almost always a mistake, and the --with
+ argument needs to be used instead.
+
 Tag: debian-rules-should-not-automatically-update-control
 Severity: serious
 Certainty: possible
diff --git a/data/rules/rules-should-not-use b/data/rules/rules-should-not-use
index 1d880577a..c4842b202 100644
--- a/data/rules/rules-should-not-use
+++ b/data/rules/rules-should-not-use
@@ -5,7 +5,7 @@
 #
 debian-rules-should-not-automatically-update-control     ~~ ^\s*DEB_AUTO_UPDATE_DEBIAN_CONTROL\s*=\s*yes
 debian-rules-should-not-use-DEB_BUILD_OPTS               ~~ \$[\(\{]DEB_BUILD_OPTS[\)\}]
+debian-rules-should-not-use-DH_EXTRA_ADDONS              ~~ ^\s*DH_EXTRA_ADDONS\s*=
 debian-rules-should-not-use-or-modify-user-only-variable ~~ \bDEB_[^_ \t]+FLAGS_(?:SET|APPEND)\b
 debian-rules-should-not-use-pwd                          ~~ \$[\(\{]PWD[\)\}]
 debian-rules-should-not-use-underscore-variable          ~~ \$[\(\{]_[\)\}]
-
diff --git a/t/tests/rules-general/debian/debian/rules b/t/tests/rules-general/debian/debian/rules
index cddbc0356..a9623caf1 100755
--- a/t/tests/rules-general/debian/debian/rules
+++ b/t/tests/rules-general/debian/debian/rules
@@ -1,6 +1,7 @@
 #!/usr/bin/make -f
 
 DEB_AUTO_UPDATE_DEBIAN_CONTROL = yes
+DH_EXTRA_ADDONS = systemd
 
 %:
 	dh $@
diff --git a/t/tests/rules-general/desc b/t/tests/rules-general/desc
index 8df153534..31dc87b89 100644
--- a/t/tests/rules-general/desc
+++ b/t/tests/rules-general/desc
@@ -5,5 +5,6 @@ Test-For:
  clean-should-be-satisfied-by-build-depends
  debian-rules-should-not-automatically-update-control
  debian-rules-should-not-use-DEB_BUILD_OPTS
+ debian-rules-should-not-use-DH_EXTRA_ADDONS
  debian-rules-should-not-use-pwd
- debian-rules-should-not-use-underscore-variable
\ No newline at end of file
+ debian-rules-should-not-use-underscore-variable
diff --git a/t/tests/rules-general/tags b/t/tests/rules-general/tags
index 3e7351beb..660bfec1d 100644
--- a/t/tests/rules-general/tags
+++ b/t/tests/rules-general/tags
@@ -1,5 +1,6 @@
 E: rules-general source: clean-should-be-satisfied-by-build-depends debhelper
 E: rules-general source: debian-rules-should-not-automatically-update-control line 3
-W: rules-general source: debian-rules-should-not-use-DEB_BUILD_OPTS line 10
-W: rules-general source: debian-rules-should-not-use-pwd line 10
-W: rules-general source: debian-rules-should-not-use-underscore-variable line 11
+W: rules-general source: debian-rules-should-not-use-DEB_BUILD_OPTS line 11
+W: rules-general source: debian-rules-should-not-use-DH_EXTRA_ADDONS line 4
+W: rules-general source: debian-rules-should-not-use-pwd line 11
+W: rules-general source: debian-rules-should-not-use-underscore-variable line 12
-- 
2.15.1


Reply to: