Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 1 | SUMMARY = "Versatile implementation of the Network Time Protocol" |
| 2 | DESCRIPTION = "Chrony can synchronize the system clock with NTP \ |
| 3 | servers, reference clocks (e.g. GPS receiver), and manual input using \ |
| 4 | wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) \ |
| 5 | server and peer to provide a time service to other computers in the \ |
| 6 | network. \ |
| 7 | \ |
| 8 | It is designed to perform well in a wide range of conditions, \ |
| 9 | including intermittent network connections, heavily congested \ |
| 10 | networks, changing temperatures (ordinary computer clocks are \ |
| 11 | sensitive to temperature), and systems that do not run continuously, or \ |
| 12 | run on a virtual machine. \ |
| 13 | \ |
| 14 | Typical accuracy between two machines on a LAN is in tens, or a few \ |
| 15 | hundreds, of microseconds; over the Internet, accuracy is typically \ |
| 16 | within a few milliseconds. With a good hardware reference clock \ |
| 17 | sub-microsecond accuracy is possible. \ |
| 18 | \ |
| 19 | Two programs are included in chrony: chronyd is a daemon that can be \ |
| 20 | started at boot time and chronyc is a command-line interface program \ |
| 21 | which can be used to monitor chronyd's performance and to change \ |
| 22 | various operating parameters whilst it is running. \ |
| 23 | \ |
| 24 | This recipe produces two binary packages: 'chrony' which contains chronyd, \ |
| 25 | the configuration file and the init script, and 'chronyc' which contains \ |
| 26 | the client program only." |
| 27 | |
| 28 | HOMEPAGE = "https://chrony.tuxfamily.org/" |
| 29 | SECTION = "net" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 30 | LICENSE = "GPL-2.0-only" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 31 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" |
| 32 | |
| 33 | SRC_URI = "https://download.tuxfamily.org/chrony/chrony-${PV}.tar.gz \ |
| 34 | file://chrony.conf \ |
| 35 | file://chronyd \ |
| 36 | file://arm_eabi.patch \ |
| 37 | " |
| 38 | |
| 39 | SRC_URI:append:libc-musl = " \ |
| 40 | file://0001-Fix-compilation-with-musl.patch \ |
| 41 | " |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 42 | SRC_URI[sha256sum] = "eafb07e6daf92b142200f478856dfed6efc9ea2d146eeded5edcb09b93127088" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 43 | |
| 44 | DEPENDS = "pps-tools" |
| 45 | |
| 46 | # Note: Despite being built via './configure; make; make install', |
| 47 | # chrony does not use GNU Autotools. |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 48 | inherit update-rc.d systemd pkgconfig |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 49 | |
| 50 | # Add chronyd user if privdrop packageconfig is selected |
| 51 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'privdrop', 'useradd', '', d)} |
| 52 | USERADD_PACKAGES = "${@bb.utils.contains('PACKAGECONFIG', 'privdrop', '${PN}', '', d)}" |
| 53 | USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'privdrop', '--system -d / -M --shell /bin/nologin chronyd;', '', d)}" |
| 54 | |
| 55 | # Configuration options: |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 56 | # - 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. |
| 62 | PACKAGECONFIG ??= "editline \ |
| 63 | ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \ |
| 64 | " |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 65 | PACKAGECONFIG[editline] = ",--without-editline,libedit" |
| 66 | PACKAGECONFIG[sechash] = "--without-tomcrypt,--disable-sechash,nss" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 67 | PACKAGECONFIG[privdrop] = ",--disable-privdrop,libcap" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 68 | PACKAGECONFIG[scfilter] = "--enable-scfilter,--without-seccomp,libseccomp" |
| 69 | PACKAGECONFIG[ipv6] = ",--disable-ipv6," |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 70 | |
| 71 | # --disable-static isn't supported by chrony's configure script. |
| 72 | DISABLE_STATIC = "" |
| 73 | |
| 74 | do_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 | |
| 84 | do_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 Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 118 | |
| 119 | install -d ${D}${sysconfdir}/tmpfiles.d |
| 120 | echo "d /var/lib/chrony 0755 root root -" > ${D}${sysconfdir}/tmpfiles.d/chronyd.conf |
| 121 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | FILES:${PN} = "${sbindir}/chronyd ${sysconfdir} ${localstatedir}/lib/chrony ${localstatedir}" |
| 125 | CONFFILES:${PN} = "${sysconfdir}/chrony.conf" |
| 126 | INITSCRIPT_NAME = "chronyd" |
| 127 | INITSCRIPT_PARAMS = "defaults" |
| 128 | SYSTEMD_PACKAGES = "${PN}" |
| 129 | SYSTEMD_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. |
| 136 | RCONFLICTS:${PN} = "ntp ntimed" |
| 137 | |
| 138 | # Separate the client program into its own package |
| 139 | PACKAGES =+ "chronyc" |
| 140 | FILES:chronyc = "${bindir}/chronyc" |