[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/02: systemd.pm: Properly remove .sh suffix when checking systemd-initscript matching



This is an automated email from the git hooks/post-receive script.

jwilk pushed a commit to branch master
in repository lintian.

commit b95007a7da6751997d3624994c97a72aeb5d4488
Author: Felipe Sateler <fsateler@debian.org>
Date:   Wed Mar 23 12:11:43 2016 -0300

    systemd.pm: Properly remove .sh suffix when checking systemd-initscript matching
---
 checks/systemd.pm                                  | 16 +++++++++----
 t/tests/systemd-general/debian/debian/install      |  1 +
 t/tests/systemd-general/debian/debian/rules        |  1 +
 .../systemd-general/debian/debian/sourced.service  |  9 ++++++++
 .../systemd-general/debian/debian/sourced.sh.init  | 27 ++++++++++++++++++++++
 5 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/checks/systemd.pm b/checks/systemd.pm
index 69092be..face504 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -66,14 +66,21 @@ sub run {
     return;
 }
 
+sub get_init_service_name {
+    my ($file) = @_;
+    my $basename = $file->basename;
+    # sysv generator drops the .sh suffix
+    $basename =~ s/\.sh$//;
+    return $basename;
+}
+
 sub get_init_scripts {
     my ($info) = @_;
     my @scripts;
     if (my $initd_path = $info->index_resolved_path('etc/init.d/')) {
         for my $init_script ($initd_path->children) {
             # sysv generator drops the .sh suffix
-            my $basename = $init_script->basename;
-            $basename =~ s/\.sh$//;
+            my $basename = get_init_service_name($init_script);
             next if $INIT_WHITELIST->known($basename);
             next
               if $init_script->is_symlink
@@ -90,6 +97,7 @@ sub get_init_scripts {
 sub check_init_script {
     my ($info, $file, $services) = @_;
     my $basename = $file->basename;
+    my $servicename = get_init_service_name($file);
     my $lsb_source_seen;
     my $is_rcs_script = 0;
 
@@ -121,12 +129,12 @@ sub check_init_script {
     # Only tag if the maintainer of this package did any effort to
     # make the package work with systemd.
     tag 'systemd-no-service-for-init-script', $basename
-      if (%{$services} and not $services->{$basename});
+      if (%{$services} and not $services->{$servicename});
 
     # rcS scripts are particularly bad, warn even if there is
     # no systemd integration
     tag 'systemd-no-service-for-init-rcS-script', $basename
-      if (not $services->{$basename} and $is_rcs_script);
+      if (not $services->{$servicename} and $is_rcs_script);
     return;
 }
 
diff --git a/t/tests/systemd-general/debian/debian/install b/t/tests/systemd-general/debian/debian/install
index 56cf085..3ed93ab 100644
--- a/t/tests/systemd-general/debian/debian/install
+++ b/t/tests/systemd-general/debian/debian/install
@@ -1,3 +1,4 @@
 debian/test.service etc/systemd/system/
 debian/test.service usr/lib/systemd/system/
+debian/sourced.service lib/systemd/system/
 debian/test.conf etc/tmpfiles.d/
diff --git a/t/tests/systemd-general/debian/debian/rules b/t/tests/systemd-general/debian/debian/rules
index fade512..47cdf51 100644
--- a/t/tests/systemd-general/debian/debian/rules
+++ b/t/tests/systemd-general/debian/debian/rules
@@ -23,3 +23,4 @@ override_dh_fixperms:
 override_dh_installinit:
 	dh_installinit
 	dh_installinit --name systemd-aliasd
+	dh_installinit --name sourced.sh
diff --git a/t/tests/systemd-general/debian/debian/sourced.service b/t/tests/systemd-general/debian/debian/sourced.service
new file mode 100644
index 0000000..3fdee38
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/sourced.service
@@ -0,0 +1,9 @@
+[Unit]
+After=network.target
+Documentation=man:sourced(1)
+
+[Service]
+ExecStart=/usr/bin/test
+
+[Install]
+WantedBy=multi-user.target
diff --git a/t/tests/systemd-general/debian/debian/sourced.sh.init b/t/tests/systemd-general/debian/debian/sourced.sh.init
new file mode 100644
index 0000000..c7fb722
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/sourced.sh.init
@@ -0,0 +1,27 @@
+#!/bin/sh
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+### BEGIN INIT INFO
+# Provides:          sourced
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Example initscript
+# Description:       This file should be used to construct scripts to be
+#                    placed in /etc/init.d.  This example start a
+#                    single forking daemon capable of writing a pid
+#                    file.  To get other behavoirs, implemend
+#                    do_start(), do_stop() or other functions to
+#                    override the defaults in /lib/init/init-d-script.
+### END INIT INFO
+
+# Author: Foo Bar <foobar@baz.org>
+#
+# Please remove the "Author" lines above and replace them
+# with your own name if you copy and modify this script.
+
+DESC="Description of the service"
+DAEMON=/usr/sbin/daemonexecutablename

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: