1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_6 )
7 PYTHON_REQ_USE='threads(+)'
9 inherit flag-o-matic python-r1 waf-utils systemd user
11 if [[ ${PV} == *9999* ]]; then
13 EGIT_REPO_URI="https://gitlab.com/NTPsec/ntpsec.git"
17 SRC_URI="ftp://ftp.ntpsec.org/pub/releases/${PN}-${PV}.tar.gz"
20 KEYWORDS="~amd64 ~arm ~arm64 ~x86"
23 DESCRIPTION="The NTP reference implementation, refactored"
24 HOMEPAGE="https://www.ntpsec.org/"
27 oncore trimble truetime gpsd jjy generic spectracom
28 shm pps hpgps zyfer arbiter nmea neoclock modem
31 IUSE_NTPSEC_REFCLOCK=${NTPSEC_REFCLOCK[@]/#/rclock_}
33 LICENSE="HPND MIT BSD-2 BSD CC-BY-SA-4.0"
35 IUSE="${IUSE_NTPSEC_REFCLOCK} debug doc early gdb heat libbsd nist ntpviz samba seccomp smear tests" #ionice
36 REQUIRED_USE="${PYTHON_REQUIRED_USE} nist? ( rclock_local )"
38 # net-misc/pps-tools oncore,pps
39 CDEPEND="${PYTHON_DEPS}
42 dev-python/psutil[${PYTHON_USEDEP}]
43 libbsd? ( dev-libs/libbsd:0= )
45 seccomp? ( sys-libs/libseccomp )
48 ntpviz? ( sci-visualization/gnuplot media-fonts/liberation-fonts )
55 app-text/docbook-xsl-stylesheets
57 rclock_oncore? ( net-misc/pps-tools )
58 rclock_pps? ( net-misc/pps-tools )
65 enewuser ntp 123 -1 /dev/null ntp
70 # Remove autostripping of binaries
71 sed -i -e '/Strip binaries/d' wscript
72 if ! use libbsd ; then
73 epatch "${FILESDIR}/${PN}-no-bsd.patch"
79 is-flagq -flto* && filter-flags -flto* -fuse-linker-plugin
85 for refclock in ${NTPSEC_REFCLOCK[@]} ; do
86 if use rclock_${refclock} ; then
87 string_127+="$refclock,"
90 CLOCKSTRING="`echo ${string_127}|sed 's|,$||'`"
95 --refclock="${CLOCKSTRING}"
96 $(use doc && echo "--enable-doc")
97 $(use early && echo "--enable-early-droproot")
98 $(use gdb && echo "--enable-debug-gdb")
99 $(use samba && echo "--enable-mssntp")
100 $(use seccomp && echo "--enable-seccomp")
101 $(use smear && echo "--enable-leap-smear")
102 $(use tests && echo "--alltests")
103 $(use debug && echo "--enable-debug")
107 waf-utils_src_configure "${myconf[@]}"
109 python_foreach_impl run_in_build_dir python_configure
115 waf-utils_src_compile
117 python_foreach_impl run_in_build_dir python_compile
122 waf-utils_src_install
124 python_foreach_impl run_in_build_dir python_install
126 # Install heat generating scripts
127 use heat && dosbin "${S}"/contrib/ntpheat{,usb}
129 # Install the openrc files
130 newinitd "${FILESDIR}"/ntpd.rc-r2 ntp
131 newconfd "${FILESDIR}"/ntpd.confd ntp
133 # Install the systemd unit file
134 systemd_newunit "${FILESDIR}"/ntpd-r1.service ntpd.service
136 # Prepare a directory for the ntp.drift file
137 mkdir -pv "${ED}"/var/lib/ntp
138 chown ntp:ntp "${ED}"/var/lib/ntp
139 chmod 770 "${ED}"/var/lib/ntp
142 # Install a log rotate script
143 mkdir -pv "${ED}"/etc/logrotate.d
144 cp -v "${S}"/etc/logrotate-config.ntpd "${ED}"/etc/logrotate.d/ntpd
146 # Install the configuration file and sample configuration
147 cp -v "${FILESDIR}"/ntp.conf "${ED}"/etc/ntp.conf
148 cp -Rv "${S}"/etc/ntp.d/ "${ED}"/etc/
150 # move doc files to /usr/share/doc/"${P}"
151 use doc && mv -v "${ED}"/usr/share/doc/"${PN}" "${ED}"/usr/share/doc/"${P}"/html
155 einfo "If you want to serve time on your local network, then"
156 einfo "you should disable all the ref_clocks unless you have"
157 einfo "one and can get stable time from it. Feel free to try"
158 einfo "it but PPS probably won't work unless you have a UART"
159 einfo "GPS that actually provides PPS messages."