blob: 420cc78ca4cc6e8157e3083ad8b475d0c7e3765f [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001SUMMARY = "Versatile implementation of the Network Time Protocol"
2DESCRIPTION = "Chrony can synchronize the system clock with NTP \
3servers, reference clocks (e.g. GPS receiver), and manual input using \
4wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) \
5server and peer to provide a time service to other computers in the \
6network. \
7\
8It is designed to perform well in a wide range of conditions, \
9including intermittent network connections, heavily congested \
10networks, changing temperatures (ordinary computer clocks are \
11sensitive to temperature), and systems that do not run continuously, or \
12run on a virtual machine. \
13\
14Typical accuracy between two machines on a LAN is in tens, or a few \
15hundreds, of microseconds; over the Internet, accuracy is typically \
16within a few milliseconds. With a good hardware reference clock \
17sub-microsecond accuracy is possible. \
18\
19Two programs are included in chrony: chronyd is a daemon that can be \
20started at boot time and chronyc is a command-line interface program \
21which can be used to monitor chronyd's performance and to change \
22various operating parameters whilst it is running. \
23\
24This recipe produces two binary packages: 'chrony' which contains chronyd, \
25the configuration file and the init script, and 'chronyc' which contains \
26the client program only."
27
28HOMEPAGE = "https://chrony.tuxfamily.org/"
29SECTION = "net"
Andrew Geissler9aee5002022-03-30 16:27:02 +000030LICENSE = "GPL-2.0-only"
Andrew Geissler595f6302022-01-24 19:11:47 +000031LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
32
33SRC_URI = "https://download.tuxfamily.org/chrony/chrony-${PV}.tar.gz \
34 file://chrony.conf \
35 file://chronyd \
36 file://arm_eabi.patch \
37"
38
39SRC_URI:append:libc-musl = " \
40 file://0001-Fix-compilation-with-musl.patch \
41"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050042SRC_URI[sha256sum] = "9d0da889a865f089a5a21610ffb6713e3c9438ce303a63b49c2fb6eaff5b8804"
Andrew Geissler595f6302022-01-24 19:11:47 +000043
44DEPENDS = "pps-tools"
45
46# Note: Despite being built via './configure; make; make install',
47# chrony does not use GNU Autotools.
Patrick Williams2194f502022-10-16 14:26:09 -050048inherit update-rc.d systemd pkgconfig
Andrew Geissler595f6302022-01-24 19:11:47 +000049
50# Add chronyd user if privdrop packageconfig is selected
51inherit ${@bb.utils.contains('PACKAGECONFIG', 'privdrop', 'useradd', '', d)}
52USERADD_PACKAGES = "${@bb.utils.contains('PACKAGECONFIG', 'privdrop', '${PN}', '', d)}"
53USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'privdrop', '--system -d / -M --shell /bin/nologin chronyd;', '', d)}"
54
55# Configuration options:
Andrew Geissler595f6302022-01-24 19:11:47 +000056# - Security-related:
57# - 'sechash' is omitted by default because it pulls in nss which is huge.
58# - 'privdrop' allows chronyd to run as non-root; would need changes to
59# chrony.conf and init script.
60# - 'scfilter' enables support for system call filtering, but requires the
61# kernel to have CONFIG_SECCOMP enabled.
62PACKAGECONFIG ??= "editline \
63 ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
64"
Andrew Geissler595f6302022-01-24 19:11:47 +000065PACKAGECONFIG[editline] = ",--without-editline,libedit"
66PACKAGECONFIG[sechash] = "--without-tomcrypt,--disable-sechash,nss"
Andrew Geissler517393d2023-01-13 08:55:19 -060067PACKAGECONFIG[privdrop] = ",--disable-privdrop,libcap"
Andrew Geissler595f6302022-01-24 19:11:47 +000068PACKAGECONFIG[scfilter] = "--enable-scfilter,--without-seccomp,libseccomp"
69PACKAGECONFIG[ipv6] = ",--disable-ipv6,"
Andrew Geissler595f6302022-01-24 19:11:47 +000070
71# --disable-static isn't supported by chrony's configure script.
72DISABLE_STATIC = ""
73
74do_configure() {
75 ./configure --sysconfdir=${sysconfdir} --bindir=${bindir} --sbindir=${sbindir} \
76 --localstatedir=${localstatedir} --datarootdir=${datadir} \
77 --with-ntp-era=$(shell date -d '1970-01-01 00:00:00+00:00' +'%s') \
78 --with-pidfile=/run/chrony/chronyd.pid \
79 --chronyrundir=/run/chrony \
80 --host-system=Linux \
81 ${PACKAGECONFIG_CONFARGS}
82}
83
84do_install() {
85 # Binaries
86 install -d ${D}${bindir}
87 install -m 0755 ${S}/chronyc ${D}${bindir}
88 install -d ${D}${sbindir}
89 install -m 0755 ${S}/chronyd ${D}${sbindir}
90
91 # Config file
92 install -d ${D}${sysconfdir}
93 install -m 644 ${WORKDIR}/chrony.conf ${D}${sysconfdir}
94 if ${@bb.utils.contains('PACKAGECONFIG', 'privdrop', 'true', 'false', d)}; then
95 echo "# Define user to drop to after dropping root privileges" >> ${D}${sysconfdir}/chrony.conf
96 echo "user chronyd" >> ${D}${sysconfdir}/chrony.conf
97 fi
98
99 # System V init script
100 install -d ${D}${sysconfdir}/init.d
101 install -m 755 ${WORKDIR}/chronyd ${D}${sysconfdir}/init.d
102
103 # systemd unit configuration file
104 install -d ${D}${systemd_unitdir}/system
105 install -m 0644 ${S}/examples/chronyd.service ${D}${systemd_unitdir}/system/
106
107 # Variable data (for drift and/or rtc file)
108 install -d ${D}${localstatedir}/lib/chrony
109
110 # Fix hard-coded paths in config files and init scripts
111 sed -i -e 's!/var/!${localstatedir}/!g' -e 's!/etc/!${sysconfdir}/!g' \
112 -e 's!/usr/sbin/!${sbindir}/!g' -e 's!/usr/bin/!${bindir}/!g' \
113 ${D}${sysconfdir}/chrony.conf \
114 ${D}${sysconfdir}/init.d/chronyd \
115 ${D}${systemd_unitdir}/system/chronyd.service
116 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/chronyd
117 sed -i 's!^EnvironmentFile=.*!EnvironmentFile=-${sysconfdir}/default/chronyd!' ${D}${systemd_unitdir}/system/chronyd.service
Andrew Geissler615f2f12022-07-15 14:00:58 -0500118
119 install -d ${D}${sysconfdir}/tmpfiles.d
120 echo "d /var/lib/chrony 0755 root root -" > ${D}${sysconfdir}/tmpfiles.d/chronyd.conf
121
Andrew Geissler595f6302022-01-24 19:11:47 +0000122}
123
124FILES:${PN} = "${sbindir}/chronyd ${sysconfdir} ${localstatedir}/lib/chrony ${localstatedir}"
125CONFFILES:${PN} = "${sysconfdir}/chrony.conf"
126INITSCRIPT_NAME = "chronyd"
127INITSCRIPT_PARAMS = "defaults"
128SYSTEMD_PACKAGES = "${PN}"
129SYSTEMD_SERVICE:${PN} = "chronyd.service"
130
131# It's probably a bad idea to run chrony and another time daemon on
132# the same system. systemd includes the SNTP client 'timesyncd', which
133# will be disabled by chronyd.service, however it will remain on the rootfs
134# wasting 150 kB unless you put 'PACKAGECONFIG:remove:pn-systemd = "timesyncd"'
135# in a conf file or bbappend somewhere.
136RCONFLICTS:${PN} = "ntp ntimed"
137
138# Separate the client program into its own package
139PACKAGES =+ "chronyc"
140FILES:chronyc = "${bindir}/chronyc"