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:
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.
(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".
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.
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…
Patch sent to the ml for review: http://thread.gmane.org/gmane.linux.gentoo.systemd/11
Created attachment 361404 [details, diff] Patch rev1
+ 22 Oct 2013; Michał Górny <mgorny@gentoo.org> systemd.eclass: + Add systemd_enable_ntpunit wrt bug #458132.