Source: lintian Severity: wishlist Version: 2.5.38 Tags: patch Attached are two patches against lintian master, which do the following:
* The first teaches lintian about some new dh-exec features, such as architecture and build profile filters. Therefore, the "dh-exec-script-without-dh-exec-features" tag will not be emitted for packages that make use of these new features, but not the old ones. * The second one is an attempt at catching unnecessary dh-exec use: when one uses dh-exec to install /usr/lib/${DEB_HOST_MULTIARCH}, that can be done with a simple wildcard, without dh-exec. There may be false positives, so the new tag is of wishlist severity only. -- |8]
>From 6b35ed7bb3ac3efcfe2ba253c0b3c0514f29c165 Mon Sep 17 00:00:00 2001 From: Gergely Nagy <alger...@madhouse-project.org> Date: Tue, 6 Oct 2015 11:54:07 +0200 Subject: [PATCH 1/2] checks/debhelper.pm: Update the dh-exec feature checks Update the dh-exec feature checks to notice the arch and build profile filters too, and not emit dh-exec-script-without-dh-exec-features if these are used. Signed-off-by: Gergely Nagy <alger...@madhouse-project.org> --- checks/debhelper.pm | 6 ++++-- t/tests/debhelper-dh-exec/debian/debian/dirs | 2 ++ t/tests/debhelper-dh-exec/debian/debian/install | 2 +- t/tests/debhelper-dh-exec/debian/debian/rules | 1 + t/tests/debhelper-dh-exec/tags | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100755 t/tests/debhelper-dh-exec/debian/debian/dirs diff --git a/checks/debhelper.pm b/checks/debhelper.pm index f40f8ab..59c1341 100644 --- a/checks/debhelper.pm +++ b/checks/debhelper.pm @@ -481,7 +481,7 @@ sub _check_dh_exec { tag 'dh-exec-private-helper', $path; } - my ($dhe_subst, $dhe_install) = (0, 0); + my ($dhe_subst, $dhe_install, $dhe_filter) = (0, 0, 0); my $fd = $path->open; while (<$fd>) { if (/\$\{([^\}]+)\}/) { @@ -499,10 +499,12 @@ sub _check_dh_exec { } } $dhe_install = 1 if / => /; + $dhe_filter = 1 if /\[[^\]]+\]/; + $dhe_filter = 1 if /<[^>]+>/; } close($fd); - if (!($dhe_subst || $dhe_install)) { + if (!($dhe_subst || $dhe_install || $dhe_filter)) { tag 'dh-exec-script-without-dh-exec-features', $path; } diff --git a/t/tests/debhelper-dh-exec/debian/debian/dirs b/t/tests/debhelper-dh-exec/debian/debian/dirs new file mode 100755 index 0000000..bc147d0 --- /dev/null +++ b/t/tests/debhelper-dh-exec/debian/debian/dirs @@ -0,0 +1,2 @@ +#! /usr/bin/dh-exec +usr/lib diff --git a/t/tests/debhelper-dh-exec/debian/debian/install b/t/tests/debhelper-dh-exec/debian/debian/install index bc147d0..819be1a 100755 --- a/t/tests/debhelper-dh-exec/debian/debian/install +++ b/t/tests/debhelper-dh-exec/debian/debian/install @@ -1,2 +1,2 @@ #! /usr/bin/dh-exec -usr/lib +usr/lib/foo [linux-any] [hurd-any] [kfreebsd-any] diff --git a/t/tests/debhelper-dh-exec/debian/debian/rules b/t/tests/debhelper-dh-exec/debian/debian/rules index 4d45dbe..0a817ea 100755 --- a/t/tests/debhelper-dh-exec/debian/debian/rules +++ b/t/tests/debhelper-dh-exec/debian/debian/rules @@ -6,5 +6,6 @@ override_dh_installman: override_dh_install: + touch debian/debhelper-dh-exec/usr/lib/foo override_dh_link: diff --git a/t/tests/debhelper-dh-exec/tags b/t/tests/debhelper-dh-exec/tags index 2d0786a..b418aee 100644 --- a/t/tests/debhelper-dh-exec/tags +++ b/t/tests/debhelper-dh-exec/tags @@ -2,4 +2,4 @@ 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 -W: debhelper-dh-exec source: dh-exec-script-without-dh-exec-features debian/install +W: debhelper-dh-exec source: dh-exec-script-without-dh-exec-features debian/dirs -- 2.5.3
>From d279b43ea3cec4664b6a23404562c939309c5c17 Mon Sep 17 00:00:00 2001 From: Gergely Nagy <alger...@madhouse-project.org> Date: Tue, 6 Oct 2015 12:28:21 +0200 Subject: [PATCH 2/2] 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 <alger...@madhouse-project.org> --- 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 -- 2.5.3