[lintian] 01/02: Check for missing calls to dpkg-maintscript-helper(1) in maintainer scripts. (Closes: #XXXXXX)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit f209dc9e94c29a60a330c4307315a589396c43ce
Author: Chris Lamb <lamby@debian.org>
Date: Sat Aug 12 21:18:40 2017 -0400
Check for missing calls to dpkg-maintscript-helper(1) in maintainer scripts. (Closes: #XXXXXX)
---
checks/scripts.desc | 8 ++++++++
checks/scripts.pm | 19 ++++++++++++++++++-
debian/changelog | 2 ++
.../debian/debian/postinst | 9 +++++++++
.../debian/debian/preinst | 9 +++++++++
.../desc | 5 +++++
.../tags | 1 +
7 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/checks/scripts.desc b/checks/scripts.desc
index f5fe1b2..8a5b6bb 100644
--- a/checks/scripts.desc
+++ b/checks/scripts.desc
@@ -375,6 +375,14 @@ Info: The maintainer script seems to call dpkg-maintscript-helper
package uninstallable.
Ref: dpkg-maintscript-helper(1)
+Tag: missing-call-to-dpkg-maintscript-helper
+Severity: serious
+Certainty: certain
+Info: The maintainer script is missing a call to the specified
+ dpkg-maintscript-helper command which requires coordinated actions from
+ several maintainer scripts.
+Ref: dpkg-maintscript-helper(1)
+
Tag: maintainer-script-removes-device-files
Severity: serious
Certainty: certain
diff --git a/checks/scripts.pm b/checks/scripts.pm
index 1b098d0..d118dea 100644
--- a/checks/scripts.pm
+++ b/checks/scripts.pm
@@ -231,7 +231,7 @@ sub script_tag {
sub run {
my ($pkg, undef, $info) = @_;
- my (%executable, %ELF, %scripts);
+ my (%executable, %ELF, %scripts, %seen_helper_cmds);
# no dependency for install-menu, because the menu package specifically
# says not to depend on it.
@@ -684,6 +684,12 @@ sub run {
$saw_statoverride_list = 1 if /--list/;
}
+ if (m,$LEADIN(?:/usr/bin/)?dpkg-maintscript-helper\s(\S+),) {
+ my $cmd = $1;
+ $seen_helper_cmds{$cmd} = () unless $seen_helper_cmds{$cmd};
+ $seen_helper_cmds{$cmd}{$file} = 1;
+ }
+
if ( m,[^\w](?:(?:/var)?/tmp|\$TMPDIR)/[^)\]}\s],
and not m/\bmks?temp\b/
and not m/\btempfile\b/
@@ -1020,6 +1026,17 @@ sub run {
}
close($ctrl_fd);
+ for my $cmd (qw(rm_conffile mv_conffile symlink_to_dir)) {
+ next unless $seen_helper_cmds{$cmd};
+
+ # dpkg-maintscript-helper(1) recommends the snippets are in all
+ # maintainer scripts but they are not strictly required in prerm.
+ for my $file (qw(preinst postinst postrm)) {
+ tag 'missing-call-to-dpkg-maintscript-helper', "$file ($cmd)"
+ unless $seen_helper_cmds{$cmd}{$file};
+ }
+ }
+
# If any of the maintainer scripts used a variable in the file or
# diversion name normalise them all
if ($expand_diversions) {
diff --git a/debian/changelog b/debian/changelog
index 5d59620..d034779 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -59,6 +59,8 @@ lintian (2.5.53) UNRELEASED; urgency=medium
+ [CL] Correct false positives in
unconditional-use-of-dpkg-statoverride by detecting "if !" as a
valid shell prefix. (Closes: #869587)
+ + [CL] Check for missing calls to dpkg-maintscript-helper(1) in
+ maintainer scripts. (Closes: #XXXXXX)
* checks/testsuite.{desc,pm}:
+ [CL] Remove recommendations to add a "Testsuite: autopkgtest" field
to debian/control as it is added when needed by dpkg-source(1)
diff --git a/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/debian/debian/postinst b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/debian/debian/postinst
new file mode 100644
index 0000000..fb6d516
--- /dev/null
+++ b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/debian/debian/postinst
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+dpkg-maintscript-helper symlink_to_dir /path/name /old/target 1.0-1 scripts-missing-call-to-dpkg-maintscript-helper
+
+exit 0
diff --git a/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/debian/debian/preinst b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/debian/debian/preinst
new file mode 100644
index 0000000..fb6d516
--- /dev/null
+++ b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/debian/debian/preinst
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+dpkg-maintscript-helper symlink_to_dir /path/name /old/target 1.0-1 scripts-missing-call-to-dpkg-maintscript-helper
+
+exit 0
diff --git a/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/desc b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/desc
new file mode 100644
index 0000000..39473f1
--- /dev/null
+++ b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/desc
@@ -0,0 +1,5 @@
+Testname: scripts-missing-call-to-dpkg-maintscript-helper
+Version: 1.0
+Description: Test for packages that miss calls to dpkg-maintscript-helper(1)
+Test-For:
+ missing-call-to-dpkg-maintscript-helper
diff --git a/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/tags b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/tags
new file mode 100644
index 0000000..488eefb
--- /dev/null
+++ b/t/tests/scripts-missing-call-to-dpkg-maintscript-helper/tags
@@ -0,0 +1 @@
+E: scripts-missing-call-to-dpkg-maintscript-helper: missing-call-to-dpkg-maintscript-helper postrm (symlink_to_dir)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: