net-misc/ntp: Sync with current Gentoo

This commit is contained in:
David Michael 2018-04-17 13:56:16 -04:00
parent d00cdc3cde
commit 60521a6eed
18 changed files with 345 additions and 154 deletions

View File

@ -1 +1,2 @@
DIST ntp-4.2.8p9.tar.gz 7231884 SHA256 b724287778e1bac625b447327c9851eedef020517a3545625e9f652a90f30b72 SHA512 ffd9e34060210d1cfb8ca0d89f2577df1c5fbe3ba63c620cdadc3ccc3c9d07f518783c6b91e57bffc77b08f449fdbab12faf226672ebd2dde5a0b4a783322a04 WHIRLPOOL ea96b106fd06f2b536394ad2a3dcc2a973aa0cec96140a292bc13b6ceb4159208a59b9c51936240c8a44fa7b2caa4be60d07d3c53066ce8588b0561bef64c070
DIST ntp-4.2.8p11-manpages.tar.xz 25700 SHA256 55fe8bb66f1dc8d5bff3ec9875ec4c535434ed4dbc3b5e64b0ef021f43b91c0d SHA512 403bc238681abaadc838f5a6619851dcd0cfa5bf780e8aeaa94e8f77e776998d1f5142d65e3fa99c23e22e4cb7207d24b059fbbc6ddcf4414f0076a4b6ab4e81 WHIRLPOOL f0ebe7d7b87cd502b232e4a094646b4734ed78cd33372995b58c7671024cc1b74751ac7d2c7dd3944e8d8cef35c148b74cc54e0f5c1f0bd721983102562de818
DIST ntp-4.2.8p11.tar.gz 7076566 SHA256 f14a39f753688252d683ff907035ffff106ba8d3db21309b742e09b5c3cd278e SHA512 05ac60f15a6aac50aaf340d40e4e439a421fa6e3d897bf30a69b2cef0cc97f8a6956012bfc6ceba055f4c3485a24f7fb8ebbd055e1875f1c69cbfdc35e71f236 WHIRLPOOL 9c9c2d0b967858d936f3b78ac93abea901d4d6e8fe90983f42da49f9a558ce96c00722545f8d5142594228be3dd01d837fba976c8ffb9de923adbcd16d343895

View File

@ -1,24 +0,0 @@
From 7c3b3f34f94146d5178adee4c5a184e9b1546e89 Mon Sep 17 00:00:00 2001
From: Michael Marineau <mike@marineau.org>
Date: Mon, 22 Dec 2014 21:20:46 -0800
Subject: [PATCH] disable perl scripts
---
Makefile.am | 1 -
1 file changed, 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index fc76719..1fd008d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,6 @@ NULL =
SUBDIRS = \
sntp \
- scripts \
include \
libntp \
libparse \
--
2.0.4

View File

@ -0,0 +1,39 @@
Fix building with libressl or without SSL.
Origin: http://bugs.ntp.org/attachment.cgi?id=1481
LibreSSL fix from Joe Kappus (https://bugs.gentoo.org/show_bug.cgi?id=600668#c2)
--- a/include/libssl_compat.h
+++ b/include/libssl_compat.h
@@ -37,7 +37,7 @@
#endif
/* ----------------------------------------------------------------- */
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
/* ----------------------------------------------------------------- */
# include <openssl/objects.h>
--- a/libntp/libssl_compat.c
+++ b/libntp/libssl_compat.c
@@ -26,7 +26,7 @@
/* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */
-#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER < 0x10100000L
+#if defined(OPENSSL) && (OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))
/* ----------------------------------------------------------------- */
#include "libssl_compat.h"
--- a/libntp/ssl_init.c
+++ b/libntp/ssl_init.c
@@ -21,7 +21,7 @@
int ssl_init_done;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
static void
atexit_ssl_cleanup(void)

View File

@ -0,0 +1,21 @@
# /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

@ -0,0 +1,31 @@
#!/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,8 +1,34 @@
# Common pool
server 0.coreos.pool.ntp.org
server 1.coreos.pool.ntp.org
server 2.coreos.pool.ntp.org
server 3.coreos.pool.ntp.org
# 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
# Warning: Using default NTP settings will leave your NTP
# server accessible to all hosts on the Internet.
@ -11,9 +37,18 @@ server 3.coreos.pool.ntp.org
# 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 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

View File

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

View File

@ -0,0 +1,6 @@
# /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

@ -0,0 +1,22 @@
#!/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,9 +4,8 @@ After=ntpdate.service sntp.service
Conflicts=systemd-timesyncd.service
[Service]
ExecStart=/usr/sbin/ntpd -g -n -f /var/lib/ntp/ntp.drift
ExecStart=/usr/sbin/ntpd -g -n
PrivateTmp=true
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -1,13 +1,12 @@
[Unit]
Description=Set time via NTP using ntpdate
After=network.target nss-lookup.target
After=network-online.target nss-lookup.target
Before=time-sync.target
Wants=time-sync.target
Conflicts=systemd-timesyncd.service
[Service]
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
RemainAfterExit=yes

View File

@ -0,0 +1,2 @@
[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

@ -0,0 +1,4 @@
# /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

@ -0,0 +1,26 @@
#!/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

@ -1,13 +1,12 @@
[Unit]
Description=Set time via SNTP
After=network.target nss-lookup.target
After=network.target NetworkManager-wait-online.service nss-lookup.target
Before=time-sync.target
Wants=time-sync.target
Conflicts=systemd-timesyncd.service
[Service]
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
RemainAfterExit=yes

View File

@ -0,0 +1,2 @@
[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

@ -0,0 +1,145 @@
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
inherit autotools toolchain-funcs flag-o-matic user systemd
MY_P=${P/_p/p}
DESCRIPTION="Network Time Protocol suite/programs"
HOMEPAGE="http://www.ntp.org/"
SRC_URI="http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${PV:0:3}/${MY_P}.tar.gz
https://dev.gentoo.org/~polynomial-c/${MY_P}-manpages.tar.xz"
LICENSE="HPND BSD ISC"
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"
IUSE="caps debug ipv6 libressl openntpd parse-clocks readline samba selinux snmp ssl +threads vim-syntax zeroconf"
CDEPEND="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 )
)
parse-clocks? ( net-misc/pps-tools )"
DEPEND="${CDEPEND}
virtual/pkgconfig"
RDEPEND="${CDEPEND}
selinux? ( sec-policy/selinux-ntp )
vim-syntax? ( app-vim/ntp-syntax )
!net-misc/ntpsec
!openntpd? ( !net-misc/openntpd )
"
PDEPEND="openntpd? ( net-misc/openntpd )"
S="${WORKDIR}/${MY_P}"
PATCHES=(
"${FILESDIR}"/${PN}-4.2.8-ipc-caps.patch #533966
"${FILESDIR}"/${PN}-4.2.8-sntp-test-pthreads.patch #563922
"${FILESDIR}"/${PN}-4.2.8_p10-fix-build-wo-ssl-or-libressl.patch
)
pkg_setup() {
enewgroup ntp 123
enewuser ntp 123 -1 /dev/null ntp
}
src_prepare() {
default
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
eautoreconf #622754
# Disable pointless checks.
touch .checkChangeLog .gcc-warning FRC.html html/.datecheck
}
src_configure() {
# avoid libmd5/libelf
export ac_cv_search_MD5Init=no ac_cv_header_md5_h=no
export ac_cv_lib_elf_nlist=no
# blah, no real configure options #176333
export ac_cv_header_dns_sd_h=$(usex zeroconf)
export ac_cv_lib_dns_sd_DNSServiceRegister=${ac_cv_header_dns_sd_h}
# Increase the default memlimit from 32MiB to 128MiB. #533232
local myeconfargs=(
--with-lineeditlibs=readline,edit,editline
--with-yielding-select
--disable-local-libevent
--docdir='$(datarootdir)'/doc/${PF}
--htmldir='$(docdir)/html'
--with-memlock=256
$(use_enable caps linuxcaps)
$(use_enable parse-clocks)
$(use_enable ipv6)
$(use_enable debug debugging)
$(use_with readline lineeditlibs readline)
$(use_enable samba ntp-signd)
$(use_with snmp ntpsnmpd)
$(use_with ssl crypto)
$(use_enable threads thread-support)
)
econf "${myeconfargs[@]}"
}
src_install() {
default
# move ntpd/ntpdate to sbin #66671
dodir /usr/sbin
mv "${ED%/}"/usr/bin/{ntpd,ntpdate} "${ED%/}"/usr/sbin/ || die "move to sbin"
dodoc INSTALL WHERE-TO-START
doman "${WORKDIR}"/man/*.[58]
insinto /etc
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
keepdir /var/lib/ntp
use prefix || fowners ntp:ntp /var/lib/ntp
if use openntpd ; then
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
if use caps ; then
sed -i '/ExecStart/ s|$| -u ntp:ntp|' \
"${D%/}$(systemd_get_systemunitdir)"/ntpd.service \
|| die
fi
systemd_enable_ntpunit 60-ntpd ntpd.service
fi
systemd_newunit "${FILESDIR}"/ntpdate.service-r1 ntpdate.service
systemd_install_serviced "${FILESDIR}"/ntpdate.service.conf
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
}

View File

@ -1,114 +0,0 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI="5"
inherit eutils toolchain-funcs flag-o-matic user systemd
MY_P=${P/_p/p}
DESCRIPTION="Network Time Protocol suite/programs"
HOMEPAGE="http://www.ntp.org/"
SRC_URI="http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${PV:0:3}/${MY_P}.tar.gz"
LICENSE="HPND BSD ISC"
SLOT="0"
KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~ia64-linux ~x86-linux ~m68k-mint"
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= )
>=dev-libs/libevent-2.0.9[threads?]
kernel_linux? ( caps? ( sys-libs/libcap ) )
zeroconf? ( net-dns/avahi[mdnsresponder-compat] )
!openntpd? ( !net-misc/openntpd )
snmp? ( net-analyzer/net-snmp )
ssl? (
!libressl? ( dev-libs/openssl:0= )
libressl? ( dev-libs/libressl )
)
parse-clocks? ( net-misc/pps-tools )"
DEPEND="${CDEPEND}
virtual/pkgconfig"
RDEPEND="${CDEPEND}
selinux? ( sec-policy/selinux-ntp )
vim-syntax? ( app-vim/ntp-syntax )"
PDEPEND="openntpd? ( net-misc/openntpd )"
S=${WORKDIR}/${MY_P}
PATCHES=(
"${FILESDIR}"/${PN}-4.2.8-ipc-caps.patch #533966
"${FILESDIR}"/${PN}-4.2.8-sntp-test-pthreads.patch #563922
)
pkg_setup() {
enewgroup ntp 123
enewuser ntp 123 -1 /dev/null ntp
}
src_prepare() {
epatch "${PATCHES[@]}"
use perl || epatch "${FILESDIR}"/${PN}-4.2.8-disable-perl-scripts.patch
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
# Disable pointless checks.
touch .checkChangeLog .gcc-warning FRC.html html/.datecheck
}
src_configure() {
# avoid libmd5/libelf
export ac_cv_search_MD5Init=no ac_cv_header_md5_h=no
export ac_cv_lib_elf_nlist=no
# blah, no real configure options #176333
export ac_cv_header_dns_sd_h=$(usex zeroconf)
export ac_cv_lib_dns_sd_DNSServiceRegister=${ac_cv_header_dns_sd_h}
# Increase the default memlimit from 32MiB to 128MiB. #533232
econf \
--with-lineeditlibs=readline,edit,editline \
--with-yielding-select \
--disable-local-libevent \
--docdir='$(datarootdir)'/doc/${PF} \
--htmldir='$(docdir)/html' \
--with-memlock=256 \
$(use_enable caps linuxcaps) \
$(use_enable parse-clocks) \
$(use_enable ipv6) \
$(use_enable debug debugging) \
$(use_with readline lineeditlibs readline) \
$(use_enable samba ntp-signd) \
$(use_with snmp ntpsnmpd) \
$(use_with ssl crypto) \
$(use_enable threads thread-support)
}
src_install() {
default
# move ntpd/ntpdate to sbin #66671
dodir /usr/sbin
mv "${ED}"/usr/bin/{ntpd,ntpdate} "${ED}"/usr/sbin/ || die "move to sbin"
dodoc INSTALL WHERE-TO-START
insinto /usr/share/ntp
doins "${FILESDIR}"/ntp.conf
systemd_newtmpfilesd "${FILESDIR}"/ntp.tmpfiles ntp.conf
use ipv6 || sed -i '/^restrict .*::1/d' "${ED}"/usr/share/ntp/ntp.conf #524726
keepdir /var/lib/ntp
use prefix || fowners ntp:ntp /var/lib/ntp
if use openntpd ; then
cd "${ED}"
rm usr/sbin/ntpd || die
rm -r var/lib
rm usr/share/man/*/ntpd.8 || die
else
systemd_dounit "${FILESDIR}"/ntpd.service
use caps && sed -i '/ExecStart/ s|$| -u ntp:ntp|' "${ED}"/usr/lib/systemd/system/ntpd.service
systemd_enable_ntpunit 60-ntpd ntpd.service
fi
systemd_dounit "${FILESDIR}"/ntpdate.service
systemd_dounit "${FILESDIR}"/sntp.service
}