Bug#799083: lintian: Please emit when systemd service files are missing a Documentation key
Package: lintian
Version: 2.5.37
Tags: patch
Severity: wishlist
Hi,
Documentation for systemd service files can be "automatically" viewed
using:
$ systemctl help servicename
You can read more here:
http://0pointer.de/blog/projects/self-documented-boot.html
It would be nice if lintian emitted a tag if this is missing. (I first
tried using "Severity: pedantic" but it meant it wasn't testable..?)
Patch attached.
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby@debian.org / chris-lamb.co.uk
`-
diff --git a/checks/systemd.desc b/checks/systemd.desc
index 701ad41..6559bfc 100644
--- a/checks/systemd.desc
+++ b/checks/systemd.desc
@@ -108,3 +108,11 @@ Info: The systemd service file contains space in the key definitions
have been known to break.
.
Please remove the spaces surrounding the key definition.
+
+Tag: systemd-service-file-missing-documentation-key
+Severity: wishlist
+Certainty: certain
+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.
diff --git a/checks/systemd.pm b/checks/systemd.pm
index e59510e..df60074 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -187,6 +187,10 @@ sub check_systemd_service_file {
my @obsolete = grep { /^(?:syslog|dbus)\.target$/ } @values;
tag 'systemd-service-file-refers-to-obsolete-target', $file, $_
for @obsolete;
+
+ tag 'systemd-service-file-missing-documentation-key', $file, unless
+ extract_service_file_values($info, $file, 'Unit', 'Documentation', 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 820b731..35df4d4 100644
--- a/t/tests/systemd-complex-service-file/debian/debian/test.service
+++ b/t/tests/systemd-complex-service-file/debian/debian/test.service
@@ -1,5 +1,6 @@
[Unit]
After=dbus.target
+Documentation=http://www.freedesktop.org/wiki/Software/dbus/
[Service]
ExecStart=/usr/bin/test
diff --git a/t/tests/systemd-complex-service-file/debian/debian/test2.service b/t/tests/systemd-complex-service-file/debian/debian/test2.service
index 71c1297..509e0d8 100644
--- a/t/tests/systemd-complex-service-file/debian/debian/test2.service
+++ b/t/tests/systemd-complex-service-file/debian/debian/test2.service
@@ -3,3 +3,4 @@
[Unit]
After=
After=syslog.target
+Documentation=http://www.freedesktop.org/wiki/Software/dbus/
diff --git a/t/tests/systemd-complex-service-file/desc b/t/tests/systemd-complex-service-file/desc
index d06284f..98ec594 100644
--- a/t/tests/systemd-complex-service-file/desc
+++ b/t/tests/systemd-complex-service-file/desc
@@ -6,3 +6,4 @@ Description: Verifies the .service file parser properly handles .include within
Test-For:
service-key-has-whitespace
systemd-service-file-refers-to-obsolete-target
+ systemd-service-file-missing-documentation-key
diff --git a/t/tests/systemd-complex-service-file/tags b/t/tests/systemd-complex-service-file/tags
index 61a9669..34cb40a 100644
--- a/t/tests/systemd-complex-service-file/tags
+++ b/t/tests/systemd-complex-service-file/tags
@@ -1,3 +1,4 @@
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-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
Reply to: