[lintian] 02/05: checks/debhelper.pm: Add a new dh-exec test
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 2ad0748c04b7dc641bc568c1526711a1a5cd3486
Author: Gergely Nagy <algernon@madhouse-project.org>
Date: Tue Oct 6 12:28:21 2015 +0200
checks/debhelper.pm: Add a new dh-exec test
The new check tries to find cases where using dh-exec is not needed, and
a better, simpler solution exists. The new tag, dh-exec-useless-usage is
emitted when lintian finds a construct where a wildcard would do instead
of using dh-exec's variable substitution powers.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Signed-off-by: Niels Thykier <niels@thykier.net>
---
checks/debhelper.desc | 20 ++++++++++++++++++
checks/debhelper.pm | 28 +++++++++++++++++++++++++
t/tests/debhelper-dh-exec/debian/debian/install | 3 +++
t/tests/debhelper-dh-exec/desc | 1 +
t/tests/debhelper-dh-exec/tags | 2 ++
5 files changed, 54 insertions(+)
diff --git a/checks/debhelper.desc b/checks/debhelper.desc
index 11783a4..89f6ab6 100644
--- a/checks/debhelper.desc
+++ b/checks/debhelper.desc
@@ -331,6 +331,26 @@ Info: The package uses a variable in one of its debhelper config
the build one way or the other, then this tag can be safely ignored
or overridden.
+Tag: dh-exec-useless-usage
+Severity: wishlist
+Certainty: possible
+Info: The package uses dh-exec for things it is not needed for.
+ .
+ This typically includes using ${DEB_HOST_MULTIARCH} in an install
+ target where a wildcard would suffice. For example, if you had:
+ .
+ #! /usr/bin/dh-exec
+ usr/lib/${DEB_HOST_MULTIARCH}
+ .
+ This could be replaced with the following in most cases, dropping the
+ need for dh-exec:
+ .
+ usr/lib/*
+ .
+ However, there may be other directories that match the wildcard,
+ which one does not wish to install. In that case, this warning should
+ be ignored or overridden.
+
Tag: debhelper-compat-file-is-missing
Severity: normal
Certainty: certain
diff --git a/checks/debhelper.pm b/checks/debhelper.pm
index 59c1341..db00b5a 100644
--- a/checks/debhelper.pm
+++ b/checks/debhelper.pm
@@ -501,6 +501,33 @@ sub _check_dh_exec {
$dhe_install = 1 if / => /;
$dhe_filter = 1 if /\[[^\]]+\]/;
$dhe_filter = 1 if /<[^>]+>/;
+
+ if (/^usr\/lib\/\$\{([^\}]+)\}\/?$/ ||
+ /^usr\/lib\/\$\{([^\}]+)\}\/?\s+\/usr\/lib\/\$\{([^\}]+)\}\/?$/) {
+ my $sv = $1;
+ my $dv = $2;
+ my $dhe_useless = 0;
+
+ if (
+ $sv =~ m{ \A
+ DEB_(?:BUILD|HOST)_(?:
+ ARCH (?: _OS|_CPU|_BITS|_ENDIAN )?
+ |GNU_ (?:CPU|SYSTEM|TYPE)|MULTIARCH
+ ) \Z}xsm
+ ) {
+ if (defined($dv)) {
+ $dhe_useless = ($sv eq $dv);
+ } else {
+ $dhe_useless = 1;
+ }
+ }
+ if ($dhe_useless) {
+ my $form = $_;
+ chomp ($form);
+ $form = "\"$form\"";
+ tag 'dh-exec-useless-usage', $path, $form;
+ }
+ }
}
close($fd);
@@ -511,6 +538,7 @@ sub _check_dh_exec {
if ($dhe_install && ($base ne 'install' && $base ne 'manpages')) {
tag 'dh-exec-install-not-allowed-here', $path;
}
+
return;
}
diff --git a/t/tests/debhelper-dh-exec/debian/debian/install b/t/tests/debhelper-dh-exec/debian/debian/install
index 819be1a..50055cb 100755
--- a/t/tests/debhelper-dh-exec/debian/debian/install
+++ b/t/tests/debhelper-dh-exec/debian/debian/install
@@ -1,2 +1,5 @@
#! /usr/bin/dh-exec
usr/lib/foo [linux-any] [hurd-any] [kfreebsd-any]
+usr/lib/${DEB_HOST_MULTIARCH}
+usr/lib/${DEB_HOST_MULTIARCH} /usr/lib/${DEB_HOST_MULTIARCH}/
+usr/lib/${DEB_BUILD_MULTIARCH} /usr/lib/${DEB_HOST_MULTIARCH}/
diff --git a/t/tests/debhelper-dh-exec/desc b/t/tests/debhelper-dh-exec/desc
index 5847cbe..c8dd8a9 100644
--- a/t/tests/debhelper-dh-exec/desc
+++ b/t/tests/debhelper-dh-exec/desc
@@ -10,4 +10,5 @@ Test-For:
dh-exec-private-helper
dh-exec-script-without-dh-exec-features
dh-exec-subst-unknown-variable
+ dh-exec-useless-usage
package-uses-dh-exec-but-lacks-build-depends
diff --git a/t/tests/debhelper-dh-exec/tags b/t/tests/debhelper-dh-exec/tags
index b418aee..50d5f12 100644
--- a/t/tests/debhelper-dh-exec/tags
+++ b/t/tests/debhelper-dh-exec/tags
@@ -2,4 +2,6 @@ E: debhelper-dh-exec source: dh-exec-install-not-allowed-here debian/links
E: debhelper-dh-exec source: dh-exec-private-helper debian/manpages
E: debhelper-dh-exec source: package-uses-dh-exec-but-lacks-build-depends
I: debhelper-dh-exec source: dh-exec-subst-unknown-variable debian/manpages DEB_BUILD_WHATEVER
+I: debhelper-dh-exec source: dh-exec-useless-usage debian/install "usr/lib/${DEB_HOST_MULTIARCH} /usr/lib/${DEB_HOST_MULTIARCH}/"
+I: debhelper-dh-exec source: dh-exec-useless-usage debian/install "usr/lib/${DEB_HOST_MULTIARCH}"
W: debhelper-dh-exec source: dh-exec-script-without-dh-exec-features debian/dirs
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: