summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support/ntp/ntp.inc
diff options
context:
space:
mode:
Diffstat (limited to 'meta-networking/recipes-support/ntp/ntp.inc')
-rw-r--r--meta-networking/recipes-support/ntp/ntp.inc158
1 files changed, 158 insertions, 0 deletions
diff --git a/meta-networking/recipes-support/ntp/ntp.inc b/meta-networking/recipes-support/ntp/ntp.inc
new file mode 100644
index 000000000..ab7bd9c53
--- /dev/null
+++ b/meta-networking/recipes-support/ntp/ntp.inc
@@ -0,0 +1,158 @@
1SUMMARY = "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 = "console/network"
8LICENSE = "NTP"
9LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=fea4b50c33b18c2194b4b1c9ca512670"
10
11DEPENDS = "pps-tools"
12
13INC_PR = "r6"
14
15SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.gz \
16 file://tickadj.c.patch \
17 file://ntp-4.2.4_p6-nano.patch \
18 file://openssl-check.patch \
19 file://ntpd \
20 file://ntp.conf \
21 file://ntpdate \
22 file://ntpdate.default \
23 file://ntpdate.service \
24 file://ntpd.service \
25 file://sntp.service \
26 file://sntp \
27 file://ntpd.list \
28 file://CVE-2013-5211.patch \
29 file://ntp-4.2.6p5-cve-2014-9293.patch \
30 file://ntp-4.2.6p5-cve-2014-9294.patch \
31 file://ntp-4.2.6p5-cve-2014-9295.patch \
32 file://ntp-4.2.6p5-cve-2014-9296.patch \
33 file://ntp-keygen_no_openssl.patch \
34"
35
36inherit autotools update-rc.d useradd systemd
37
38# The ac_cv_header_readline_history is to stop ntpdc depending on either
39# readline or curses
40EXTRA_OECONF += "--with-net-snmp-config=no \
41 --without-ntpsnmpd \
42 ac_cv_header_readline_history_h=no \
43 --with-binsubdir=sbin"
44
45CFLAGS_append = " -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED"
46
47USERADD_PACKAGES = "${PN}"
48NTP_USER_HOME ?= "/var/lib/ntp"
49USERADD_PARAM_${PN} = "--system --home-dir ${NTP_USER_HOME} \
50 --no-create-home \
51 --shell /bin/false --user-group ntp"
52
53# NB: debug is default-enabled by NTP; keep it default-enabled here.
54PACKAGECONFIG ??= "event cap debug"
55PACKAGECONFIG[openssl] = "--with-openssl-libdir=${STAGING_LIBDIR} \
56 --with-openssl-incdir=${STAGING_INCDIR} \
57 --with-crypto, \
58 --without-openssl --without-crypto, \
59 openssl"
60PACKAGECONFIG[cap] = "--enable-linuxcaps,--disable-linuxcaps,libcap"
61PACKAGECONFIG[readline] = "--with-lineeditlibs,--without-lineeditlibs,readline"
62PACKAGECONFIG[debug] = "--enable-debugging,--disable-debugging"
63PACKAGECONFIG[event] = "--enable-libevent,--disable-libevent, libevent"
64
65do_install_append() {
66 install -d ${D}${sysconfdir}/init.d
67 install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir}
68 install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d
69 install -d ${D}${bindir}
70 install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync
71
72 install -m 755 -d ${D}${NTP_USER_HOME}
73 chown ntp:ntp ${D}${NTP_USER_HOME}
74
75 # Fix hardcoded paths in scripts
76 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
77 sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
78 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
79 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
80 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync
81 sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace
82 sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace
83 sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait
84 sed -i '/use/i use warnings;' ${D}${sbindir}/ntp-wait
85
86 install -d ${D}/${sysconfdir}/default
87 install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate
88 install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/
89
90 install -d ${D}/${sysconfdir}/network/if-up.d
91 ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d
92
93 install -d ${D}${systemd_unitdir}/system
94 install -m 0644 ${WORKDIR}/ntpdate.service ${D}${systemd_unitdir}/system/
95 install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/
96 install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/
97
98 install -d ${D}${systemd_unitdir}/ntp-units.d
99 install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list
100}
101
102PACKAGES += "ntpdate sntp ${PN}-tickadj ${PN}-utils"
103# NOTE: you don't need ntpdate, use "ntpd -q -g -x"
104
105# ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms
106# with wonky clocks (e.g. OpenSlug)
107RDEPENDS_${PN} = "${PN}-tickadj libbsd"
108# Handle move from bin to utils package
109RPROVIDES_${PN}-utils = "${PN}-bin"
110RREPLACES_${PN}-utils = "${PN}-bin"
111RCONFLICTS_${PN}-utils = "${PN}-bin"
112
113SYSTEMD_PACKAGES = "${PN} ntpdate sntp"
114SYSTEMD_SERVICE_${PN} = "ntpd.service"
115SYSTEMD_SERVICE_ntpdate = "ntpdate.service"
116SYSTEMD_SERVICE_sntp = "sntp.service"
117
118RPROVIDES_${PN} += "${PN}-systemd"
119RREPLACES_${PN} += "${PN}-systemd"
120RCONFLICTS_${PN} += "${PN}-systemd"
121
122RPROVIDES_ntpdate += "ntpdate-systemd"
123RREPLACES_ntpdate += "ntpdate-systemd"
124RCONFLICTS_ntpdate += "ntpdate-systemd"
125
126RSUGGESTS_${PN} = "iana-etc"
127
128FILES_${PN} = "${sbindir}/ntpd ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd ${libdir} \
129 ${NTP_USER_HOME} \
130 ${systemd_unitdir}/ntp-units.d/60-ntpd.list \
131"
132FILES_${PN}-tickadj = "${sbindir}/tickadj"
133FILES_${PN}-utils = "${sbindir}"
134FILES_ntpdate = "${sbindir}/ntpdate \
135 ${sysconfdir}/network/if-up.d/ntpdate-sync \
136 ${bindir}/ntpdate-sync \
137 ${sysconfdir}/default/ntpdate \
138 ${systemd_unitdir}/system/ntpdate.service \
139"
140FILES_sntp = "${sbindir}/sntp \
141 ${sysconfdir}/default/sntp \
142 "
143
144CONFFILES_${PN} = "${sysconfdir}/ntp.conf"
145CONFFILES_ntpdate = "${sysconfdir}/default/ntpdate"
146
147INITSCRIPT_NAME = "ntpd"
148# No dependencies, so just go in at the standard level (20)
149INITSCRIPT_PARAMS = "defaults"
150
151pkg_postinst_ntpdate() {
152 if ! grep -q -s ntpdate $D/var/spool/cron/root; then
153 echo "adding crontab"
154 test -d $D/var/spool/cron || mkdir -p $D/var/spool/cron
155 echo "30 * * * * ${bindir}/ntpdate-sync silent" >> $D/var/spool/cron/root
156 fi
157}
158