Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/ntpsec/files/, net-misc/ntpsec/
Date: Fri, 03 Jun 2022 05:32:51
Message-Id: 1654234172.729d3c0a57feff2c9edb4e87136535c133877e4b.sam@gentoo
1 commit: 729d3c0a57feff2c9edb4e87136535c133877e4b
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 3 05:20:50 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Fri Jun 3 05:29:32 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=729d3c0a
7
8 net-misc/ntpsec: Improve OpenRC script for ntpd
9
10 The attached script updates a couple things which effectively is
11 the same as the current model however it follows the modular nature of the
12 declarative syntax.
13
14 Changes:
15 * Removes the duplicating start_stop_daemon_args since --pidfile is automatic
16 with pidfile=
17 * Only have ntpd create the pidfile when forking via command_args_background
18 * Add command_args_foreground for the option not to fork
19
20 Closes: https://bugs.gentoo.org/828078
21 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
22 Signed-off-by: Sam James <sam <AT> gentoo.org>
23
24 net-misc/ntpsec/files/ntpd.rc-r3 | 23 +++++
25 net-misc/ntpsec/ntpsec-1.2.1-r4.ebuild | 177 +++++++++++++++++++++++++++++++++
26 2 files changed, 200 insertions(+)
27
28 diff --git a/net-misc/ntpsec/files/ntpd.rc-r3 b/net-misc/ntpsec/files/ntpd.rc-r3
29 new file mode 100644
30 index 000000000000..68d07237455c
31 --- /dev/null
32 +++ b/net-misc/ntpsec/files/ntpd.rc-r3
33 @@ -0,0 +1,23 @@
34 +#!/sbin/openrc-run
35 +# Copyright 1999-2021 Gentoo Foundation
36 +# Distributed under the terms of the GNU General Public License v2
37 +
38 +description="ntpd - the network time protocol daemon"
39 +pidfile="/run/ntpd.pid"
40 +command="/usr/sbin/ntpd"
41 +command_args="${NTPD_OPTS}"
42 +command_args_background="-p ${pidfile}"
43 +command_args_foreground="-n"
44 +
45 +depend() {
46 + use net dns logger
47 + after ntp-client
48 +}
49 +
50 +start_pre() {
51 + if [ ! -f /etc/ntp.conf ] ; then
52 + eerror "Please create /etc/ntp.conf"
53 + return 1
54 + fi
55 + return 0
56 +}
57
58 diff --git a/net-misc/ntpsec/ntpsec-1.2.1-r4.ebuild b/net-misc/ntpsec/ntpsec-1.2.1-r4.ebuild
59 new file mode 100644
60 index 000000000000..c6da1c0300fc
61 --- /dev/null
62 +++ b/net-misc/ntpsec/ntpsec-1.2.1-r4.ebuild
63 @@ -0,0 +1,177 @@
64 +# Copyright 1999-2022 Gentoo Authors
65 +# Distributed under the terms of the GNU General Public License v2
66 +
67 +EAPI=7
68 +
69 +PYTHON_COMPAT=( python3_{8..10} )
70 +PYTHON_REQ_USE='threads(+)'
71 +DISTUTILS_USE_SETUPTOOLS=no
72 +
73 +inherit distutils-r1 flag-o-matic waf-utils systemd
74 +
75 +if [[ ${PV} == *9999* ]]; then
76 + inherit git-r3
77 + EGIT_REPO_URI="https://gitlab.com/NTPsec/ntpsec.git"
78 +else
79 + SRC_URI="ftp://ftp.ntpsec.org/pub/releases/${P}.tar.gz"
80 + KEYWORDS="~amd64 ~arm ~arm64 ~riscv ~x86"
81 +fi
82 +
83 +DESCRIPTION="The NTP reference implementation, refactored"
84 +HOMEPAGE="https://www.ntpsec.org/"
85 +
86 +NTPSEC_REFCLOCK=(
87 + oncore trimble truetime gpsd jjy generic spectracom
88 + shm pps hpgps zyfer arbiter nmea modem local
89 +)
90 +
91 +IUSE_NTPSEC_REFCLOCK=${NTPSEC_REFCLOCK[@]/#/rclock_}
92 +
93 +LICENSE="HPND MIT BSD-2 BSD CC-BY-SA-4.0"
94 +SLOT="0"
95 +IUSE="${IUSE_NTPSEC_REFCLOCK} debug doc early gdb heat libbsd nist ntpviz samba seccomp smear" #ionice
96 +REQUIRED_USE="${PYTHON_REQUIRED_USE} nist? ( rclock_local )"
97 +
98 +# net-misc/pps-tools oncore,pps
99 +DEPEND="${PYTHON_DEPS}
100 + dev-libs/openssl:=
101 + dev-python/psutil[${PYTHON_USEDEP}]
102 + sys-libs/libcap
103 + libbsd? ( dev-libs/libbsd:0= )
104 + seccomp? ( sys-libs/libseccomp )
105 + rclock_oncore? ( net-misc/pps-tools )
106 + rclock_pps? ( net-misc/pps-tools )"
107 +RDEPEND="${DEPEND}
108 + !net-misc/ntp
109 + !net-misc/openntpd
110 + acct-group/ntp
111 + acct-user/ntp
112 + ntpviz? ( sci-visualization/gnuplot media-fonts/liberation-fonts )"
113 +BDEPEND=">=app-text/asciidoc-8.6.8
114 + dev-libs/libxslt
115 + app-text/docbook-xsl-stylesheets
116 + sys-devel/bison"
117 +
118 +PATCHES=(
119 + "${FILESDIR}/${PN}-1.1.9-remove-asciidoctor-from-config.patch"
120 + "${FILESDIR}/${PN}-1.2.1-seccomp-rollup.patch"
121 + "${FILESDIR}/${PN}-1.2.1-seccomp-rseq-glibc-2.35.patch"
122 + "${FILESDIR}/${PN}-1.2.1-build-notests.patch"
123 + "${FILESDIR}/${PN}-py3-test-clarify.patch"
124 +)
125 +
126 +WAF_BINARY="${S}/waf"
127 +
128 +src_prepare() {
129 + default
130 +
131 + # Remove autostripping of binaries
132 + sed -i -e '/Strip binaries/d' wscript || die
133 + if ! use libbsd ; then
134 + eapply "${FILESDIR}/${PN}-no-bsd.patch"
135 + fi
136 + # remove extra default pool servers
137 + sed -i '/use-pool/s/^/#/' "${S}"/etc/ntp.d/default.conf || die
138 +
139 + python_copy_sources
140 +}
141 +
142 +src_configure() {
143 + is-flagq -flto* && filter-flags -flto* -fuse-linker-plugin
144 +
145 + local string_127=""
146 + local rclocks="";
147 + local CLOCKSTRING=""
148 +
149 + for refclock in ${NTPSEC_REFCLOCK[@]} ; do
150 + if use rclock_${refclock} ; then
151 + string_127+="$refclock,"
152 + fi
153 + done
154 + CLOCKSTRING="`echo ${string_127}|sed 's|,$||'`"
155 +
156 + local myconf=(
157 + --notests
158 + --nopyc
159 + --nopyo
160 + --enable-pylib ext
161 + --refclock="${CLOCKSTRING}"
162 + #--build-epoch="$(date +%s)"
163 + $(use doc || echo "--disable-doc")
164 + $(use early && echo "--enable-early-droproot")
165 + $(use gdb && echo "--enable-debug-gdb")
166 + $(use samba && echo "--enable-mssntp")
167 + $(use seccomp && echo "--enable-seccomp")
168 + $(use smear && echo "--enable-leap-smear")
169 + $(use debug && echo "--enable-debug")
170 + )
171 +
172 + python_configure() {
173 + waf-utils_src_configure "${myconf[@]}"
174 + }
175 + python_foreach_impl run_in_build_dir python_configure
176 +}
177 +
178 +src_compile() {
179 + unset MAKEOPTS
180 + python_compile() {
181 + waf-utils_src_compile --notests
182 + }
183 + python_foreach_impl run_in_build_dir python_compile
184 +}
185 +
186 +src_test() {
187 + python_compile() {
188 + waf-utils_src_compile check
189 + }
190 + python_foreach_impl run_in_build_dir python_compile
191 +}
192 +
193 +python_test() {
194 + # Silence QA warning as we're running tests via src_test anyway.
195 + :;
196 +}
197 +
198 +src_install() {
199 + python_install() {
200 + waf-utils_src_install --notests
201 + python_fix_shebang "${ED}"
202 + }
203 + python_foreach_impl run_in_build_dir python_install
204 + python_foreach_impl python_optimize
205 +
206 + # Install heat generating scripts
207 + use heat && dosbin "${S}"/contrib/ntpheat{,usb}
208 +
209 + # Install the openrc files
210 + newinitd "${FILESDIR}"/ntpd.rc-r3 ntp
211 + newconfd "${FILESDIR}"/ntpd.confd ntp
212 +
213 + # Install the systemd unit file
214 + systemd_newunit "${FILESDIR}"/ntpd-r1.service ntpd.service
215 +
216 + # Prepare a directory for the ntp.drift file
217 + mkdir -pv "${ED}"/var/lib/ntp
218 + chown ntp:ntp "${ED}"/var/lib/ntp
219 + chmod 770 "${ED}"/var/lib/ntp
220 + keepdir /var/lib/ntp
221 +
222 + # Install a log rotate script
223 + mkdir -pv "${ED}"/etc/logrotate.d
224 + cp -v "${S}"/etc/logrotate-config.ntpd "${ED}"/etc/logrotate.d/ntpd
225 +
226 + # Install the configuration file and sample configuration
227 + cp -v "${FILESDIR}"/ntp.conf "${ED}"/etc/ntp.conf
228 + cp -Rv "${S}"/etc/ntp.d/ "${ED}"/etc/
229 +
230 + # move doc files to /usr/share/doc/"${P}"
231 + use doc && mv -v "${ED}"/usr/share/doc/"${PN}" "${ED}"/usr/share/doc/"${P}"/html
232 +}
233 +
234 +pkg_postinst() {
235 + einfo "If you want to serve time on your local network, then"
236 + einfo "you should disable all the ref_clocks unless you have"
237 + einfo "one and can get stable time from it. Feel free to try"
238 + einfo "it but PPS probably won't work unless you have a UART"
239 + einfo "GPS that actually provides PPS messages."
240 +}