net-misc/ntp: Apply CoreOS changes

- 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
This commit is contained in:
David Michael 2019-03-19 14:12:39 +00:00
parent f9ec3fbbec
commit 71d591c17c
15 changed files with 25 additions and 189 deletions

View File

@ -1,9 +1,9 @@
DEFINED_PHASES=configure install postinst prepare setup DEFINED_PHASES=configure install prepare setup
DEPEND=readline? ( >=sys-libs/readline-4.1:0= ) >=dev-libs/libevent-2.0.9:=[threads?] kernel_linux? ( caps? ( sys-libs/libcap ) ) zeroconf? ( net-dns/avahi[mdnsresponder-compat] ) snmp? ( net-analyzer/net-snmp ) ssl? ( !libressl? ( dev-libs/openssl:0= ) libressl? ( dev-libs/libressl:0= ) ) parse-clocks? ( net-misc/pps-tools ) virtual/pkgconfig >=app-portage/elt-patches-20170815 !<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4 virtual/pkgconfig DEPEND=readline? ( >=sys-libs/readline-4.1:0= ) >=dev-libs/libevent-2.0.9:=[threads?] kernel_linux? ( caps? ( sys-libs/libcap ) ) zeroconf? ( net-dns/avahi[mdnsresponder-compat] ) snmp? ( net-analyzer/net-snmp ) ssl? ( !libressl? ( dev-libs/openssl:0= ) libressl? ( dev-libs/libressl:0= ) ) parse-clocks? ( net-misc/pps-tools ) virtual/pkgconfig >=app-portage/elt-patches-20170815 !<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4 virtual/pkgconfig
DESCRIPTION=Network Time Protocol suite/programs DESCRIPTION=Network Time Protocol suite/programs
EAPI=6 EAPI=6
HOMEPAGE=http://www.ntp.org/ HOMEPAGE=http://www.ntp.org/
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
KEYWORDS=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~m68k-mint KEYWORDS=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~m68k-mint
LICENSE=HPND BSD ISC LICENSE=HPND BSD ISC
PDEPEND=openntpd? ( net-misc/openntpd ) PDEPEND=openntpd? ( net-misc/openntpd )
@ -11,4 +11,4 @@ RDEPEND=readline? ( >=sys-libs/readline-4.1:0= ) >=dev-libs/libevent-2.0.9:=[thr
SLOT=0 SLOT=0
SRC_URI=http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p13.tar.gz https://dev.gentoo.org/~polynomial-c/ntp-4.2.8p13-manpages.tar.xz SRC_URI=http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p13.tar.gz https://dev.gentoo.org/~polynomial-c/ntp-4.2.8p13-manpages.tar.xz
_eclasses_=autotools 1bf086cdd7356f5c9a4acd9727bd2065 desktop b1d22ac8bdd4679ab79c71aca235009d epatch a1bf4756dba418a7238f3be0cb010c54 estack 43ddf5aaffa7a8d0482df54d25a66a1f eutils 6e6c2737b59a4b982de6fb3ecefd87f8 flag-o-matic 55aaa148741116aa54ad0d80e361818e libtool f143db5a74ccd9ca28c1234deffede96 ltprune 08f9e1d9ee0af8f5d9a7854efbcd8c0e multilib b2f01ad412baf81650c23fcf0975fa33 preserve-libs ef207dc62baddfddfd39a164d9797648 systemd 71fd8d2065d102753fb9e4d20eaf3e9f toolchain-funcs f164325a2cdb5b3ea39311d483988861 user 8bc2845510e2109af75e3eeac607ec81 vcs-clean 2a0f74a496fa2b1552c4f3398258b7bf _eclasses_=autotools 1bf086cdd7356f5c9a4acd9727bd2065 desktop b1d22ac8bdd4679ab79c71aca235009d epatch a1bf4756dba418a7238f3be0cb010c54 estack 43ddf5aaffa7a8d0482df54d25a66a1f eutils 6e6c2737b59a4b982de6fb3ecefd87f8 flag-o-matic 55aaa148741116aa54ad0d80e361818e libtool f143db5a74ccd9ca28c1234deffede96 ltprune 08f9e1d9ee0af8f5d9a7854efbcd8c0e multilib b2f01ad412baf81650c23fcf0975fa33 preserve-libs ef207dc62baddfddfd39a164d9797648 systemd 71fd8d2065d102753fb9e4d20eaf3e9f toolchain-funcs f164325a2cdb5b3ea39311d483988861 user 8bc2845510e2109af75e3eeac607ec81 vcs-clean 2a0f74a496fa2b1552c4f3398258b7bf
_md5_=088dd6d4d87c2b974daa13d27a446fe5 _md5_=40fe1c3393d483e71d5bda0fb0c29ef5

View File

@ -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"

View File

@ -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"
}

View File

@ -1,34 +1,8 @@
# NOTES: # Common pool
# DHCP clients can append or replace NTP configuration files. server 0.coreos.pool.ntp.org
# You should consult your DHCP client documentation about its server 1.coreos.pool.ntp.org
# default behaviour and how to change it. server 2.coreos.pool.ntp.org
server 3.coreos.pool.ntp.org
# 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
# Warning: Using default NTP settings will leave your NTP # Warning: Using default NTP settings will leave your NTP
# server accessible to all hosts on the Internet. # server accessible to all hosts on the Internet.
@ -37,18 +11,9 @@ driftfile /var/lib/ntp/ntp.drift
# from accessing the NTP server, uncomment: # from accessing the NTP server, uncomment:
#restrict default ignore #restrict default ignore
# Default configuration: # Default configuration:
# - Allow only time queries, at a limited rate, sending KoD when in excess. # - Allow only time queries, at a limited rate, sending KoD when in excess.
# - Allow all local queries (IPv4, IPv6) # - 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 127.0.0.1
restrict [::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

View File

@ -0,0 +1,2 @@
d /var/lib/ntp 0755 ntp ntp - -
L /etc/ntp.conf - - - - /usr/share/ntp/ntp.conf

View File

@ -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"

View File

@ -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
}

View File

@ -4,8 +4,9 @@ After=ntpdate.service sntp.service
Conflicts=systemd-timesyncd.service Conflicts=systemd-timesyncd.service
[Service] [Service]
ExecStart=/usr/sbin/ntpd -g -n ExecStart=/usr/sbin/ntpd -g -n -f /var/lib/ntp/ntp.drift
PrivateTmp=true PrivateTmp=true
Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -7,6 +7,7 @@ Conflicts=systemd-timesyncd.service
[Service] [Service]
Type=oneshot Type=oneshot
Environment="SERVER=0.coreos.pool.ntp.org 1.coreos.pool.ntp.org 2.coreos.pool.ntp.org 3.coreos.pool.ntp.org"
ExecStart=/usr/sbin/ntpdate -b -u $SERVER ExecStart=/usr/sbin/ntpdate -b -u $SERVER
RemainAfterExit=yes RemainAfterExit=yes

View File

@ -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"

View File

@ -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"

View File

@ -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"
}

View File

@ -7,6 +7,7 @@ Conflicts=systemd-timesyncd.service
[Service] [Service]
Type=oneshot Type=oneshot
Environment="SERVER=0.coreos.pool.ntp.org 1.coreos.pool.ntp.org 2.coreos.pool.ntp.org 3.coreos.pool.ntp.org"
ExecStart=/usr/bin/sntp -s $SERVER ExecStart=/usr/bin/sntp -s $SERVER
RemainAfterExit=yes RemainAfterExit=yes

View File

@ -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"

View File

@ -14,7 +14,7 @@ SRC_URI="http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${PV:0:3}/${MY_P}.tar
LICENSE="HPND BSD ISC" LICENSE="HPND BSD ISC"
SLOT="0" SLOT="0"
KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~m68k-mint" KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~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"
CDEPEND="readline? ( >=sys-libs/readline-4.1:0= ) CDEPEND="readline? ( >=sys-libs/readline-4.1:0= )
>=dev-libs/libevent-2.0.9:=[threads?] >=dev-libs/libevent-2.0.9:=[threads?]
@ -52,6 +52,7 @@ pkg_setup() {
src_prepare() { src_prepare() {
default default
use perl || sed -i -e '/^SUBDIRS *=/,/[^\\]$/{/scripts/d;}' Makefile.am || die
append-cppflags -D_GNU_SOURCE #264109 append-cppflags -D_GNU_SOURCE #264109
# Make sure every build uses the same install layout. #539092 # Make sure every build uses the same install layout. #539092
find sntp/loc/ -type f '!' -name legacy -delete || die find sntp/loc/ -type f '!' -name legacy -delete || die
@ -97,19 +98,10 @@ src_install() {
dodoc INSTALL WHERE-TO-START dodoc INSTALL WHERE-TO-START
doman "${WORKDIR}"/man/*.[58] doman "${WORKDIR}"/man/*.[58]
insinto /etc insinto /usr/share/ntp
doins "${FILESDIR}"/ntp.conf doins "${FILESDIR}"/ntp.conf
use ipv6 || sed -i '/^restrict .*::1/d' "${ED%/}"/etc/ntp.conf #524726 use ipv6 || sed -i '/^restrict .*::1/d' "${ED%/}"/usr/share/ntp/ntp.conf #524726
newinitd "${FILESDIR}"/ntpd.rc-r1 ntpd systemd_newtmpfilesd "${FILESDIR}"/ntp.tmpfiles ntp.conf
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
keepdir /var/lib/ntp keepdir /var/lib/ntp
use prefix || fowners ntp:ntp /var/lib/ntp use prefix || fowners ntp:ntp /var/lib/ntp
@ -118,10 +110,9 @@ src_install() {
cd "${ED}" || die cd "${ED}" || die
rm usr/sbin/ntpd || die rm usr/sbin/ntpd || die
rm -r var/lib || die rm -r var/lib || die
rm etc/{conf,init}.d/ntpd || die
rm usr/share/man/*/ntpd.8 || die rm usr/share/man/*/ntpd.8 || die
else else
systemd_newunit "${FILESDIR}"/ntpd.service-r2 ntpd.service systemd_dounit "${FILESDIR}"/ntpd.service
if use caps ; then if use caps ; then
sed -i '/ExecStart/ s|$| -u ntp:ntp|' \ sed -i '/ExecStart/ s|$| -u ntp:ntp|' \
"${D%/}$(systemd_get_systemunitdir)"/ntpd.service \ "${D%/}$(systemd_get_systemunitdir)"/ntpd.service \
@ -130,17 +121,6 @@ src_install() {
systemd_enable_ntpunit 60-ntpd ntpd.service systemd_enable_ntpunit 60-ntpd ntpd.service
fi fi
systemd_newunit "${FILESDIR}"/ntpdate.service-r1 ntpdate.service systemd_dounit "${FILESDIR}"/ntpdate.service
systemd_install_serviced "${FILESDIR}"/ntpdate.service.conf systemd_dounit "${FILESDIR}"/sntp.service
systemd_newunit "${FILESDIR}"/sntp.service-r2 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
} }