diff options
Diffstat (limited to 'meta-networking/recipes-support/ntp/ntp.inc')
-rw-r--r-- | meta-networking/recipes-support/ntp/ntp.inc | 137 |
1 files changed, 137 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 0000000000..49f9901e1e --- /dev/null +++ b/meta-networking/recipes-support/ntp/ntp.inc | |||
@@ -0,0 +1,137 @@ | |||
1 | SUMMARY = "Network Time Protocol daemon and utilities" | ||
2 | DESCRIPTION = "The Network Time Protocol (NTP) is used to \ | ||
3 | synchronize the time of a computer client or server to \ | ||
4 | another server or reference time source, such as a radio \ | ||
5 | or satellite receiver or modem." | ||
6 | HOMEPAGE = "http://support.ntp.org" | ||
7 | SECTION = "console/network" | ||
8 | LICENSE = "NTP" | ||
9 | LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=fea4b50c33b18c2194b4b1c9ca512670" | ||
10 | |||
11 | INC_PR = "r6" | ||
12 | |||
13 | SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.gz \ | ||
14 | file://tickadj.c.patch \ | ||
15 | file://ntp-4.2.4_p6-nano.patch \ | ||
16 | file://openssl-check.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 | |||
28 | inherit autotools update-rc.d useradd systemd | ||
29 | |||
30 | # The ac_cv_header_readline_history is to stop ntpdc depending on either | ||
31 | # readline or curses | ||
32 | EXTRA_OECONF += "--with-net-snmp-config=no --without-ntpsnmpd ac_cv_header_readline_history_h=no --with-binsubdir=sbin" | ||
33 | CFLAGS_append = " -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED" | ||
34 | |||
35 | USERADD_PACKAGES = "${PN}" | ||
36 | USERADD_PARAM_${PN} = "--system --home-dir /var/lib/ntp \ | ||
37 | --shell /bin/false --user-group ntp" | ||
38 | |||
39 | PACKAGECONFIG ??= "cap" | ||
40 | PACKAGECONFIG[openssl] = "--with-openssl-libdir=${STAGING_LIBDIR} \ | ||
41 | --with-openssl-incdir=${STAGING_INCDIR} \ | ||
42 | --with-crypto, \ | ||
43 | --without-openssl --without-crypto, \ | ||
44 | openssl" | ||
45 | PACKAGECONFIG[cap] = "--enable-linuxcaps,--disable-linuxcaps,libcap" | ||
46 | PACKAGECONFIG[readline] = "--with-lineeditlibs,--without-lineeditlibs,readline" | ||
47 | |||
48 | do_install_append() { | ||
49 | install -d ${D}${sysconfdir}/init.d | ||
50 | install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir} | ||
51 | install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d | ||
52 | install -d ${D}${bindir} | ||
53 | install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync | ||
54 | |||
55 | # Fix hardcoded paths in scripts | ||
56 | sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync | ||
57 | sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync | ||
58 | sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync | ||
59 | sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync | ||
60 | sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync | ||
61 | sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace | ||
62 | sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace | ||
63 | sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait | ||
64 | sed -i '/use/i use warnings;' ${D}${sbindir}/ntp-wait | ||
65 | |||
66 | install -d ${D}/${sysconfdir}/default | ||
67 | install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate | ||
68 | install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/ | ||
69 | |||
70 | install -d ${D}/${sysconfdir}/network/if-up.d | ||
71 | ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d | ||
72 | |||
73 | install -d ${D}${systemd_unitdir}/system | ||
74 | install -m 0644 ${WORKDIR}/ntpdate.service ${D}${systemd_unitdir}/system/ | ||
75 | install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/ | ||
76 | install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/ | ||
77 | |||
78 | install -d ${D}${systemd_unitdir}/ntp-units.d | ||
79 | install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list | ||
80 | } | ||
81 | |||
82 | PACKAGES += "ntpdate sntp ${PN}-tickadj ${PN}-utils" | ||
83 | # NOTE: you don't need ntpdate, use "ntpd -q -g -x" | ||
84 | |||
85 | # ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms | ||
86 | # with wonky clocks (e.g. OpenSlug) | ||
87 | RDEPENDS_${PN} = "${PN}-tickadj" | ||
88 | # Handle move from bin to utils package | ||
89 | RPROVIDES_${PN}-utils = "${PN}-bin" | ||
90 | RREPLACES_${PN}-utils = "${PN}-bin" | ||
91 | RCONFLICTS_${PN}-utils = "${PN}-bin" | ||
92 | |||
93 | SYSTEMD_PACKAGES = "${PN} ntpdate sntp" | ||
94 | SYSTEMD_SERVICE_${PN} = "ntpd.service" | ||
95 | SYSTEMD_SERVICE_ntpdate = "ntpdate.service" | ||
96 | SYSTEMD_SERVICE_sntp = "sntp.service" | ||
97 | |||
98 | RPROVIDES_${PN} += "${PN}-systemd" | ||
99 | RREPLACES_${PN} += "${PN}-systemd" | ||
100 | RCONFLICTS_${PN} += "${PN}-systemd" | ||
101 | |||
102 | RPROVIDES_ntpdate += "ntpdate-systemd" | ||
103 | RREPLACES_ntpdate += "ntpdate-systemd" | ||
104 | RCONFLICTS_ntpdate += "ntpdate-systemd" | ||
105 | |||
106 | RSUGGESTS_${PN} = "iana-etc" | ||
107 | |||
108 | FILES_${PN} = "${sbindir}/ntpd ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd ${libdir} \ | ||
109 | ${systemd_unitdir}/ntp-units.d/60-ntpd.list \ | ||
110 | " | ||
111 | FILES_${PN}-tickadj = "${sbindir}/tickadj" | ||
112 | FILES_${PN}-utils = "${sbindir}" | ||
113 | FILES_ntpdate = "${sbindir}/ntpdate \ | ||
114 | ${sysconfdir}/network/if-up.d/ntpdate-sync \ | ||
115 | ${bindir}/ntpdate-sync \ | ||
116 | ${sysconfdir}/default/ntpdate \ | ||
117 | ${systemd_unitdir}/system/ntpdate.service \ | ||
118 | " | ||
119 | FILES_sntp = "${sbindir}/sntp \ | ||
120 | ${sysconfdir}/default/sntp \ | ||
121 | " | ||
122 | |||
123 | CONFFILES_${PN} = "${sysconfdir}/ntp.conf" | ||
124 | CONFFILES_ntpdate = "${sysconfdir}/default/ntpdate" | ||
125 | |||
126 | INITSCRIPT_NAME = "ntpd" | ||
127 | # No dependencies, so just go in at the standard level (20) | ||
128 | INITSCRIPT_PARAMS = "defaults" | ||
129 | |||
130 | pkg_postinst_ntpdate() { | ||
131 | if ! grep -q -s ntpdate $D/var/spool/cron/root; then | ||
132 | echo "adding crontab" | ||
133 | test -d $D/var/spool/cron || mkdir -p $D/var/spool/cron | ||
134 | echo "30 * * * * ${bindir}/ntpdate-sync silent" >> $D/var/spool/cron/root | ||
135 | fi | ||
136 | } | ||
137 | |||