summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhixiong Chi <zhixiong.chi@windriver.com>2023-03-15 20:33:56 -0700
committerKhem Raj <raj.khem@gmail.com>2023-03-17 07:06:56 -0700
commit6315006aadd52e44c15986c9e00ca8162623be85 (patch)
tree16ec47c8d19b03836e689dd17398045b6a12a8ac
parentbf49bdea290ba8cf18f3fd6b47d1d71dfe499948 (diff)
downloadmeta-openembedded-6315006aadd52e44c15986c9e00ca8162623be85.tar.gz
ntp: drop the deprecated ntpdate
The combination of ntpd and sntp now implements the functions of ntpdate, which has been deprecated. Now we don't need ntpdate anymore, and we can use the following command 'ntpd -q -g -x' instead. So drop the related section of ntpdate now. Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rwxr-xr-xmeta-networking/recipes-support/ntp/ntp/ntpdate59
-rw-r--r--meta-networking/recipes-support/ntp/ntp/ntpdate.default7
-rw-r--r--meta-networking/recipes-support/ntp/ntp/ntpdate.service11
-rw-r--r--meta-networking/recipes-support/ntp/ntp_4.2.8p15.bb47
4 files changed, 8 insertions, 116 deletions
diff --git a/meta-networking/recipes-support/ntp/ntp/ntpdate b/meta-networking/recipes-support/ntp/ntp/ntpdate
deleted file mode 100755
index be3bacfcd1..0000000000
--- a/meta-networking/recipes-support/ntp/ntp/ntpdate
+++ /dev/null
@@ -1,59 +0,0 @@
1#!/bin/sh
2
3PATH=/sbin:/bin:/usr/bin:/usr/sbin
4
5test -x /usr/sbin/ntpdate || exit 0
6
7if test -f /etc/default/ntpdate ; then
8. /etc/default/ntpdate
9fi
10
11if [ "$NTPSERVERS" = "" ] ; then
12 if [ "$METHOD" = "" -a "$1" != "silent" ] ; then
13 echo "Please set NTPSERVERS in /etc/default/ntpdate"
14 exit 1
15 else
16 exit 0
17 fi
18fi
19
20# This is a heuristic: The idea is that if a static interface is brought
21# up, that is a major event, and we can put in some extra effort to fix
22# the system time. Feel free to change this, especially if you regularly
23# bring up new network interfaces.
24if [ "$METHOD" = static ]; then
25 OPTS="-b"
26fi
27
28if [ "$METHOD" = loopback ]; then
29 exit 0
30fi
31
32(
33
34LOCKFILE=/var/lock/ntpdate
35
36# Avoid running more than one at a time
37if [ -x /usr/bin/lockfile-create ]; then
38 lockfile-create $LOCKFILE
39 lockfile-touch $LOCKFILE &
40 LOCKTOUCHPID="$!"
41fi
42
43if /usr/sbin/ntpdate -s $OPTS $NTPSERVERS 2>/dev/null; then
44 if [ "$UPDATE_HWCLOCK" = "yes" ]; then
45 hwclock --systohc || :
46 fi
47fi
48
49if [ -x /usr/bin/lockfile-create ] ; then
50 kill $LOCKTOUCHPID
51 lockfile-remove $LOCKFILE
52fi
53
54) &
55
56# wait for all subprocesses to finish
57# this is required when using systemd service as ntpd will start before ntpdate finishes
58# and results in a bind error (port 123)
59wait
diff --git a/meta-networking/recipes-support/ntp/ntp/ntpdate.default b/meta-networking/recipes-support/ntp/ntp/ntpdate.default
deleted file mode 100644
index 486b6e07d3..0000000000
--- a/meta-networking/recipes-support/ntp/ntp/ntpdate.default
+++ /dev/null
@@ -1,7 +0,0 @@
1# Configuration script used by ntpdate-sync script
2
3NTPSERVERS=""
4
5# Set to "yes" to write time to hardware clock on success
6UPDATE_HWCLOCK="no"
7
diff --git a/meta-networking/recipes-support/ntp/ntp/ntpdate.service b/meta-networking/recipes-support/ntp/ntp/ntpdate.service
deleted file mode 100644
index 10cbd70f99..0000000000
--- a/meta-networking/recipes-support/ntp/ntp/ntpdate.service
+++ /dev/null
@@ -1,11 +0,0 @@
1[Unit]
2Description=Network Time Service (one-shot ntpdate mode)
3Before=ntpd.service
4
5[Service]
6Type=oneshot
7ExecStart=/usr/bin/ntpdate-sync silent
8RemainAfterExit=yes
9
10[Install]
11WantedBy=multi-user.target
diff --git a/meta-networking/recipes-support/ntp/ntp_4.2.8p15.bb b/meta-networking/recipes-support/ntp/ntp_4.2.8p15.bb
index 2ae53dc640..3ce2d77df7 100644
--- a/meta-networking/recipes-support/ntp/ntp_4.2.8p15.bb
+++ b/meta-networking/recipes-support/ntp/ntp_4.2.8p15.bb
@@ -18,9 +18,6 @@ SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.g
18 file://0001-sntp-Fix-types-in-check-for-pthread_detach.patch \ 18 file://0001-sntp-Fix-types-in-check-for-pthread_detach.patch \
19 file://ntpd \ 19 file://ntpd \
20 file://ntp.conf \ 20 file://ntp.conf \
21 file://ntpdate \
22 file://ntpdate.default \
23 file://ntpdate.service \
24 file://ntpd.service \ 21 file://ntpd.service \
25 file://sntp.service \ 22 file://sntp.service \
26 file://sntp \ 23 file://sntp \
@@ -95,18 +92,15 @@ do_install:append() {
95 install -d ${D}${sysconfdir}/init.d 92 install -d ${D}${sysconfdir}/init.d
96 install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir} 93 install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir}
97 install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d 94 install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d
98 install -d ${D}${bindir}
99 install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync
100 95
101 install -m 755 -d ${D}${NTP_USER_HOME} 96 install -m 755 -d ${D}${NTP_USER_HOME}
102 chown ntp:ntp ${D}${NTP_USER_HOME} 97 chown ntp:ntp ${D}${NTP_USER_HOME}
103 98
104 # Fix hardcoded paths in scripts 99 # Fix hardcoded paths in scripts
105 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync 100 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd
106 sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync 101 sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd
107 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync 102 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd
108 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync 103 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd
109 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync
110 sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace 104 sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace
111 sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace 105 sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace
112 sed -i '1s,#!.*perl,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait 106 sed -i '1s,#!.*perl,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait
@@ -115,26 +109,21 @@ do_install:append() {
115 sed -i '/use/i use warnings;' ${D}${sbindir}/calc_tickadj 109 sed -i '/use/i use warnings;' ${D}${sbindir}/calc_tickadj
116 110
117 install -d ${D}/${sysconfdir}/default 111 install -d ${D}/${sysconfdir}/default
118 install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate
119 install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/ 112 install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/
120 113
121 install -d ${D}/${sysconfdir}/network/if-up.d
122 ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d
123
124 install -d ${D}${systemd_unitdir}/system 114 install -d ${D}${systemd_unitdir}/system
125 install -m 0644 ${WORKDIR}/ntpdate.service ${D}${systemd_unitdir}/system/
126 install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/ 115 install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/
127 install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/ 116 install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/
128 117
129 install -d ${D}${systemd_unitdir}/ntp-units.d 118 install -d ${D}${systemd_unitdir}/ntp-units.d
130 install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list 119 install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list
131 120
132 # Remove an empty libexecdir. 121 # Remove the empty libexecdir and bindir.
133 rmdir --ignore-fail-on-non-empty ${D}${libexecdir} 122 rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
123 rmdir --ignore-fail-on-non-empty ${D}${bindir}
134} 124}
135 125
136PACKAGES += "ntpdate sntp ntpdc ntpq ${PN}-tickadj ${PN}-utils" 126PACKAGES += "sntp ntpdc ntpq ${PN}-tickadj ${PN}-utils"
137# NOTE: you don't need ntpdate, use "ntpd -q -g -x"
138 127
139# ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms 128# ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms
140# with wonky clocks (e.g. OpenSlug) 129# with wonky clocks (e.g. OpenSlug)
@@ -149,9 +138,8 @@ RCONFLICTS:${PN}-utils = "${PN}-bin"
149# ntpdc and ntpq were split out of ntp-utils 138# ntpdc and ntpq were split out of ntp-utils
150RDEPENDS:${PN}-utils = "ntpdc ntpq" 139RDEPENDS:${PN}-utils = "ntpdc ntpq"
151 140
152SYSTEMD_PACKAGES = "${PN} ntpdate sntp" 141SYSTEMD_PACKAGES = "${PN} sntp"
153SYSTEMD_SERVICE:${PN} = "ntpd.service" 142SYSTEMD_SERVICE:${PN} = "ntpd.service"
154SYSTEMD_SERVICE:ntpdate = "ntpdate.service"
155SYSTEMD_SERVICE:sntp = "sntp.service" 143SYSTEMD_SERVICE:sntp = "sntp.service"
156SYSTEMD_AUTO_ENABLE:sntp = "disable" 144SYSTEMD_AUTO_ENABLE:sntp = "disable"
157 145
@@ -159,10 +147,6 @@ RPROVIDES:${PN} += "${PN}-systemd"
159RREPLACES:${PN} += "${PN}-systemd" 147RREPLACES:${PN} += "${PN}-systemd"
160RCONFLICTS:${PN} += "${PN}-systemd" 148RCONFLICTS:${PN} += "${PN}-systemd"
161 149
162RPROVIDES:ntpdate += "ntpdate-systemd"
163RREPLACES:ntpdate += "ntpdate-systemd"
164RCONFLICTS:ntpdate += "ntpdate-systemd"
165
166RSUGGESTS:${PN} = "iana-etc" 150RSUGGESTS:${PN} = "iana-etc"
167 151
168FILES:${PN} = "${sbindir}/ntpd.ntp ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd \ 152FILES:${PN} = "${sbindir}/ntpd.ntp ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd \
@@ -172,12 +156,6 @@ FILES:${PN} = "${sbindir}/ntpd.ntp ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/n
172FILES:${PN}-tickadj = "${sbindir}/tickadj" 156FILES:${PN}-tickadj = "${sbindir}/tickadj"
173FILES:${PN}-utils = "${sbindir} ${datadir}/ntp/lib" 157FILES:${PN}-utils = "${sbindir} ${datadir}/ntp/lib"
174RDEPENDS:${PN}-utils += "perl" 158RDEPENDS:${PN}-utils += "perl"
175FILES:ntpdate = "${sbindir}/ntpdate \
176 ${sysconfdir}/network/if-up.d/ntpdate-sync \
177 ${bindir}/ntpdate-sync \
178 ${sysconfdir}/default/ntpdate \
179 ${systemd_unitdir}/system/ntpdate.service \
180"
181FILES:sntp = "${sbindir}/sntp \ 159FILES:sntp = "${sbindir}/sntp \
182 ${sysconfdir}/default/sntp \ 160 ${sysconfdir}/default/sntp \
183 ${systemd_unitdir}/system/sntp.service \ 161 ${systemd_unitdir}/system/sntp.service \
@@ -186,20 +164,11 @@ FILES:ntpdc = "${sbindir}/ntpdc"
186FILES:ntpq = "${sbindir}/ntpq" 164FILES:ntpq = "${sbindir}/ntpq"
187 165
188CONFFILES:${PN} = "${sysconfdir}/ntp.conf" 166CONFFILES:${PN} = "${sysconfdir}/ntp.conf"
189CONFFILES:ntpdate = "${sysconfdir}/default/ntpdate"
190 167
191INITSCRIPT_NAME = "ntpd" 168INITSCRIPT_NAME = "ntpd"
192# No dependencies, so just go in at the standard level (20) 169# No dependencies, so just go in at the standard level (20)
193INITSCRIPT_PARAMS = "defaults" 170INITSCRIPT_PARAMS = "defaults"
194 171
195pkg_postinst:ntpdate() {
196 if ! grep -q -s ntpdate $D/var/spool/cron/root; then
197 echo "adding crontab"
198 test -d $D/var/spool/cron || mkdir -p $D/var/spool/cron
199 echo "30 * * * * ${bindir}/ntpdate-sync silent" >> $D/var/spool/cron/root
200 fi
201}
202
203inherit update-alternatives 172inherit update-alternatives
204 173
205ALTERNATIVE_PRIORITY = "100" 174ALTERNATIVE_PRIORITY = "100"