blob: 57dd635dc384b6c6a61fb24449e50f398263ab5c [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"
42SRC_URI[sha256sum] = "273f9fd15c328ed6f3a5f6ba6baec35a421a34a73bb725605329b1712048db9a"
43
44DEPENDS = "pps-tools"
45
46# Note: Despite being built via './configure; make; make install',
47# chrony does not use GNU Autotools.
48inherit update-rc.d systemd
49
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:
56# - For command line editing support in chronyc, you may specify either
57# 'editline' or 'readline' but not both. editline is smaller, but
58# many systems already have readline for other purposes so you might want
59# to choose that instead. However, beware license incompatibility
60# since chrony is GPLv2 and readline versions after 6.0 are GPLv3+.
61# You can of course choose neither, but if you're that tight on space
62# consider dropping chronyc entirely (you can use it remotely with
63# appropriate chrony.conf options).
64# - Security-related:
65# - 'sechash' is omitted by default because it pulls in nss which is huge.
66# - 'privdrop' allows chronyd to run as non-root; would need changes to
67# chrony.conf and init script.
68# - 'scfilter' enables support for system call filtering, but requires the
69# kernel to have CONFIG_SECCOMP enabled.
70PACKAGECONFIG ??= "editline \
71 ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
72"
73PACKAGECONFIG[readline] = "--without-editline,--without-readline,readline"
74PACKAGECONFIG[editline] = ",--without-editline,libedit"
75PACKAGECONFIG[sechash] = "--without-tomcrypt,--disable-sechash,nss"
76PACKAGECONFIG[privdrop] = "--with-libcap,--disable-privdrop --without-libcap,libcap"
77PACKAGECONFIG[scfilter] = "--enable-scfilter,--without-seccomp,libseccomp"
78PACKAGECONFIG[ipv6] = ",--disable-ipv6,"
79PACKAGECONFIG[nss] = "--with-nss,--without-nss,nss"
80PACKAGECONFIG[libcap] = "--with-libcap,--without-libcap,libcap"
81
82# --disable-static isn't supported by chrony's configure script.
83DISABLE_STATIC = ""
84
85do_configure() {
86 ./configure --sysconfdir=${sysconfdir} --bindir=${bindir} --sbindir=${sbindir} \
87 --localstatedir=${localstatedir} --datarootdir=${datadir} \
88 --with-ntp-era=$(shell date -d '1970-01-01 00:00:00+00:00' +'%s') \
89 --with-pidfile=/run/chrony/chronyd.pid \
90 --chronyrundir=/run/chrony \
91 --host-system=Linux \
92 ${PACKAGECONFIG_CONFARGS}
93}
94
95do_install() {
96 # Binaries
97 install -d ${D}${bindir}
98 install -m 0755 ${S}/chronyc ${D}${bindir}
99 install -d ${D}${sbindir}
100 install -m 0755 ${S}/chronyd ${D}${sbindir}
101
102 # Config file
103 install -d ${D}${sysconfdir}
104 install -m 644 ${WORKDIR}/chrony.conf ${D}${sysconfdir}
105 if ${@bb.utils.contains('PACKAGECONFIG', 'privdrop', 'true', 'false', d)}; then
106 echo "# Define user to drop to after dropping root privileges" >> ${D}${sysconfdir}/chrony.conf
107 echo "user chronyd" >> ${D}${sysconfdir}/chrony.conf
108 fi
109
110 # System V init script
111 install -d ${D}${sysconfdir}/init.d
112 install -m 755 ${WORKDIR}/chronyd ${D}${sysconfdir}/init.d
113
114 # systemd unit configuration file
115 install -d ${D}${systemd_unitdir}/system
116 install -m 0644 ${S}/examples/chronyd.service ${D}${systemd_unitdir}/system/
117
118 # Variable data (for drift and/or rtc file)
119 install -d ${D}${localstatedir}/lib/chrony
120
121 # Fix hard-coded paths in config files and init scripts
122 sed -i -e 's!/var/!${localstatedir}/!g' -e 's!/etc/!${sysconfdir}/!g' \
123 -e 's!/usr/sbin/!${sbindir}/!g' -e 's!/usr/bin/!${bindir}/!g' \
124 ${D}${sysconfdir}/chrony.conf \
125 ${D}${sysconfdir}/init.d/chronyd \
126 ${D}${systemd_unitdir}/system/chronyd.service
127 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/chronyd
128 sed -i 's!^EnvironmentFile=.*!EnvironmentFile=-${sysconfdir}/default/chronyd!' ${D}${systemd_unitdir}/system/chronyd.service
129}
130
131FILES:${PN} = "${sbindir}/chronyd ${sysconfdir} ${localstatedir}/lib/chrony ${localstatedir}"
132CONFFILES:${PN} = "${sysconfdir}/chrony.conf"
133INITSCRIPT_NAME = "chronyd"
134INITSCRIPT_PARAMS = "defaults"
135SYSTEMD_PACKAGES = "${PN}"
136SYSTEMD_SERVICE:${PN} = "chronyd.service"
137
138# It's probably a bad idea to run chrony and another time daemon on
139# the same system. systemd includes the SNTP client 'timesyncd', which
140# will be disabled by chronyd.service, however it will remain on the rootfs
141# wasting 150 kB unless you put 'PACKAGECONFIG:remove:pn-systemd = "timesyncd"'
142# in a conf file or bbappend somewhere.
143RCONFLICTS:${PN} = "ntp ntimed"
144
145# Separate the client program into its own package
146PACKAGES =+ "chronyc"
147FILES:chronyc = "${bindir}/chronyc"