blob: 53e41297aafa4487eb505aaac121817f7abca7a9 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001SUMMARY = "Network Time Protocol daemon and utilities"
2DESCRIPTION = "The Network Time Protocol (NTP) is used to \
3synchronize the time of a computer client or server to \
4another server or reference time source, such as a radio \
5or satellite receiver or modem."
6HOMEPAGE = "http://support.ntp.org"
7SECTION = "net"
8LICENSE = "NTP"
9LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=e877a1d567a6a58996d2b66e3e387003"
10
11DEPENDS = "libevent"
12
13SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.gz \
14 file://ntp-4.2.4_p6-nano.patch \
15 file://reproducibility-fixed-path-to-posix-shell.patch \
16 file://reproducibility-respect-source-date-epoch.patch \
17 file://ntpd \
18 file://ntp.conf \
19 file://ntpdate \
20 file://ntpdate.default \
21 file://ntpdate.service \
22 file://ntpd.service \
23 file://sntp.service \
24 file://sntp \
25 file://ntpd.list \
26"
27
28SRC_URI[md5sum] = "1522d66574bae14abb2622746dad2bdc"
29SRC_URI[sha256sum] = "709b222b5013d77d26bfff532b5ea470a8039497ef29d09363931c036cb30454"
30
31inherit autotools update-rc.d useradd systemd pkgconfig
32
33# The ac_cv_header_readline_history is to stop ntpdc depending on either
34# readline or curses
35EXTRA_OECONF += "--with-net-snmp-config=no \
36 --without-ntpsnmpd \
37 ac_cv_header_readline_history_h=no \
38 --with-yielding_select=yes \
39 --with-locfile=redhat \
40 --without-rpath \
41 "
42CFLAGS_append = " -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED"
43
44USERADD_PACKAGES = "${PN}"
45NTP_USER_HOME ?= "/var/lib/ntp"
46USERADD_PARAM_${PN} = "--system --home-dir ${NTP_USER_HOME} \
47 --no-create-home \
48 --shell /bin/false --user-group ntp"
49
50# NB: debug is default-enabled by NTP; keep it default-enabled here.
51PACKAGECONFIG ??= "cap debug refclocks openssl \
52 ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
53"
54PACKAGECONFIG[openssl] = "--with-openssl-libdir=${STAGING_LIBDIR} \
55 --with-openssl-incdir=${STAGING_INCDIR} \
56 --with-crypto, \
57 --without-openssl --without-crypto, \
58 openssl"
59PACKAGECONFIG[cap] = "--enable-linuxcaps,--disable-linuxcaps,libcap"
60PACKAGECONFIG[readline] = "--with-lineeditlibs,--without-lineeditlibs,readline"
61PACKAGECONFIG[refclocks] = "--enable-all-clocks,--disable-all-clocks,pps-tools"
62PACKAGECONFIG[debug] = "--enable-debugging,--disable-debugging"
63PACKAGECONFIG[mdns] = "ac_cv_header_dns_sd_h=yes,ac_cv_header_dns_sd_h=no,mdns"
64PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
65
66do_install_append() {
67 install -d ${D}${sysconfdir}/init.d
68 install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir}
69 install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d
70 install -d ${D}${bindir}
71 install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync
72
73 install -m 755 -d ${D}${NTP_USER_HOME}
74 chown ntp:ntp ${D}${NTP_USER_HOME}
75
76 # Fix hardcoded paths in scripts
77 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
78 sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
79 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
80 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
81 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync
82 sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace
83 sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace
84 sed -i '1s,#!.*perl,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait
85 sed -i '/use/i use warnings;' ${D}${sbindir}/ntp-wait
86 sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/calc_tickadj
87 sed -i '/use/i use warnings;' ${D}${sbindir}/calc_tickadj
88
89 install -d ${D}/${sysconfdir}/default
90 install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate
91 install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/
92
93 install -d ${D}/${sysconfdir}/network/if-up.d
94 ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d
95
96 install -d ${D}${systemd_unitdir}/system
97 install -m 0644 ${WORKDIR}/ntpdate.service ${D}${systemd_unitdir}/system/
98 install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/
99 install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/
100
101 install -d ${D}${systemd_unitdir}/ntp-units.d
102 install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list
103
104 # Remove an empty libexecdir.
105 rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
106}
107
108PACKAGES += "ntpdate sntp ${PN}-tickadj ${PN}-utils"
109# NOTE: you don't need ntpdate, use "ntpd -q -g -x"
110
111# ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms
112# with wonky clocks (e.g. OpenSlug)
113RDEPENDS_${PN} = "${PN}-tickadj"
114# ntpd require libgcc for execution
115RDEPENDS_${PN} += "libgcc"
116# Handle move from bin to utils package
117RPROVIDES_${PN}-utils = "${PN}-bin"
118RREPLACES_${PN}-utils = "${PN}-bin"
119RCONFLICTS_${PN}-utils = "${PN}-bin"
120
121SYSTEMD_PACKAGES = "${PN} ntpdate sntp"
122SYSTEMD_SERVICE_${PN} = "ntpd.service"
123SYSTEMD_SERVICE_ntpdate = "ntpdate.service"
124SYSTEMD_SERVICE_sntp = "sntp.service"
125SYSTEMD_AUTO_ENABLE_sntp = "disable"
126
127RPROVIDES_${PN} += "${PN}-systemd"
128RREPLACES_${PN} += "${PN}-systemd"
129RCONFLICTS_${PN} += "${PN}-systemd"
130
131RPROVIDES_ntpdate += "ntpdate-systemd"
132RREPLACES_ntpdate += "ntpdate-systemd"
133RCONFLICTS_ntpdate += "ntpdate-systemd"
134
135RSUGGESTS_${PN} = "iana-etc"
136
137FILES_${PN} = "${sbindir}/ntpd.ntp ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd ${libdir} \
138 ${NTP_USER_HOME} \
139 ${systemd_unitdir}/ntp-units.d/60-ntpd.list ${libexecdir}\
140"
141FILES_${PN}-tickadj = "${sbindir}/tickadj"
142FILES_${PN}-utils = "${sbindir} ${datadir}/ntp/lib"
143RDEPENDS_${PN}-utils += "perl"
144FILES_ntpdate = "${sbindir}/ntpdate \
145 ${sysconfdir}/network/if-up.d/ntpdate-sync \
146 ${bindir}/ntpdate-sync \
147 ${sysconfdir}/default/ntpdate \
148 ${systemd_unitdir}/system/ntpdate.service \
149"
150FILES_sntp = "${sbindir}/sntp \
151 ${sysconfdir}/default/sntp \
152 ${systemd_unitdir}/system/sntp.service \
153 "
154
155CONFFILES_${PN} = "${sysconfdir}/ntp.conf"
156CONFFILES_ntpdate = "${sysconfdir}/default/ntpdate"
157
158INITSCRIPT_NAME = "ntpd"
159# No dependencies, so just go in at the standard level (20)
160INITSCRIPT_PARAMS = "defaults"
161
162pkg_postinst_ntpdate() {
163 if ! grep -q -s ntpdate $D/var/spool/cron/root; then
164 echo "adding crontab"
165 test -d $D/var/spool/cron || mkdir -p $D/var/spool/cron
166 echo "30 * * * * ${bindir}/ntpdate-sync silent" >> $D/var/spool/cron/root
167 fi
168}
169
170inherit update-alternatives
171
172ALTERNATIVE_PRIORITY = "100"
173
174ALTERNATIVE_${PN} = "ntpd"
175ALTERNATIVE_LINK_NAME[ntpd] = "${sbindir}/ntpd"