From 076251ff56a2cd53ec3b87ee54fd3f23e47d772e Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Wed, 15 Dec 2021 19:51:49 +0100 Subject: [PATCH] net-misc/ntp: Apply Flatcar modifications - Check out our previous ntp.conf and service units - Disable USE=threads - Add USE=perl, disabled to skip the scripts subdir - Do the /etc -> /usr/share + tmpfiles dance for ntp.conf - Drop unused init scripts and pkg_postinst --- .../net-misc/ntp/files/ntp-client.confd | 21 --------- .../net-misc/ntp/files/ntp-client.rc | 31 ------------ .../net-misc/ntp/files/ntp.conf | 47 +++---------------- .../net-misc/ntp/files/ntpd.confd | 6 --- .../net-misc/ntp/files/ntpd.rc-r1 | 22 --------- .../net-misc/ntp/files/ntpd.service-r2 | 11 ----- .../net-misc/ntp/files/ntpdate.service-r2 | 14 ------ .../net-misc/ntp/files/ntpdate.service.conf | 2 - .../net-misc/ntp/files/sntp.confd | 4 -- .../coreos-overlay/net-misc/ntp/files/sntp.rc | 26 ---------- .../net-misc/ntp/files/sntp.service-r3 | 14 ------ .../net-misc/ntp/files/sntp.service.conf | 2 - .../net-misc/ntp/ntp-4.2.8_p15.ebuild | 39 ++++----------- 13 files changed, 16 insertions(+), 223 deletions(-) delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.confd delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.rc delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.confd delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.rc-r1 delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.service-r2 delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service-r2 delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service.conf delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.confd delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.rc delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service-r3 delete mode 100644 sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service.conf diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.confd b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.confd deleted file mode 100644 index 786004da83..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.confd +++ /dev/null @@ -1,21 +0,0 @@ -# /etc/conf.d/ntp-client - -# Command to run to set the clock initially -# Most people should just leave this line alone ... -# however, if you know what you're doing, and you -# want to use ntpd to set the clock, change this to 'ntpd' -NTPCLIENT_CMD="ntpdate" - -# Options to pass to the above command -# This default setting should work fine but you should -# change the default 'pool.ntp.org' to something closer -# to your machine. See http://www.pool.ntp.org/ or -# try running `netselect -s 3 pool.ntp.org`. -NTPCLIENT_OPTS="-s -b -u \ - 0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org \ - 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org" - -# If you use hostnames above, then you should depend on dns -# being up & running before we try to run. Otherwise, you -# can disable this. -rc_use="dns" diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.rc b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.rc deleted file mode 100644 index 5b5d594473..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp-client.rc +++ /dev/null @@ -1,31 +0,0 @@ -#!/sbin/openrc-run -# Copyright 1999-2013 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -depend() { - before cron portmap - after net - use dns logger -} - -checkconfig() { - if ! type "${NTPCLIENT_CMD}" >/dev/null 2>&1 ; then - eerror "Please edit /etc/conf.d/ntp-client" - eerror "Unable to locate the client command ${NTPCLIENT_CMD}!" - return 1 - fi - if [ -z "${NTPCLIENT_OPTS}" ] ; then - eerror "Please edit /etc/conf.d/ntp-client" - eerror "I need to know what server/options to use!" - return 1 - fi - return 0 -} - -start() { - checkconfig || return $? - - ebegin "Setting clock via the NTP client '${NTPCLIENT_CMD}'" - "${NTPCLIENT_CMD}" ${NTPCLIENT_OPTS} - eend $? "Failed to set clock" -} diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp.conf b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp.conf index 97bed8dd13..c0cd2271f9 100644 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp.conf +++ b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntp.conf @@ -1,34 +1,8 @@ -# NOTES: -# DHCP clients can append or replace NTP configuration files. -# You should consult your DHCP client documentation about its -# default behaviour and how to change it. - -# Name of the servers ntpd should sync with -# Please respect the access policy as stated by the responsible person. -#server ntp.example.tld iburst - -# Common pool for random people -#server pool.ntp.org - -# Pools for Gentoo users -server 0.gentoo.pool.ntp.org -server 1.gentoo.pool.ntp.org -server 2.gentoo.pool.ntp.org -server 3.gentoo.pool.ntp.org - -## -# A list of available servers can be found here: -# http://www.pool.ntp.org/ -# http://www.pool.ntp.org/#use -# A good way to get servers for your machine is: -# netselect -s 3 pool.ntp.org -## - -# you should not need to modify the following paths -driftfile /var/lib/ntp/ntp.drift - -#server ntplocal.example.com prefer -#server timeserver.example.org +# Common pool +server 0.flatcar.pool.ntp.org +server 1.flatcar.pool.ntp.org +server 2.flatcar.pool.ntp.org +server 3.flatcar.pool.ntp.org # Warning: Using default NTP settings will leave your NTP # server accessible to all hosts on the Internet. @@ -37,18 +11,9 @@ driftfile /var/lib/ntp/ntp.drift # from accessing the NTP server, uncomment: #restrict default ignore - # Default configuration: # - Allow only time queries, at a limited rate, sending KoD when in excess. # - Allow all local queries (IPv4, IPv6) -restrict default nomodify nopeer noquery limited kod +restrict default nomodify nopeer noquery notrap limited kod restrict 127.0.0.1 restrict [::1] - - -# To allow machines within your network to synchronize -# their clocks with your server, but ensure they are -# not allowed to configure the server or used as peers -# to synchronize against, uncomment this line. -# -#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.confd b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.confd deleted file mode 100644 index 2b74282c57..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.confd +++ /dev/null @@ -1,6 +0,0 @@ -# /etc/conf.d/ntpd - -# Options to pass to the ntpd process -# Most people should leave this line alone ... -# however, if you know what you're doing, feel free to tweak -NTPD_OPTS="-g -u ntp:ntp" diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.rc-r1 b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.rc-r1 deleted file mode 100644 index 7573411c99..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.rc-r1 +++ /dev/null @@ -1,22 +0,0 @@ -#!/sbin/openrc-run -# Copyright 1999-2016 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -description="ntpd - the network time protocol daemon" -pidfile="/var/run/ntpd.pid" -command="/usr/sbin/ntpd" -command_args="-p ${pidfile} ${NTPD_OPTS}" -start_stop_daemon_args="--pidfile ${pidfile}" - -depend() { - use net dns logger - after ntp-client -} - -start_pre() { - if [ ! -f /etc/ntp.conf ] ; then - eerror "Please create /etc/ntp.conf" - return 1 - fi - return 0 -} diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.service-r2 b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.service-r2 deleted file mode 100644 index 5f11b27e92..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpd.service-r2 +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Network Time Service -After=ntpdate.service sntp.service -Conflicts=systemd-timesyncd.service - -[Service] -ExecStart=/usr/sbin/ntpd -g -n -PrivateTmp=true - -[Install] -WantedBy=multi-user.target diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service-r2 b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service-r2 deleted file mode 100644 index 7ad294eccd..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service-r2 +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Set time via NTP using ntpdate -After=network-online.target nss-lookup.target -Before=time-sync.target -Wants=network-online.target time-sync.target -Conflicts=systemd-timesyncd.service - -[Service] -Type=oneshot -ExecStart=/usr/sbin/ntpdate -b -u $SERVER -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service.conf b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service.conf deleted file mode 100644 index 75e4f41b41..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/ntpdate.service.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Service] -Environment="SERVER=0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org" diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.confd b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.confd deleted file mode 100644 index d11983a3fb..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.confd +++ /dev/null @@ -1,4 +0,0 @@ -# /etc/conf.d/sntp - -# Options to pass to sntp -SNTP_OPTS="-s 0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org" diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.rc b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.rc deleted file mode 100644 index 4ed56ae2bf..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.rc +++ /dev/null @@ -1,26 +0,0 @@ -#!/sbin/openrc-run -# Copyright 1999-2016 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -command="/usr/bin/sntp" - -depend() { - before cron portmap - after net - use dns logger -} - -start_pre() { - if [ -z "${SNTP_OPTS}" ] ; then - eerror "Please edit /etc/conf.d/sntp" - eerror "I need to know what server/options to use!" - return 1 - fi - return 0 -} - -start() { - ebegin "Setting clock via SNTP" - ${command} ${SNTP_OPTS} - eend $? "Failed to set clock" -} diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service-r3 b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service-r3 deleted file mode 100644 index 2ab722f2c6..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service-r3 +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Set time via SNTP -After=network.target network-online.target nss-lookup.target -Before=time-sync.target -Wants=network-online.target time-sync.target -Conflicts=systemd-timesyncd.service - -[Service] -Type=oneshot -ExecStart=/usr/bin/sntp -s $SERVER -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service.conf b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service.conf deleted file mode 100644 index 75e4f41b41..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/files/sntp.service.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Service] -Environment="SERVER=0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org" diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/ntp-4.2.8_p15.ebuild b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/ntp-4.2.8_p15.ebuild index 57803acb84..591c3f1cdf 100644 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/ntp-4.2.8_p15.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/net-misc/ntp/ntp-4.2.8_p15.ebuild @@ -3,7 +3,8 @@ EAPI=7 -inherit autotools toolchain-funcs flag-o-matic systemd +TMPFILES_OPTIONAL=1 +inherit autotools toolchain-funcs flag-o-matic systemd tmpfiles MY_P=${P/_p/p} DESCRIPTION="Network Time Protocol suite/programs" @@ -14,7 +15,7 @@ SRC_URI="http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${PV:0:3}/${MY_P}.tar LICENSE="HPND BSD ISC" SLOT="0" KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~amd64-linux ~x86-linux ~m68k-mint" -IUSE="caps debug ipv6 libressl openntpd parse-clocks readline samba selinux snmp ssl +threads vim-syntax zeroconf" +IUSE="caps debug ipv6 libressl openntpd parse-clocks perl readline samba selinux snmp ssl threads vim-syntax zeroconf" COMMON_DEPEND="readline? ( >=sys-libs/readline-4.1:0= ) >=dev-libs/libevent-2.0.9:=[threads?] @@ -52,6 +53,7 @@ PATCHES=( src_prepare() { default + use perl || sed -i -e '/^SUBDIRS *=/,/[^\\]$/{/scripts/d;}' Makefile.am || die append-cppflags -D_GNU_SOURCE #264109 # Make sure every build uses the same install layout. #539092 find sntp/loc/ -type f '!' -name legacy -delete || die @@ -95,19 +97,10 @@ src_install() { dodoc INSTALL WHERE-TO-START doman "${WORKDIR}"/man/*.[58] - insinto /etc + insinto /usr/share/ntp doins "${FILESDIR}"/ntp.conf - use ipv6 || sed -i '/^restrict .*::1/d' "${ED}"/etc/ntp.conf #524726 - newinitd "${FILESDIR}"/ntpd.rc-r1 ntpd - newconfd "${FILESDIR}"/ntpd.confd ntpd - newinitd "${FILESDIR}"/ntp-client.rc ntp-client - newconfd "${FILESDIR}"/ntp-client.confd ntp-client - newinitd "${FILESDIR}"/sntp.rc sntp - newconfd "${FILESDIR}"/sntp.confd sntp - if ! use caps ; then - sed -i "s|-u ntp:ntp||" "${ED}"/etc/conf.d/ntpd || die - fi - sed -i "s:/usr/bin:/usr/sbin:" "${ED}"/etc/init.d/ntpd || die + use ipv6 || sed -i '/^restrict .*::1/d' "${ED%/}"/usr/share/ntp/ntp.conf #524726 + newtmpfiles "${FILESDIR}"/ntp.tmpfiles ntp.conf keepdir /var/lib/ntp use prefix || fowners ntp:ntp /var/lib/ntp @@ -116,10 +109,9 @@ src_install() { cd "${ED}" || die rm usr/sbin/ntpd || die rm -r var/lib || die - rm etc/{conf,init}.d/ntpd || die rm usr/share/man/*/ntpd.8 || die else - systemd_newunit "${FILESDIR}"/ntpd.service-r2 ntpd.service + systemd_dounit "${FILESDIR}"/ntpd.service if use caps ; then sed -i '/ExecStart/ s|$| -u ntp:ntp|' \ "${D}$(systemd_get_systemunitdir)"/ntpd.service \ @@ -128,17 +120,6 @@ src_install() { systemd_enable_ntpunit 60-ntpd ntpd.service fi - systemd_newunit "${FILESDIR}"/ntpdate.service-r2 ntpdate.service - systemd_install_serviced "${FILESDIR}"/ntpdate.service.conf - systemd_newunit "${FILESDIR}"/sntp.service-r3 sntp.service - systemd_install_serviced "${FILESDIR}"/sntp.service.conf -} - -pkg_postinst() { - if grep -qs '^[^#].*notrust' "${EROOT}"/etc/ntp.conf ; then - eerror "The notrust option was found in your /etc/ntp.conf!" - ewarn "If your ntpd starts sending out weird responses," - ewarn "then make sure you have keys properly setup and see" - ewarn "https://bugs.gentoo.org/41827" - fi + systemd_dounit "${FILESDIR}"/ntpdate.service + systemd_dounit "${FILESDIR}"/sntp.service }