sys-process/glances: revbump 3.1.4.1, add missing doc dep
[gentoo.git] / net-misc / ntp / ntp-4.2.8_p14-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools toolchain-funcs flag-o-matic systemd
7
8 MY_P=${P/_p/p}
9 DESCRIPTION="Network Time Protocol suite/programs"
10 HOMEPAGE="http://www.ntp.org/"
11 SRC_URI="http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${PV:0:3}/${MY_P}.tar.gz
12         https://dev.gentoo.org/~polynomial-c/${MY_P}-manpages.tar.xz"
13
14 LICENSE="HPND BSD ISC"
15 SLOT="0"
16 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~amd64-linux ~x86-linux ~m68k-mint"
17 IUSE="caps debug ipv6 libressl openntpd parse-clocks readline samba selinux snmp ssl +threads vim-syntax zeroconf"
18
19 COMMON_DEPEND="readline? ( >=sys-libs/readline-4.1:0= )
20         >=dev-libs/libevent-2.0.9:=[threads?]
21         kernel_linux? ( caps? ( sys-libs/libcap ) )
22         zeroconf? ( net-dns/avahi[mdnsresponder-compat] )
23         snmp? ( net-analyzer/net-snmp )
24         ssl? (
25                 !libressl? ( dev-libs/openssl:0= )
26                 libressl? ( dev-libs/libressl:0= )
27         )
28         parse-clocks? ( net-misc/pps-tools )"
29 BDEPEND="virtual/pkgconfig
30         acct-group/ntp
31         acct-user/ntp"
32 DEPEND="${COMMON_DEPEND}"
33 RDEPEND="${COMMON_DEPEND}
34         acct-group/ntp
35         acct-user/ntp
36         selinux? ( sec-policy/selinux-ntp )
37         vim-syntax? ( app-vim/ntp-syntax )
38         !net-misc/ntpsec
39         !openntpd? ( !net-misc/openntpd )
40 "
41 PDEPEND="openntpd? ( net-misc/openntpd )"
42
43 S="${WORKDIR}/${MY_P}"
44
45 PATCHES=(
46         "${FILESDIR}"/${PN}-4.2.8-ipc-caps.patch #533966
47         "${FILESDIR}"/${PN}-4.2.8-sntp-test-pthreads.patch #563922
48         "${FILESDIR}"/${PN}-4.2.8_p10-fix-build-wo-ssl-or-libressl.patch
49         "${FILESDIR}"/${PN}-4.2.8_p12-libressl-2.8.patch
50         "${FILESDIR}"/${PN}-4.2.8_p14-add_cap_ipc_lock.patch #711530
51         "${FILESDIR}"/${PN}-4.2.8-gcc10-fno-common.patch
52 )
53
54 src_prepare() {
55         default
56         append-cppflags -D_GNU_SOURCE #264109
57         # Make sure every build uses the same install layout. #539092
58         find sntp/loc/ -type f '!' -name legacy -delete || die
59         eautoreconf #622754
60         # Disable pointless checks.
61         touch .checkChangeLog .gcc-warning FRC.html html/.datecheck
62 }
63
64 src_configure() {
65         # avoid libmd5/libelf
66         export ac_cv_search_MD5Init=no ac_cv_header_md5_h=no
67         export ac_cv_lib_elf_nlist=no
68         # blah, no real configure options #176333
69         export ac_cv_header_dns_sd_h=$(usex zeroconf)
70         export ac_cv_lib_dns_sd_DNSServiceRegister=${ac_cv_header_dns_sd_h}
71         # Increase the default memlimit from 32MiB to 128MiB.  #533232
72         local myeconfargs=(
73                 --with-lineeditlibs=readline,edit,editline
74                 --with-yielding-select
75                 --disable-local-libevent
76                 --with-memlock=256
77                 $(use_enable caps linuxcaps)
78                 $(use_enable parse-clocks)
79                 $(use_enable ipv6)
80                 $(use_enable debug debugging)
81                 $(use_with readline lineeditlibs readline)
82                 $(use_enable samba ntp-signd)
83                 $(use_with snmp ntpsnmpd)
84                 $(use_with ssl crypto)
85                 $(use_enable threads thread-support)
86         )
87         econf "${myeconfargs[@]}"
88 }
89
90 src_install() {
91         default
92         # move ntpd/ntpdate to sbin #66671
93         dodir /usr/sbin
94         mv "${ED}"/usr/bin/{ntpd,ntpdate} "${ED}"/usr/sbin/ || die "move to sbin"
95
96         dodoc INSTALL WHERE-TO-START
97         doman "${WORKDIR}"/man/*.[58]
98
99         insinto /etc
100         doins "${FILESDIR}"/ntp.conf
101         use ipv6 || sed -i '/^restrict .*::1/d' "${ED}"/etc/ntp.conf #524726
102         newinitd "${FILESDIR}"/ntpd.rc-r1 ntpd
103         newconfd "${FILESDIR}"/ntpd.confd ntpd
104         newinitd "${FILESDIR}"/ntp-client.rc ntp-client
105         newconfd "${FILESDIR}"/ntp-client.confd ntp-client
106         newinitd "${FILESDIR}"/sntp.rc sntp
107         newconfd "${FILESDIR}"/sntp.confd sntp
108         if ! use caps ; then
109                 sed -i "s|-u ntp:ntp||" "${ED}"/etc/conf.d/ntpd || die
110         fi
111         sed -i "s:/usr/bin:/usr/sbin:" "${ED}"/etc/init.d/ntpd || die
112
113         keepdir /var/lib/ntp
114         use prefix || fowners ntp:ntp /var/lib/ntp
115
116         if use openntpd ; then
117                 cd "${ED}" || die
118                 rm usr/sbin/ntpd || die
119                 rm -r var/lib || die
120                 rm etc/{conf,init}.d/ntpd || die
121                 rm usr/share/man/*/ntpd.8 || die
122         else
123                 systemd_newunit "${FILESDIR}"/ntpd.service-r2 ntpd.service
124                 if use caps ; then
125                         sed -i '/ExecStart/ s|$| -u ntp:ntp|' \
126                                 "${D}$(systemd_get_systemunitdir)"/ntpd.service \
127                                 || die
128                 fi
129                 systemd_enable_ntpunit 60-ntpd ntpd.service
130         fi
131
132         systemd_newunit "${FILESDIR}"/ntpdate.service-r2 ntpdate.service
133         systemd_install_serviced "${FILESDIR}"/ntpdate.service.conf
134         systemd_newunit "${FILESDIR}"/sntp.service-r3 sntp.service
135         systemd_install_serviced "${FILESDIR}"/sntp.service.conf
136 }
137
138 pkg_postinst() {
139         if grep -qs '^[^#].*notrust' "${EROOT}"/etc/ntp.conf ; then
140                 eerror "The notrust option was found in your /etc/ntp.conf!"
141                 ewarn "If your ntpd starts sending out weird responses,"
142                 ewarn "then make sure you have keys properly setup and see"
143                 ewarn "https://bugs.gentoo.org/41827"
144         fi
145 }