Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 458132 - systemd.eclass: add support for ntp-units.d
Summary: systemd.eclass: add support for ntp-units.d
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo systemd Team
URL: http://thread.gmane.org/gmane.linux.g...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-18 16:29 UTC by Kacper Kowalik (Xarthisius) (RETIRED)
Modified: 2013-10-22 15:14 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch rev1 (0001-Add-systemd_enable_ntpunit-to-add-NTP-units.patch,2.08 KB, patch)
2013-10-20 06:35 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kacper Kowalik (Xarthisius) (RETIRED) gentoo-dev 2013-02-18 16:29:50 UTC
Ntp providers are treated in a special way in systemd (stolen from [1]):

For NTP daemons, systemd-timedated requires an additional file in /usr/lib/systemd/ntp-units.d. It should be named after the package it belongs to (with a .list suffix), and contain the name of the service which starts the NTP daemon itself.

[1] https://wiki.archlinux.org/index.php/DeveloperWiki:Systemd#ntp-units.d

As a first pass I propose:

Index: systemd.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v
retrieving revision 1.21
diff -u -B -r1.21 systemd.eclass
--- systemd.eclass	31 Dec 2012 13:09:09 -0000	1.21
+++ systemd.eclass	4 Feb 2013 10:17:13 -0000
@@ -86,6 +86,25 @@
 	doins "${@}"
 }
 
+# @FUNCTION: systemd_ntpunit
+# @USAGE: listname service
+# @DESCRIPTION:
+# For NTP daemons, systemd-timedated requires an additional file in
+# /usr/lib/systemd/ntp-units.d. It should be named after the package it belongs
+# to (with a .list suffix), and contain the name of the service which starts the
+# NTP daemon itself.
+systemd_ntpunit() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local listname=${1}
+	local service=${2}
+	echo "${service}.service" > "${T}/${listname}.list"
+
+	local INSDESTTREE
+	insinto "$(_systemd_get_unitdir)"/ntp-units.d
+	doins "${T}/${listname}.list"
+}
+
 # @FUNCTION: systemd_newunit
 # @USAGE: oldname newname
 # @DESCRIPTION:
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-02-22 09:38:16 UTC
It seems that this lacks proper documentation. Source code tells me a single ntp-units.d file can contain multiple providers, and the daemon simply concatenates the list from all files there.

I'd assume that an NTP daemon with 'native' systemd install should install ntp-units.d file along with the unit, correct? Assuming that, I'd say we could simply give systemd_dontpunit().

That function would install the unit using systemd_dounit() and add installed using name to ntp-units.d file. I'm not sure if the name of the latter file is really important, we could just put ${PN} there, I guess.
Comment 2 Mike Gilbert gentoo-dev 2013-02-22 16:31:27 UTC
(In reply to comment #1)
> It seems that this lacks proper documentation. Source code tells me a single
> ntp-units.d file can contain multiple providers, and the daemon simply
> concatenates the list from all files there.
> 

Documentation is here:

http://www.freedesktop.org/wiki/Software/systemd/timedated

Basically, the order (lexograpically) of the files controls which service is started when you run "timedatectl set-ntp true".
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-02-27 22:15:13 UTC
Hmm, I wonder if we actually want to decide on the order.

If yes, then I think that's mostly fine. It would need a few changes though:

1) parameter checking.

2) I think we shouldn't append '.service', take the full name instead.

3) the description should note that 'listname' is expected to be NN-something.

4) the name... it should somehow explicitly state it's not a function 'just' installing a file but creating it.
Comment 4 Kirill Elagin 2013-10-19 18:30:53 UTC
It seems to me that half a year of making design decisions is a bit too much for a function required by three packages to put one one-line file each…
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-10-19 21:06:40 UTC
Patch sent to the ml for review:

http://thread.gmane.org/gmane.linux.gentoo.systemd/11
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-10-20 06:35:08 UTC
Created attachment 361404 [details, diff]
Patch rev1
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-10-22 15:14:52 UTC
+  22 Oct 2013; Michał Górny <mgorny@gentoo.org> systemd.eclass:
+  Add systemd_enable_ntpunit wrt bug #458132.