[lintian] 01/01: Warn on packages unnecessararily setting dpkg-architecture(1) variables. (Closes: #793554)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit 4ad986037d03677504c802eec69175d6529185c8
Author: Chris Lamb <lamby@debian.org>
Date: Wed Oct 25 15:10:55 2017 -0400
Warn on packages unnecessararily setting dpkg-architecture(1) variables. (Closes: #793554)
---
checks/rules.desc | 13 +++++++++++++
checks/rules.pm | 10 ++++++++++
debian/changelog | 3 +++
.../debian/debian/rules | 8 ++++++++
t/tests/rules-sets-dpkg-architecture-variable/desc | 5 +++++
t/tests/rules-sets-dpkg-architecture-variable/tags | 2 ++
6 files changed, 41 insertions(+)
diff --git a/checks/rules.desc b/checks/rules.desc
index 2f2cc52..37731e6 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -259,3 +259,16 @@ Info: The rules file appears to be parsing the output of dpkg-parsechangelog to
.
Using this library is not only cleaner and more efficient, it handles many
corner-cases such as binNMUs, epoch versions, etc.
+
+Tag: debian-rules-sets-dpkg-architecture-variable
+Severity: normal
+Certainty: certain
+Ref: dpkg-architecture(1)
+Info: The <tt>debian/rules</tt> file sets one or more
+ <tt>dpkg-architecture</tt> variables such as <tt>DEB_BUILD_ARCH</tt>.
+ .
+ These variables are pre-initialized in the environment when running under
+ <tt>dpkg-buildpackage</tt> - avoiding these assignments can reduce package
+ build time.
+ .
+ Please replace the assignment operator with <tt>?=</tt>.
diff --git a/checks/rules.pm b/checks/rules.pm
index 2d73da8..f9e317c 100644
--- a/checks/rules.pm
+++ b/checks/rules.pm
@@ -212,6 +212,16 @@ sub run {
tag 'debian-rules-sets-DEB_BUILD_OPTIONS', "line $.";
}
+ if (
+ /^
+ \s*(?:export\s+)?
+ (DEB_(?:HOST|BUILD|TARGET)_(?:ARCH|MULTIARCH|GNU)[A-Z_]*)\s*:?=
+ /x
+ && keys(%seen) == 0
+ ) {
+ tag 'debian-rules-sets-dpkg-architecture-variable', "$1 (line $.)";
+ }
+
# check generic problem
foreach my $bad_construct ($BAD_CONSTRUCT_IN_RULES->all) {
my $badregex = $BAD_CONSTRUCT_IN_RULES->value($bad_construct);
diff --git a/debian/changelog b/debian/changelog
index e5d9b00..35973ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -37,6 +37,9 @@ lintian (2.5.56) UNRELEASED; urgency=medium
template. Thanks to Christoph Biedl for the idea. (Closes: #879152)
* checks/md5sums.pm:
+ [CL] Allow empty md5sums files. (Closes: #781372)
+ * checks/rules.{pm,desc}:
+ + [CL] Warn on packages unnecessararily setting dpkg-architecture(1)
+ variables. (Closes: #793554)
* checks/source-changelog.{desc.pm}:
+ [CL] Move latest-debian-changelog-entry-without-new-date tag into a
new check of type "source". (Closes: #873612)
diff --git a/t/tests/rules-sets-dpkg-architecture-variable/debian/debian/rules b/t/tests/rules-sets-dpkg-architecture-variable/debian/debian/rules
new file mode 100755
index 0000000..77454fa
--- /dev/null
+++ b/t/tests/rules-sets-dpkg-architecture-variable/debian/debian/rules
@@ -0,0 +1,8 @@
+#!/usr/bin/make -f
+
+export DEB_HOST_ARCH = invalid
+export DEB_BUILD_ARCH := invalid
+export DEB_TARGET_ARCH ?= false-positive
+
+%:
+ dh $@
diff --git a/t/tests/rules-sets-dpkg-architecture-variable/desc b/t/tests/rules-sets-dpkg-architecture-variable/desc
new file mode 100644
index 0000000..e98b2cd
--- /dev/null
+++ b/t/tests/rules-sets-dpkg-architecture-variable/desc
@@ -0,0 +1,5 @@
+Testname: rules-sets-dpkg-architecture-variable
+Version: 1.0
+Description: Test for unnecessary dpkg-architecture assignments
+Test-For:
+ debian-rules-sets-dpkg-architecture-variable
diff --git a/t/tests/rules-sets-dpkg-architecture-variable/tags b/t/tests/rules-sets-dpkg-architecture-variable/tags
new file mode 100644
index 0000000..0b5d16d
--- /dev/null
+++ b/t/tests/rules-sets-dpkg-architecture-variable/tags
@@ -0,0 +1,2 @@
+W: rules-sets-dpkg-architecture-variable source: debian-rules-sets-dpkg-architecture-variable DEB_BUILD_ARCH (line 4)
+W: rules-sets-dpkg-architecture-variable source: debian-rules-sets-dpkg-architecture-variable DEB_HOST_ARCH (line 3)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: