[lintian] 01/01: c/systemd: Warn about .service files with a potentially missing Install key
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch systemd-service-file-missing-wanted-by
in repository lintian.
commit cc4e77351ce51f99b58555f012c88756b0bd2d5e
Author: Chris Lamb <lamby@debian.org>
Date: Fri Jul 29 09:25:06 2016 -0400
c/systemd: Warn about .service files with a potentially missing Install key
Signed-off-by: Chris Lamb <lamby@debian.org>
---
checks/systemd.desc | 12 ++++++++++++
checks/systemd.pm | 3 +++
.../systemd-complex-service-file/debian/debian/test.service | 2 +-
.../systemd-complex-service-file/debian/debian/test3.service | 3 +++
t/tests/systemd-complex-service-file/desc | 1 +
t/tests/systemd-complex-service-file/tags | 1 +
6 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/checks/systemd.desc b/checks/systemd.desc
index 07dea64..529abb5 100644
--- a/checks/systemd.desc
+++ b/checks/systemd.desc
@@ -126,3 +126,15 @@ Info: The systemd service file does not contain a <tt>Documentation</tt> key.
Documentation for systemd service files can be automatically viewed using
<tt>systemctl help servicename</tt> if this field is present.
Ref: systemd.unit(5)
+
+Tag: systemd-service-file-missing-install-key
+Severity: normal
+Certainty: possible
+Info: The systemd service file does not contain a <tt>WantedBy=</tt> or
+ <tt>RequiredBy=</tt> key in its <tt>[Install]</tt> section.
+ .
+ Forgetting to add such a line (e.g. <tt>WantedBy=multi-user.target</tt>)
+ results in the service file not being started by default.
+ .
+ If this is intentional, please override this warning.
+Ref: systemd.unit(5)
diff --git a/checks/systemd.pm b/checks/systemd.pm
index face504..3de56e5 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -201,6 +201,9 @@ sub check_systemd_service_file {
if (not $file->is_symlink or $file->link ne '/dev/null') {
tag 'systemd-service-file-missing-documentation-key', $file,
unless extract_service_file_values($file, 'Unit', 'Documentation',1);
+ tag 'systemd-service-file-missing-install-key', $file,
+ unless extract_service_file_values($file, 'Install', 'WantedBy',1)
+ or extract_service_file_values($file, 'Install', 'RequiredBy',1);
}
return 1;
diff --git a/t/tests/systemd-complex-service-file/debian/debian/test.service b/t/tests/systemd-complex-service-file/debian/debian/test.service
index e62b6a1..60f401a 100644
--- a/t/tests/systemd-complex-service-file/debian/debian/test.service
+++ b/t/tests/systemd-complex-service-file/debian/debian/test.service
@@ -6,4 +6,4 @@ Documentation=https://www.freedesktop.org/wiki/Software/dbus/
ExecStart=/usr/bin/test
[Install]
-WantedBy=multi-user.target
+RequiredBy=multi-user.target
diff --git a/t/tests/systemd-complex-service-file/debian/debian/test3.service b/t/tests/systemd-complex-service-file/debian/debian/test3.service
index 5fe96f6..3862626 100644
--- a/t/tests/systemd-complex-service-file/debian/debian/test3.service
+++ b/t/tests/systemd-complex-service-file/debian/debian/test3.service
@@ -3,3 +3,6 @@
[Unit]
After=
After = syslog.target
+
+[Install]
+WantedBy=multi-user.target
diff --git a/t/tests/systemd-complex-service-file/desc b/t/tests/systemd-complex-service-file/desc
index 98ec594..f0b46c1 100644
--- a/t/tests/systemd-complex-service-file/desc
+++ b/t/tests/systemd-complex-service-file/desc
@@ -7,3 +7,4 @@ Test-For:
service-key-has-whitespace
systemd-service-file-refers-to-obsolete-target
systemd-service-file-missing-documentation-key
+ systemd-service-file-missing-install-key
diff --git a/t/tests/systemd-complex-service-file/tags b/t/tests/systemd-complex-service-file/tags
index 34cb40a..fafa0e8 100644
--- a/t/tests/systemd-complex-service-file/tags
+++ b/t/tests/systemd-complex-service-file/tags
@@ -1,4 +1,5 @@
E: systemd-complex-service-file: service-key-has-whitespace lib/systemd/system/test3.service at line 3
I: systemd-complex-service-file: systemd-service-file-missing-documentation-key lib/systemd/system/test3.service
+W: systemd-complex-service-file: systemd-service-file-missing-install-key lib/systemd/system/test2.service
W: systemd-complex-service-file: systemd-service-file-refers-to-obsolete-target lib/systemd/system/test.service dbus.target
W: systemd-complex-service-file: systemd-service-file-refers-to-obsolete-target lib/systemd/system/test2.service syslog.target
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: