Bug#838997: lintian: checks/init.d: Check for initscripts that source /lib/lsb/init-functions without declaring the corresponding dependency on lsb-base (>= 3.0-6).
Dear Niels,
Thanks for the review.
> Please shorten the synopsis and move the more length part into the
> description.
Done…
> Please create a non-legacy test case for new tags. A long term goal is
> to remove all the t/tests/legacy-* tests.
… and done. Good to know :)
Updated patch attached:
commit 7152e3984acb45ebb455387765a5e7af4176bb62
Author: Chris Lamb <lamby@debian.org>
Date: Sat Oct 1 12:39:39 2016 +0100
checks/init.d: Check scripts using init-functions without lsb-base Depends. (Closes: #838997)
Emit a tag for initscripts that source the /lib/lsb/init-functions utility
functions without declaring the corresponding dependency on lsb-base
(>= 3.0-6).
Signed-off-by: Chris Lamb <lamby@debian.org>
checks/init.d.desc | 6 +++
checks/init.d.pm | 12 +++--
t/tests/init.d-lsb-depends/debian/debian/init | 71 +++++++++++++++++++++++++++
t/tests/init.d-lsb-depends/desc | 4 ++
t/tests/init.d-lsb-depends/tags | 1 +
5 files changed, 91 insertions(+), 3 deletions(-)
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby@debian.org / chris-lamb.co.uk
`-
From e382f9e37fae3a4a9af304b47c49ddbec7d8f0e5 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Sat, 1 Oct 2016 12:42:10 +0100
Subject: [PATCH] checks/init.d: Check scripts using init-functions without
lsb-base Depends. (Closes: #838997)
Emit a tag for initscripts that source the /lib/lsb/init-functions utility
functions without declaring the corresponding dependency on lsb-base
(>= 3.0-6).
Signed-off-by: Chris Lamb <lamby@debian.org>
---
checks/init.d.desc | 6 +++
checks/init.d.pm | 12 +++--
t/tests/init.d-lsb-depends/debian/debian/init | 71 +++++++++++++++++++++++++++
t/tests/init.d-lsb-depends/desc | 4 ++
t/tests/init.d-lsb-depends/tags | 1 +
5 files changed, 91 insertions(+), 3 deletions(-)
create mode 100644 t/tests/init.d-lsb-depends/debian/debian/init
create mode 100644 t/tests/init.d-lsb-depends/desc
create mode 100644 t/tests/init.d-lsb-depends/tags
diff --git a/checks/init.d.desc b/checks/init.d.desc
index ce33ba5..3be8a3d 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -370,3 +370,9 @@ Info: The given init script declares a dependency on the
totally broken.
Ref: https://wiki.debian.org/LSBInitScripts
+Tag: init.d-script-needs-depends-on-lsb-base
+Severity: important
+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).
diff --git a/checks/init.d.pm b/checks/init.d.pm
index f91afa1..4174a4d 100644
--- a/checks/init.d.pm
+++ b/checks/init.d.pm
@@ -198,7 +198,7 @@ sub run {
# Check if file exists in package and check the script for
# other issues if it was included in the package.
- check_init($initd_path);
+ check_init($initd_path, $info);
}
return unless $initd_dir and $initd_dir->is_dir;
@@ -222,7 +222,7 @@ sub run {
# coverage in the first pass.
unless ($initd_postinst{$script->basename}) {
tag $tagname, $script;
- check_init($script);
+ check_init($script, $info);
}
}
@@ -230,7 +230,7 @@ sub run {
}
sub check_init {
- my ($initd_path) = @_;
+ my ($initd_path, $info) = @_;
# In an upstart system, such as Ubuntu, init scripts are symlinks to
# upstart-job. It doesn't make sense to check the syntax of upstart-job,
@@ -321,6 +321,12 @@ sub check_init {
while ($l =~ s/^[^\#]*?(start|stop|restart|force-reload|status)//o) {
$tag{$1} = 1;
}
+
+ if ($l =~ m{^\s*\.\s+/lib/lsb/init-functions}
+ && not $info->relation('strong')->implies('lsb-base (>= 3.0-6)')) {
+ tag 'init.d-script-needs-depends-on-lsb-base',
+ $initd_path, "(line $.)";
+ }
}
close($fd);
diff --git a/t/tests/init.d-lsb-depends/debian/debian/init b/t/tests/init.d-lsb-depends/debian/debian/init
new file mode 100644
index 0000000..48d4cde
--- /dev/null
+++ b/t/tests/init.d-lsb-depends/debian/debian/init
@@ -0,0 +1,71 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: init.d-lsb-depends
+# Required-Start: $syslog $remote_fs
+# Required-Stop: $syslog $remote_fs
+# Should-Start: $local_fs
+# Should-Stop: $local_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: init.d-lsb-depends
+# Description: init.d-lsb-depends
+### END INIT INFO
+
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/bin/init.d-lsb-depends
+NAME=init.d-lsb-depends
+DESC=init.d-lsb-depends
+
+RUNDIR=/var/run/redis
+PIDFILE=$RUNDIR/init.d-lsb-depends.pid
+
+test -x $DAEMON || exit 0
+
+if [ -r /etc/default/$NAME ]
+then
+ . /etc/default/$NAME
+fi
+
+. /lib/lsb/init-functions
+
+set -e
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
+ then
+ echo "$NAME."
+ else
+ echo "failed"
+ fi
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ if start-stop-daemon --stop --retry --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
+ then
+ echo "$NAME."
+ else
+ echo "failed"
+ fi
+ rm -f $PIDFILE
+ sleep 1
+ ;;
+
+ restart|force-reload)
+ ${0} stop
+ ${0} start
+ ;;
+
+ status)
+ status_of_proc -p ${PIDFILE} ${DAEMON} ${NAME}
+ ;;
+
+ *)
+ echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/t/tests/init.d-lsb-depends/desc b/t/tests/init.d-lsb-depends/desc
new file mode 100644
index 0000000..e0f6565
--- /dev/null
+++ b/t/tests/init.d-lsb-depends/desc
@@ -0,0 +1,4 @@
+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
diff --git a/t/tests/init.d-lsb-depends/tags b/t/tests/init.d-lsb-depends/tags
new file mode 100644
index 0000000..21e92fd
--- /dev/null
+++ b/t/tests/init.d-lsb-depends/tags
@@ -0,0 +1 @@
+E: init.d-lsb-depends: init.d-script-needs-depends-on-lsb-base etc/init.d/init.d-lsb-depends (line 30)
--
2.9.3
Reply to: