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>
This commit is contained in:
Zhixiong Chi 2023-03-15 20:33:56 -07:00 committed by Khem Raj
parent bf49bdea29
commit 6315006aad
4 changed files with 8 additions and 116 deletions

View File

@ -1,59 +0,0 @@
#!/bin/sh
PATH=/sbin:/bin:/usr/bin:/usr/sbin
test -x /usr/sbin/ntpdate || exit 0
if test -f /etc/default/ntpdate ; then
. /etc/default/ntpdate
fi
if [ "$NTPSERVERS" = "" ] ; then
if [ "$METHOD" = "" -a "$1" != "silent" ] ; then
echo "Please set NTPSERVERS in /etc/default/ntpdate"
exit 1
else
exit 0
fi
fi
# This is a heuristic: The idea is that if a static interface is brought
# up, that is a major event, and we can put in some extra effort to fix
# the system time. Feel free to change this, especially if you regularly
# bring up new network interfaces.
if [ "$METHOD" = static ]; then
OPTS="-b"
fi
if [ "$METHOD" = loopback ]; then
exit 0
fi
(
LOCKFILE=/var/lock/ntpdate
# Avoid running more than one at a time
if [ -x /usr/bin/lockfile-create ]; then
lockfile-create $LOCKFILE
lockfile-touch $LOCKFILE &
LOCKTOUCHPID="$!"
fi
if /usr/sbin/ntpdate -s $OPTS $NTPSERVERS 2>/dev/null; then
if [ "$UPDATE_HWCLOCK" = "yes" ]; then
hwclock --systohc || :
fi
fi
if [ -x /usr/bin/lockfile-create ] ; then
kill $LOCKTOUCHPID
lockfile-remove $LOCKFILE
fi
) &
# wait for all subprocesses to finish
# this is required when using systemd service as ntpd will start before ntpdate finishes
# and results in a bind error (port 123)
wait

View File

@ -1,7 +0,0 @@
# Configuration script used by ntpdate-sync script
NTPSERVERS=""
# Set to "yes" to write time to hardware clock on success
UPDATE_HWCLOCK="no"

View File

@ -1,11 +0,0 @@
[Unit]
Description=Network Time Service (one-shot ntpdate mode)
Before=ntpd.service
[Service]
Type=oneshot
ExecStart=/usr/bin/ntpdate-sync silent
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

View File

@ -18,9 +18,6 @@ SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.g
file://0001-sntp-Fix-types-in-check-for-pthread_detach.patch \
file://ntpd \
file://ntp.conf \
file://ntpdate \
file://ntpdate.default \
file://ntpdate.service \
file://ntpd.service \
file://sntp.service \
file://sntp \
@ -95,18 +92,15 @@ do_install:append() {
install -d ${D}${sysconfdir}/init.d
install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir}
install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d
install -d ${D}${bindir}
install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync
install -m 755 -d ${D}${NTP_USER_HOME}
chown ntp:ntp ${D}${NTP_USER_HOME}
# Fix hardcoded paths in scripts
sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync
sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync
sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd
sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd
sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd
sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd
sed -i '1s,#!.*perl -w,#! ${bindir}/env perl,' ${D}${sbindir}/ntptrace
sed -i '/use/i use warnings;' ${D}${sbindir}/ntptrace
sed -i '1s,#!.*perl,#! ${bindir}/env perl,' ${D}${sbindir}/ntp-wait
@ -115,26 +109,21 @@ do_install:append() {
sed -i '/use/i use warnings;' ${D}${sbindir}/calc_tickadj
install -d ${D}/${sysconfdir}/default
install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate
install -m 0644 ${WORKDIR}/sntp ${D}${sysconfdir}/default/
install -d ${D}/${sysconfdir}/network/if-up.d
ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/ntpdate.service ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/ntpd.service ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/sntp.service ${D}${systemd_unitdir}/system/
install -d ${D}${systemd_unitdir}/ntp-units.d
install -m 0644 ${WORKDIR}/ntpd.list ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list
# Remove an empty libexecdir.
# Remove the empty libexecdir and bindir.
rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
rmdir --ignore-fail-on-non-empty ${D}${bindir}
}
PACKAGES += "ntpdate sntp ntpdc ntpq ${PN}-tickadj ${PN}-utils"
# NOTE: you don't need ntpdate, use "ntpd -q -g -x"
PACKAGES += "sntp ntpdc ntpq ${PN}-tickadj ${PN}-utils"
# ntp originally includes tickadj. It's split off for inclusion in small firmware images on platforms
# with wonky clocks (e.g. OpenSlug)
@ -149,9 +138,8 @@ RCONFLICTS:${PN}-utils = "${PN}-bin"
# ntpdc and ntpq were split out of ntp-utils
RDEPENDS:${PN}-utils = "ntpdc ntpq"
SYSTEMD_PACKAGES = "${PN} ntpdate sntp"
SYSTEMD_PACKAGES = "${PN} sntp"
SYSTEMD_SERVICE:${PN} = "ntpd.service"
SYSTEMD_SERVICE:ntpdate = "ntpdate.service"
SYSTEMD_SERVICE:sntp = "sntp.service"
SYSTEMD_AUTO_ENABLE:sntp = "disable"
@ -159,10 +147,6 @@ RPROVIDES:${PN} += "${PN}-systemd"
RREPLACES:${PN} += "${PN}-systemd"
RCONFLICTS:${PN} += "${PN}-systemd"
RPROVIDES:ntpdate += "ntpdate-systemd"
RREPLACES:ntpdate += "ntpdate-systemd"
RCONFLICTS:ntpdate += "ntpdate-systemd"
RSUGGESTS:${PN} = "iana-etc"
FILES:${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
FILES:${PN}-tickadj = "${sbindir}/tickadj"
FILES:${PN}-utils = "${sbindir} ${datadir}/ntp/lib"
RDEPENDS:${PN}-utils += "perl"
FILES:ntpdate = "${sbindir}/ntpdate \
${sysconfdir}/network/if-up.d/ntpdate-sync \
${bindir}/ntpdate-sync \
${sysconfdir}/default/ntpdate \
${systemd_unitdir}/system/ntpdate.service \
"
FILES:sntp = "${sbindir}/sntp \
${sysconfdir}/default/sntp \
${systemd_unitdir}/system/sntp.service \
@ -186,20 +164,11 @@ FILES:ntpdc = "${sbindir}/ntpdc"
FILES:ntpq = "${sbindir}/ntpq"
CONFFILES:${PN} = "${sysconfdir}/ntp.conf"
CONFFILES:ntpdate = "${sysconfdir}/default/ntpdate"
INITSCRIPT_NAME = "ntpd"
# No dependencies, so just go in at the standard level (20)
INITSCRIPT_PARAMS = "defaults"
pkg_postinst:ntpdate() {
if ! grep -q -s ntpdate $D/var/spool/cron/root; then
echo "adding crontab"
test -d $D/var/spool/cron || mkdir -p $D/var/spool/cron
echo "30 * * * * ${bindir}/ntpdate-sync silent" >> $D/var/spool/cron/root
fi
}
inherit update-alternatives
ALTERNATIVE_PRIORITY = "100"