dev-python/csv23: arm64 keyworded (bug #719700)
[gentoo.git] / net-misc / ntpsec / ntpsec-1.1.6.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python3_6 )
7 PYTHON_REQ_USE='threads(+)'
8
9 inherit flag-o-matic python-r1 waf-utils systemd user
10
11 if [[ ${PV} == *9999* ]]; then
12         inherit git-r3
13         EGIT_REPO_URI="https://gitlab.com/NTPsec/ntpsec.git"
14         BDEPEND=""
15         KEYWORDS=""
16 else
17         SRC_URI="ftp://ftp.ntpsec.org/pub/releases/${PN}-${PV}.tar.gz"
18         RESTRICT="mirror"
19         BDEPEND=""
20         KEYWORDS="~amd64 ~arm ~arm64 ~x86"
21 fi
22
23 DESCRIPTION="The NTP reference implementation, refactored"
24 HOMEPAGE="https://www.ntpsec.org/"
25
26 NTPSEC_REFCLOCK=(
27         oncore trimble truetime gpsd jjy generic spectracom
28         shm pps hpgps zyfer arbiter nmea neoclock modem
29         local)
30
31 IUSE_NTPSEC_REFCLOCK=${NTPSEC_REFCLOCK[@]/#/rclock_}
32
33 LICENSE="HPND MIT BSD-2 BSD CC-BY-SA-4.0"
34 SLOT="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 )"
37
38 # net-misc/pps-tools oncore,pps
39 CDEPEND="${PYTHON_DEPS}
40         ${BDEPEND}
41         sys-libs/libcap
42         dev-python/psutil[${PYTHON_USEDEP}]
43         libbsd? ( dev-libs/libbsd:0= )
44         dev-libs/openssl:0=
45         seccomp? ( sys-libs/libseccomp )
46 "
47 RDEPEND="${CDEPEND}
48         ntpviz? ( sci-visualization/gnuplot media-fonts/liberation-fonts )
49         !net-misc/ntp
50         !net-misc/openntpd
51 "
52 DEPEND="${CDEPEND}
53         app-text/asciidoc
54         dev-libs/libxslt
55         app-text/docbook-xsl-stylesheets
56         sys-devel/bison
57         rclock_oncore? ( net-misc/pps-tools )
58         rclock_pps? ( net-misc/pps-tools )
59 "
60
61 WAF_BINARY="${S}/waf"
62
63 pkg_setup() {
64         enewgroup ntp 123
65         enewuser ntp 123 -1 /dev/null ntp
66 }
67
68 src_prepare() {
69         default
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"
74         fi
75         python_copy_sources
76 }
77
78 src_configure() {
79         is-flagq -flto* && filter-flags -flto* -fuse-linker-plugin
80
81         local string_127=""
82         local rclocks="";
83         local CLOCKSTRING=""
84
85         for refclock in ${NTPSEC_REFCLOCK[@]} ; do
86                 if use rclock_${refclock} ; then
87                         string_127+="$refclock,"
88                 fi
89         done
90         CLOCKSTRING="`echo ${string_127}|sed 's|,$||'`"
91
92         local myconf=(
93                 --nopyc
94                 --nopyo
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")
104         )
105
106         python_configure() {
107                 waf-utils_src_configure "${myconf[@]}"
108         }
109         python_foreach_impl run_in_build_dir python_configure
110 }
111
112 src_compile() {
113         unset MAKEOPTS
114         python_compile() {
115                 waf-utils_src_compile
116         }
117         python_foreach_impl run_in_build_dir python_compile
118 }
119
120 src_install() {
121         python_install() {
122                 waf-utils_src_install
123         }
124         python_foreach_impl run_in_build_dir python_install
125
126         # Install heat generating scripts
127         use heat && dosbin "${S}"/contrib/ntpheat{,usb}
128
129         # Install the openrc files
130         newinitd "${FILESDIR}"/ntpd.rc-r2 ntp
131         newconfd "${FILESDIR}"/ntpd.confd ntp
132
133         # Install the systemd unit file
134         systemd_newunit "${FILESDIR}"/ntpd-r1.service ntpd.service
135
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
140         keepdir /var/lib/ntp
141
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
145
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/
149
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
152 }
153
154 pkg_postinst() {
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."
160 }