[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.
nthykier pushed a commit to branch master
in repository lintian.
commit 02aa87d38c6c9169bd8e8766a15c84436255bd85
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>
Signed-off-by: Niels Thykier <niels@thykier.net>
---
checks/systemd.desc | 12 ++++++++++++
checks/systemd.pm | 3 +++
debian/changelog | 4 +++-
.../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 +
7 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/checks/systemd.desc b/checks/systemd.desc
index dadc31d..877bc25 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..b6a2153 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/debian/changelog b/debian/changelog
index 724f81d..2970d51 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,8 +23,10 @@ lintian (2.5.46) UNRELEASED; urgency=medium
+ [JW] Fix typos.
* checks/shared-libs.desc:
+ [JW] Fix typo.
- * checks/systemd.desc:
+ * checks/systemd.{desc,pm}:
+ [JW] Fix typos.
+ + [JW, NT] Apply from Chris Lamb to check for a possibly missing
+ "WantedBy" target in service files. (Closes: #832771)
* checks/watch-file.desc:
+ [JW] Fix typo.
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: