Bug#839861: lintian: init.d-script-needs-depends-on-lsb-base does not use strict enough lsb-base version for (eg.) status_of_proc
[Deliberately not setting 'patch' tag; see below]
Hi,
> lintian: init.d-script-needs-depends-on-lsb-base does not use strict
> enough lsb-base version for (eg.) status_of_proc
_Work in progress_ patch attached:
commit 0828c266ac77239fffe25e6bfe473603a4dfbad1
Author: Chris Lamb <lamby@debian.org>
Date: Sun Oct 9 12:35:42 2016 +0100
WIP: Add init.d-script-needs-depends-on-lsb-base-for-status-of-proc tag.
checks/init.d.desc | 7 +++++++
checks/init.d.pm | 11 +++++++++--
t/tests/init.d-lsb-depends/desc | 4 +++-
t/tests/init.d-lsb-depends/tags | 1 +
4 files changed, 20 insertions(+), 3 deletions(-)
(Just asking for some very early feedback; not sure the testsuite even passes
at this point.)
I have two main questions:
a) should I try and merge init.d-script-needs-depends-on-lsb-base-for-status-of-proc
and init.d-script-needs-depends-on-lsb-base tags.
b) If so, is there prior art in Lintian on how to "parameterise" the tag
to include the initscript name, the line number /and/ the minimum
lsb-base version required given the features used.
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby@debian.org / chris-lamb.co.uk
`-
>From 0828c266ac77239fffe25e6bfe473603a4dfbad1 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Sun, 9 Oct 2016 12:35:42 +0100
Subject: [PATCH] WIP: Add
init.d-script-needs-depends-on-lsb-base-for-status-of-proc tag.
---
checks/init.d.desc | 7 +++++++
checks/init.d.pm | 11 +++++++++--
t/tests/init.d-lsb-depends/desc | 4 +++-
t/tests/init.d-lsb-depends/tags | 1 +
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/checks/init.d.desc b/checks/init.d.desc
index 5b19b3a..06bb64b 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -376,3 +376,10 @@ Certainty: possible
Info: The given init script sources the <tt>/lib/lsb/init-functions</tt> utility
functions without declaring the corresponding dependency on lsb-base
(>= 3.0-6).
+
+Tag: init.d-script-needs-depends-on-lsb-base-for-status-of-proc
+Severity: important
+Certainty: possible
+Info: The given init script uses the <tt>status_of_proc</tt> utility from
+ <tt>/lib/lsb/init-functions</tt> utility functions without declaring the
+ corresponding dependency on lsb-base (>= 3.2-13).
diff --git a/checks/init.d.pm b/checks/init.d.pm
index 7b0fa7d..b3fa827 100644
--- a/checks/init.d.pm
+++ b/checks/init.d.pm
@@ -318,8 +318,10 @@ sub check_init {
$needs_fs{'remote'} = 1 if ($l =~ m,^[^\#]*/usr/,);
$needs_fs{'local'} = 1 if ($l =~ m,^[^\#]*/var/,);
- while ($l =~ s/^[^\#]*?(start|stop|restart|force-reload|status)//o) {
- $tag{$1} = 1;
+ if ($l =~ m{^[^\#]*?status_of_proc}
+ && !$info->relation('strong')->implies('lsb-base (>= 3.2-13)')) {
+ tag 'init.d-script-needs-depends-on-lsb-base-for-status-of-proc',
+ $initd_path, "(line $.)";
}
if ($l =~ m{^\s*\.\s+/lib/lsb/init-functions}
@@ -327,6 +329,11 @@ sub check_init {
tag 'init.d-script-needs-depends-on-lsb-base',
$initd_path, "(line $.)";
}
+
+ # Modify $l as late as possible in loop
+ while ($l =~ s/^[^\#]*?(start|stop|restart|force-reload|status)//o) {
+ $tag{$1} = 1;
+ }
}
close($fd);
diff --git a/t/tests/init.d-lsb-depends/desc b/t/tests/init.d-lsb-depends/desc
index e0f6565..4aa74fb 100644
--- a/t/tests/init.d-lsb-depends/desc
+++ b/t/tests/init.d-lsb-depends/desc
@@ -1,4 +1,6 @@
Testname: init.d-lsb-depends
Version: 1.0
Description: Test for packages missing dependencies on lsb-base
-Test-For: init.d-script-needs-depends-on-lsb-base
+Test-For:
+ init.d-script-needs-depends-on-lsb-base
+ init.d-script-needs-depends-on-lsb-base-for-status-of-proc
diff --git a/t/tests/init.d-lsb-depends/tags b/t/tests/init.d-lsb-depends/tags
index 21e92fd..9d521ef 100644
--- a/t/tests/init.d-lsb-depends/tags
+++ b/t/tests/init.d-lsb-depends/tags
@@ -1 +1,2 @@
E: init.d-lsb-depends: init.d-script-needs-depends-on-lsb-base etc/init.d/init.d-lsb-depends (line 30)
+E: init.d-lsb-depends: init.d-script-needs-depends-on-lsb-base-for-status-of-proc etc/init.d/init.d-lsb-depends (line 62)
--
2.9.3
Reply to: