summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-misc/openntpd')
-rw-r--r--net-misc/openntpd/Manifest3
-rw-r--r--net-misc/openntpd/files/openntpd-20080406-dns-timeout.patch46
-rw-r--r--net-misc/openntpd/files/openntpd-20080406-pidfile.patch141
-rw-r--r--net-misc/openntpd/files/openntpd-20080406-signal.patch57
-rw-r--r--net-misc/openntpd/files/openntpd-5.7_p4-nolibtls.patch49
-rw-r--r--net-misc/openntpd/files/openntpd.conf.d-20080406-r67
-rw-r--r--net-misc/openntpd/files/openntpd.init.d-20080406-r615
-rw-r--r--net-misc/openntpd/files/openntpd.service-20080406-r411
-rw-r--r--net-misc/openntpd/metadata.xml19
-rw-r--r--net-misc/openntpd/openntpd-4.0_pre20080406.ebuild105
-rw-r--r--net-misc/openntpd/openntpd-5.7_p4-r1.ebuild86
11 files changed, 539 insertions, 0 deletions
diff --git a/net-misc/openntpd/Manifest b/net-misc/openntpd/Manifest
new file mode 100644
index 000000000000..b610e7332681
--- /dev/null
+++ b/net-misc/openntpd/Manifest
@@ -0,0 +1,3 @@
+DIST openntpd-5.7p4.tar.gz 427900 SHA256 a993d95976e375acc0ab1a677fd268f55024477835633c8ae404895046bccb23 SHA512 2a185139c915482086069fa19dd3070884a415137d1688059559d2da892928afbbe2fa0a8ade70d474809710265dcc05906abaf261892d7894e70272e2e516ef WHIRLPOOL 9464941e0f055ecd1db19a03bb5264a1dce02c6c7c2be078d1e3a19b5bd0a3c4e19ee6768617c90ebed01dea32f3a63751f9ef0436f56e22b7e6bd673a065546
+DIST openntpd_20080406p-6.debian.tar.gz 11849 SHA256 6718ffb52b7f34c7c3e9532d245f31ee5c749bac2cc2c2d4594d8161925a3122 SHA512 f857fbc85e29035470af0855c8fc416c188f55586ba2e1d719159ecfa4a0274ba4dd526409dfd915056a1c15f5e44cb8c40196a7e03c3026c5d73851ebb5abc8 WHIRLPOOL 35bc0ab16d161c7878d438641eede8425238fbce4d32f6b56e347252e6ad561dc1a5795e3bc3cf133fa09dccb69520cb9837c7134bc0fe6cec9ea14be314ee51
+DIST openntpd_20080406p.orig.tar.gz 175923 SHA256 52f473dd8ea8864023ebcdce16a9a50571803af7ffc32a00212242c6a866c3b2 SHA512 9561788002b232786d1589f74bbe2f07a029e3407da4471d2ac9d5e20d8839dbb6e6e53493c78829058611ca23bf00560bbe7bcfe76204d206747752fd47f696 WHIRLPOOL 545125d0ee5ced7827df3d804ac63938d2614e9fb4a2bf3c6bbc17f6040175aa03c057d7a4d3da71ae944f4a556e2b66266d1c6d0463c1cad5d86de3ae896712
diff --git a/net-misc/openntpd/files/openntpd-20080406-dns-timeout.patch b/net-misc/openntpd/files/openntpd-20080406-dns-timeout.patch
new file mode 100644
index 000000000000..6026037331a7
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd-20080406-dns-timeout.patch
@@ -0,0 +1,46 @@
+fix dns lookups timeout
+https://bugs.gentoo.org/show_bug.cgi?id=493358
+
+diff -u openntpd-20080406p-orig/ntpd.c openntpd-20080406p/ntpd.c
+--- openntpd-20080406p-orig/ntpd.c 2013-12-04 20:12:02.562857933 -0800
++++ openntpd-20080406p/ntpd.c 2013-12-04 20:22:55.617577783 -0800
+@@ -34,6 +34,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <time.h>
+ #include <unistd.h>
+
+ #include "ntpd.h"
+@@ -95,6 +96,7 @@
+ int ch, nfds, timeout = INFTIM;
+ int pipe_chld[2];
+ extern char *__progname;
++ time_t start_time;
+
+ __progname = _compat_get_progname(argv[0]);
+
+@@ -197,6 +199,8 @@
+ fatal(NULL);
+ imsg_init(ibuf, pipe_chld[0]);
+
++ start_time = getmonotime();
++
+ while (quit == 0) {
+ pfd[PFD_PIPE].fd = ibuf->fd;
+ pfd[PFD_PIPE].events = POLLIN;
+@@ -209,11 +213,12 @@
+ quit = 1;
+ }
+
+- if (nfds == 0 && lconf.settime) {
++ if (lconf.settime &&
++ (nfds == 0 || getmonotime() > start_time+SETTIME_TIMEOUT)) {
+ lconf.settime = 0;
+ timeout = INFTIM;
+ log_init(lconf.debug);
+- log_debug("no reply received in time, skipping initial "
++ log_warnx("no reply received in time, skipping initial "
+ "time setting");
+ if (!lconf.debug) {
+ if (daemon(1, 0))
diff --git a/net-misc/openntpd/files/openntpd-20080406-pidfile.patch b/net-misc/openntpd/files/openntpd-20080406-pidfile.patch
new file mode 100644
index 000000000000..d2ee38504c3e
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd-20080406-pidfile.patch
@@ -0,0 +1,141 @@
+adding a -p option to openntpd to create a pidfile
+
+https://bugs.gentoo.org/show_bug.cgi?id=493082
+
+diff -u -r openntpd-20080406p.orig/ntpd.8 openntpd-20080406p/ntpd.8
+--- openntpd-20080406p.orig/ntpd.8 2013-12-01 12:49:49.773116316 -0800
++++ openntpd-20080406p/ntpd.8 2013-12-01 13:27:39.417324497 -0800
+@@ -25,6 +25,7 @@
+ .Bk -words
+ .Op Fl dnSsv
+ .Op Fl f Ar file
++.Op Fl p Ar file
+ .Ek
+ .Sh DESCRIPTION
+ The
+@@ -63,13 +64,16 @@
+ .Xr ntpd.conf 5 .
+ .Pp
+ The options are as follows:
+-.Bl -tag -width "-f fileXXX"
++.Bl -tag -width "-p fileXXX"
+ .It Fl d
+ Do not daemonize.
+ If this option is specified,
+ .Nm
+ will run in the foreground and log to
+ .Em stderr .
++.It Fl p Ar file
++Write pid to
++.Ar file
+ .It Fl f Ar file
+ Use
+ .Ar file
+diff -u -r openntpd-20080406p.orig/ntpd.c openntpd-20080406p/ntpd.c
+--- openntpd-20080406p.orig/ntpd.c 2013-12-01 12:49:49.774116176 -0800
++++ openntpd-20080406p/ntpd.c 2013-12-01 13:31:43.964616270 -0800
+@@ -78,7 +78,7 @@
+ {
+ extern char *__progname;
+
+- fprintf(stderr, "usage: %s [-dnSsv] [-f file]\n", __progname);
++ fprintf(stderr, "usage: %s [-dnSsv] [-f file] [-p file]\n", __progname);
+ exit(1);
+ }
+
+@@ -105,7 +105,7 @@
+ log_init(1); /* log to stderr until daemonized */
+ res_init(); /* XXX */
+
+- while ((ch = getopt(argc, argv, "df:nsSv")) != -1) {
++ while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) {
+ switch (ch) {
+ case 'd':
+ lconf.debug = 1;
+@@ -116,6 +116,9 @@
+ case 'n':
+ lconf.noaction = 1;
+ break;
++ case 'p':
++ lconf.pid_file = optarg;
++ break;
+ case 's':
+ lconf.settime = 1;
+ break;
+@@ -157,9 +160,17 @@
+ reset_adjtime();
+ if (!lconf.settime) {
+ log_init(lconf.debug);
+- if (!lconf.debug)
++ if (!lconf.debug) {
+ if (daemon(1, 0))
+ fatal("daemon");
++ else if (lconf.pid_file != NULL) {
++ FILE *f = fopen(lconf.pid_file, "w");
++ if (f == NULL)
++ fatal("couldn't open pid file");
++ fprintf(f, "%ld\n", (long) getpid());
++ fclose(f);
++ }
++ }
+ } else
+ timeout = SETTIME_TIMEOUT * 1000;
+
+@@ -201,9 +212,17 @@
+ log_init(lconf.debug);
+ log_debug("no reply received in time, skipping initial "
+ "time setting");
+- if (!lconf.debug)
++ if (!lconf.debug) {
+ if (daemon(1, 0))
+ fatal("daemon");
++ else if (lconf.pid_file != NULL) {
++ FILE *f = fopen(lconf.pid_file, "w");
++ if (f == NULL)
++ fatal("couldn't open pid file");
++ fprintf(f, "%ld\n", (long) getpid());
++ fclose(f);
++ }
++ }
+ }
+
+ if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT))
+@@ -242,6 +261,8 @@
+ msgbuf_clear(&ibuf->w);
+ free(ibuf);
+ log_info("Terminating");
++ if (lconf.pid_file != NULL)
++ unlink(lconf.pid_file);
+ return (0);
+ }
+
+@@ -316,9 +337,17 @@
+ memcpy(&d, imsg.data, sizeof(d));
+ ntpd_settime(d);
+ /* daemonize now */
+- if (!lconf->debug)
++ if (!lconf->debug) {
+ if (daemon(1, 0))
+ fatal("daemon");
++ else if (lconf->pid_file != NULL) {
++ FILE *f = fopen(lconf->pid_file, "w");
++ if (f == NULL)
++ fatal("couldn't open pid file");
++ fprintf(f, "%ld\n", (long) getpid());
++ fclose(f);
++ }
++ }
+ lconf->settime = 0;
+ break;
+ case IMSG_HOST_DNS:
+diff -u -r openntpd-20080406p.orig/ntpd.h openntpd-20080406p/ntpd.h
+--- openntpd-20080406p.orig/ntpd.h 2013-12-01 12:49:49.773116316 -0800
++++ openntpd-20080406p/ntpd.h 2013-12-01 12:54:02.023313872 -0800
+@@ -178,6 +178,7 @@
+ u_int8_t debug;
+ u_int32_t scale;
+ u_int8_t noaction;
++ char *pid_file;
+ };
+
+ struct buf {
diff --git a/net-misc/openntpd/files/openntpd-20080406-signal.patch b/net-misc/openntpd/files/openntpd-20080406-signal.patch
new file mode 100644
index 000000000000..695beecb36c9
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd-20080406-signal.patch
@@ -0,0 +1,57 @@
+allow SIGUSR1 as stand-in for SIGINFO (on e.g linux)
+https://bugs.gentoo.org/show_bug.cgi?id=493084
+
+diff -u openntpd-20080406p-orig/ntp.c openntpd-20080406p/ntp.c
+--- openntpd-20080406p-orig/ntp.c 2013-12-04 15:11:04.417274938 -0800
++++ openntpd-20080406p/ntp.c 2013-12-04 15:12:21.066006404 -0800
+@@ -67,9 +67,11 @@
+ break;
+ #ifdef HAVE_SIGINFO
+ case SIGINFO:
+- ntp_report = 1;
+- break;
++#else
++ case SIGUSR1:
+ #endif
++ ntp_report = 1;
++ break;
+ }
+ }
+
+@@ -158,6 +160,8 @@
+ signal(SIGINT, ntp_sighdlr);
+ #ifdef USE_SIGINFO
+ signal(SIGINFO, ntp_sighdlr);
++#else
++ signal(SIGUSR1, ntp_sighdlr);
+ #endif
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+diff -u openntpd-20080406p-orig/ntpd.8 openntpd-20080406p/ntpd.8
+--- openntpd-20080406p-orig/ntpd.8 2013-12-04 15:11:04.416274915 -0800
++++ openntpd-20080406p/ntpd.8 2013-12-04 15:12:21.066006404 -0800
+@@ -104,7 +104,11 @@
+ .Nm
+ receives a
+ .Dv SIGINFO
+-signal, it will write its peer and sensor status to syslog.
++signal (or a
++.Dv SIGUSR1
++signal on systems without
++.Dv SIGINFO
++), it will write its peer and sensor status to syslog.
+ .Sh FILES
+ .Bl -tag -width "/var/lib/openntpd/ntpd.driftXXX" -compact
+ .It Pa /etc/ntpd.conf
+diff -u openntpd-20080406p-orig/ntpd.c openntpd-20080406p/ntpd.c
+--- openntpd-20080406p-orig/ntpd.c 2013-12-04 15:11:04.416274915 -0800
++++ openntpd-20080406p/ntpd.c 2013-12-04 15:14:21.586728922 -0800
+@@ -187,6 +187,9 @@
+ signal(SIGTERM, sighdlr);
+ signal(SIGINT, sighdlr);
+ signal(SIGHUP, sighdlr);
++ #ifndef HAVE_SIGINFO
++ signal(SIGUSR1, SIG_IGN);
++ #endif
+
+ close(pipe_chld[1]);
diff --git a/net-misc/openntpd/files/openntpd-5.7_p4-nolibtls.patch b/net-misc/openntpd/files/openntpd-5.7_p4-nolibtls.patch
new file mode 100644
index 000000000000..85a7c72949f2
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd-5.7_p4-nolibtls.patch
@@ -0,0 +1,49 @@
+diff -u -r openntpd-5.7p4-orig/src/config.c openntpd-5.7p4/src/config.c
+--- openntpd-5.7p4-orig/src/config.c 2015-03-24 18:18:56.000000000 -0700
++++ openntpd-5.7p4/src/config.c 2015-05-25 16:48:59.000000000 -0700
+@@ -218,6 +218,9 @@
+ fatal("new_constraint calloc");
+ p->id = ++constraint_maxid;
+
++#ifndef HAVE_LIBTLS
++ fatal("constraint configured without libtls support");
++#endif
+ return (p);
+ }
+
+diff -u -r openntpd-5.7p4-orig/src/ntp.c openntpd-5.7p4/src/ntp.c
+--- openntpd-5.7p4-orig/src/ntp.c 2015-03-11 19:15:36.000000000 -0700
++++ openntpd-5.7p4/src/ntp.c 2015-05-25 16:48:59.000000000 -0700
+@@ -110,12 +110,14 @@
+ return (pid);
+ }
+
++#ifdef HAVE_LIBTLS
+ tls_init();
+
+ /* Verification will be turned off if CA is not found */
+ if ((conf->ca = tls_load_file(CONSTRAINT_CA,
+ &conf->ca_len, NULL)) == NULL)
+ log_warnx("constraint certificate verification turned off");
++#endif
+
+ /* in this case the parent didn't init logging and didn't daemonize */
+ if (nconf->settime && !nconf->debug) {
+diff -u -r openntpd-5.7p4-orig/src/ntpd.conf.5 openntpd-5.7p4/src/ntpd.conf.5
+--- openntpd-5.7p4-orig/src/ntpd.conf.5 2015-03-24 18:18:56.000000000 -0700
++++ openntpd-5.7p4/src/ntpd.conf.5 2015-05-25 16:48:59.000000000 -0700
+@@ -192,8 +192,11 @@
+ .Sq Man-In-The-Middle
+ attacks.
+ Received NTP packets with time information falling outside of a range
+-near the constraint will be discarded and such NTP servers
+-will be marked as invalid.
++near the constraint will be discarded and such NTP servers will be marked as
++invalid. Contraints are only available if
++.Xr ntpd 8
++has been compiled with libtls support. Configuring a constraint without libtls
++support will result in a fatal error.
+ .Bl -tag -width Ds
+ .It Ic constraint from Ar url
+ Specify the URL, IP address or the hostname of an HTTPS server to
+Only in openntpd-5.7p4/src: ntpd.conf.5.orig
diff --git a/net-misc/openntpd/files/openntpd.conf.d-20080406-r6 b/net-misc/openntpd/files/openntpd.conf.d-20080406-r6
new file mode 100644
index 000000000000..ccd45459664c
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd.conf.d-20080406-r6
@@ -0,0 +1,7 @@
+# /etc/conf.d/ntpd: config file for openntpd's ntpd
+
+# See ntpd(8) man page ... some popular options:
+# -s Set the time immediately at startup
+# (Note: may cause up to a 15 second startup delay
+# if ntp servers not reachable)
+NTPD_OPTS=""
diff --git a/net-misc/openntpd/files/openntpd.init.d-20080406-r6 b/net-misc/openntpd/files/openntpd.init.d-20080406-r6
new file mode 100644
index 000000000000..ca7e3c5f7cf9
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd.init.d-20080406-r6
@@ -0,0 +1,15 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+name="OpenNTPD"
+command="/usr/sbin/ntpd"
+pidfile="/run/ntpd.pid"
+command_args="-p ${pidfile} ${NTPD_OPTS}"
+
+depend() {
+ need net
+ after ntp-client
+ use dns logger
+}
diff --git a/net-misc/openntpd/files/openntpd.service-20080406-r4 b/net-misc/openntpd/files/openntpd.service-20080406-r4
new file mode 100644
index 000000000000..2e1bbff8ff7f
--- /dev/null
+++ b/net-misc/openntpd/files/openntpd.service-20080406-r4
@@ -0,0 +1,11 @@
+[Unit]
+Description=OpenNTP Daemon
+After=network.target
+Conflicts=systemd-timesyncd.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/ntpd -s -d
+
+[Install]
+WantedBy=multi-user.target
diff --git a/net-misc/openntpd/metadata.xml b/net-misc/openntpd/metadata.xml
new file mode 100644
index 000000000000..cfa796d87054
--- /dev/null
+++ b/net-misc/openntpd/metadata.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>proxy-maintainers</herd>
+ <maintainer>
+ <email>henson@acm.org</email>
+ <name>Paul B. Henson</name>
+ </maintainer>
+ <maintainer>
+ <email>ottxor@gentoo.org</email>
+ <name>Christoph Junghans (proxy)</name>
+ </maintainer>
+ <longdescription lang="en">
+ OpenNTPD is a FREE, easy to use implementation of the Network Time
+ Protocol. It provides the ability to sync the local clock to remote
+ NTP servers and can act as NTP server itself, redistributing the
+ local clock.
+ </longdescription>
+</pkgmetadata>
diff --git a/net-misc/openntpd/openntpd-4.0_pre20080406.ebuild b/net-misc/openntpd/openntpd-4.0_pre20080406.ebuild
new file mode 100644
index 000000000000..e790857150b2
--- /dev/null
+++ b/net-misc/openntpd/openntpd-4.0_pre20080406.ebuild
@@ -0,0 +1,105 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit autotools eutils toolchain-funcs systemd user
+
+MY_PV=${PV##*pre}
+MY_P="${PN}_${MY_PV}p"
+DEB_VER="6"
+DESCRIPTION="Lightweight NTP server ported from OpenBSD"
+HOMEPAGE="http://www.openntpd.org/"
+SRC_URI="mirror://debian/pool/main/${PN:0:1}/${PN}/${MY_P}.orig.tar.gz
+ mirror://debian/pool/main/${PN:0:1}/${PN}/${MY_P}-${DEB_VER}.debian.tar.gz"
+
+LICENSE="BSD GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~x86-fbsd"
+IUSE="ssl selinux"
+
+CDEPEND="ssl? ( dev-libs/openssl )
+ !<=net-misc/ntp-4.2.0-r2
+ !net-misc/ntp[-openntpd]"
+DEPEND="${CDEPEND}
+ virtual/yacc"
+RDEPEND="${CDEPEND}
+ selinux? ( sec-policy/selinux-ntp )
+"
+
+S="${WORKDIR}/${MY_P/_/-}"
+
+pkg_setup() {
+ export NTP_HOME="${NTP_HOME:=/var/lib/openntpd/chroot}"
+ enewgroup ntp
+ enewuser ntp -1 -1 "${NTP_HOME}" ntp
+
+ # make sure user has correct HOME as flipng between
+ # the standard ntp pkg and this one was possible in
+ # the past
+ if [[ $(egethome ntp) != ${NTP_HOME} ]]; then
+ ewarn "From this version on, the homedir of the ntp user cannot be changed"
+ ewarn "dynamically after the installation. For homedir different from"
+ ewarn "/var/lib/openntpd/chroot set NTP_HOME in your make.conf and re-emerge."
+ esethome ntp "${NTP_HOME}"
+ fi
+}
+
+src_prepare() {
+ sed -i '/NTPD_USER/s:_ntp:ntp:' ntpd.h || die
+
+ epatch "${WORKDIR}"/debian/patches/*.patch
+ epatch "${FILESDIR}/${PN}-${MY_PV}-pidfile.patch"
+ epatch "${FILESDIR}/${PN}-${MY_PV}-signal.patch"
+ epatch "${FILESDIR}/${PN}-${MY_PV}-dns-timeout.patch"
+ sed -i 's:debian:gentoo:g' ntpd.conf || die
+ eautoreconf # deb patchset touches .ac files and such
+}
+
+src_configure() {
+ econf \
+ --disable-strip \
+ $(use_with !ssl builtin-arc4random) \
+ AR="$(type -p $(tc-getAR))"
+}
+
+src_install() {
+ default
+ rmdir "${ED}"/{var/empty,var}
+
+ newinitd "${FILESDIR}/${PN}.init.d-${MY_PV}-r6" ntpd
+ newconfd "${FILESDIR}/${PN}.conf.d-${MY_PV}-r6" ntpd
+
+ systemd_newunit "${FILESDIR}/${PN}.service-${MY_PV}-r4" ntpd.service
+}
+
+pkg_config() {
+ einfo "Setting up chroot for ntp in ${NTP_HOME}"
+ # remove localtime file from previous installations
+ rm -f "${EROOT%/}${NTP_HOME}"/etc/localtime
+ mkdir -p "${EROOT%/}${NTP_HOME}"/etc
+ if ! ln "${EROOT%/}"/etc/localtime "${EROOT%/}${NTP_HOME}"/etc/localtime ; then
+ cp "${EROOT%/}"/etc/localtime "${EROOT%/}${NTP_HOME}"/etc/localtime || die
+ einfo "We could not create a hardlink from /etc/localtime to ${NTP_HOME}/etc/localtime,"
+ einfo "so please run 'emerge --config =${CATEGORY}/${PF}' whenever you changed"
+ einfo "your timezone."
+ fi
+ chown -R root:root "${EROOT%/}${NTP_HOME}" || die
+}
+
+pkg_postinst() {
+ pkg_config
+
+ [[ -f ${EROOT}var/log/ntpd.log ]] && \
+ ewarn "There is an orphaned logfile '${EROOT}var/log/ntpd.log', please remove it!"
+
+ # bug #226491, remove <=openntpd-20080406-r7 trash
+ rm -f "${EROOT%/}${NTP_HOME}"etc/localtime
+ [-d "${EROOT%/}${NTP_HOME}"etc ] && rmdir "${EROOT%/}${NTP_HOME}"etc
+}
+
+pkg_postrm() {
+ # remove localtime file from previous installations
+ rm -f "${EROOT%/}${NTP_HOME}"/etc/localtime
+}
diff --git a/net-misc/openntpd/openntpd-5.7_p4-r1.ebuild b/net-misc/openntpd/openntpd-5.7_p4-r1.ebuild
new file mode 100644
index 000000000000..721bf80554e0
--- /dev/null
+++ b/net-misc/openntpd/openntpd-5.7_p4-r1.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+inherit eutils systemd user
+
+MY_P="${P/_p/p}"
+DESCRIPTION="Lightweight NTP server ported from OpenBSD"
+HOMEPAGE="http://www.openntpd.org/"
+SRC_URI="mirror://openbsd/OpenNTPD/${MY_P}.tar.gz"
+
+LICENSE="BSD GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
+IUSE="selinux"
+
+DEPEND="!<=net-misc/ntp-4.2.0-r2
+ !net-misc/ntp[-openntpd]"
+RDEPEND="${DEPEND}
+ selinux? ( sec-policy/selinux-ntp )"
+
+S="${WORKDIR}/${MY_P}"
+
+pkg_setup() {
+ export NTP_HOME="${NTP_HOME:=/var/lib/openntpd/chroot}"
+ enewgroup ntp
+ enewuser ntp -1 -1 "${NTP_HOME}" ntp
+
+ # make sure user has correct HOME as flipping between the standard ntp pkg
+ # and this one was possible in the past
+ if [[ $(egethome ntp) != ${NTP_HOME} ]]; then
+ ewarn "From this version on, the homedir of the ntp user cannot be changed"
+ ewarn "dynamically after the installation. For homedir different from"
+ ewarn "/var/lib/openntpd/chroot set NTP_HOME in your make.conf and re-emerge."
+ esethome ntp "${NTP_HOME}"
+ fi
+}
+
+src_prepare() {
+ # add fail constraints when no libtls patch (accepted upstream)
+ epatch "${FILESDIR}/${P}-nolibtls.patch"
+ # fix /run path
+ sed -i 's:/var/run/ntpd:/run/ntpd:g' src/ntpctl.8 src/ntpd.8 || die
+ sed -i 's:LOCALSTATEDIR "/run/ntpd:"/run/ntpd:' src/ntpd.h || die
+ # fix ntpd.drift path
+ sed -i 's:/var/db/ntpd.drift:/var/lib/openntpd/ntpd.drift:g' src/ntpd.8 || die
+ sed -i 's:"/db/ntpd.drift":"/openntpd/ntpd.drift":' src/ntpd.h || die
+ # fix default config to use gentoo pool
+ sed -i 's:servers pool.ntp.org:#servers pool.ntp.org:' ntpd.conf || die
+ printf "\n# Choose servers announced from Gentoo NTP Pool\nservers 0.gentoo.pool.ntp.org\nservers 1.gentoo.pool.ntp.org\nservers 2.gentoo.pool.ntp.org\nservers 3.gentoo.pool.ntp.org\n" >> ntpd.conf || die
+}
+
+src_configure() {
+ econf --with-privsep-user=ntp
+}
+
+src_install() {
+ default
+ rm -r "${ED}"/var
+
+ newinitd "${FILESDIR}/${PN}.init.d-20080406-r6" ntpd
+ newconfd "${FILESDIR}/${PN}.conf.d-20080406-r6" ntpd
+
+ systemd_newunit "${FILESDIR}/${PN}.service-20080406-r4" ntpd.service
+}
+
+pkg_postinst() {
+ # Clean up chroot localtime copy from older versions
+ if [ -d "${EROOT%/}${NTP_HOME}"/etc ] ; then
+ if [ -f "${EROOT%/}${NTP_HOME}"/etc/localtime ] ; then
+ rm -f "${EROOT%/}${NTP_HOME}"/etc/localtime
+ fi
+
+ rmdir "${EROOT%/}${NTP_HOME}"/etc ||
+ ewarn "Unable to remove legacy ${EROOT%/}${NTP_HOME}/etc directory"
+ fi
+
+ [[ -f ${EROOT}var/log/ntpd.log ]] && \
+ ewarn "Logfile '${EROOT}var/log/ntpd.log' might be orphaned, please remove it if not in use via syslog."
+
+ if [[ -f ${EROOT}var/lib/ntpd.drift ]] ; then
+ einfo "Moving ntpd.drift file to new location."
+ mv "${EROOT}var/lib/ntpd.drift" "${EROOT}var/lib/openntpd/ntpd.drift"
+ fi
+}