dev-perl/DBIx-Class-UserStamp: Fix missing test dep on DBD-SQLite
[gentoo.git] / net-misc / ntp / ntp-4.2.8_p9.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils toolchain-funcs flag-o-matic user 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 ~s390 ~sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~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 CDEPEND="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         !openntpd? ( !net-misc/openntpd )
24         snmp? ( net-analyzer/net-snmp )
25         ssl? (
26                 !libressl? ( dev-libs/openssl:0= )
27                 libressl? ( dev-libs/libressl )
28         )
29         parse-clocks? ( net-misc/pps-tools )"
30 DEPEND="${CDEPEND}
31         virtual/pkgconfig"
32 RDEPEND="${CDEPEND}
33         selinux? ( sec-policy/selinux-ntp )
34         vim-syntax? ( app-vim/ntp-syntax )"
35 PDEPEND="openntpd? ( net-misc/openntpd )"
36
37 S=${WORKDIR}/${MY_P}
38
39 PATCHES=(
40         "${FILESDIR}"/${PN}-4.2.8-ipc-caps.patch #533966
41         "${FILESDIR}"/${PN}-4.2.8-sntp-test-pthreads.patch #563922
42         "${FILESDIR}"/${P}-fix-build-wo-ssl-or-libressl.patch
43 )
44
45 pkg_setup() {
46         enewgroup ntp 123
47         enewuser ntp 123 -1 /dev/null ntp
48 }
49
50 src_prepare() {
51         epatch "${PATCHES[@]}"
52         append-cppflags -D_GNU_SOURCE #264109
53         # Make sure every build uses the same install layout. #539092
54         find sntp/loc/ -type f '!' -name legacy -delete || die
55         # Disable pointless checks.
56         touch .checkChangeLog .gcc-warning FRC.html html/.datecheck
57 }
58
59 src_configure() {
60         # avoid libmd5/libelf
61         export ac_cv_search_MD5Init=no ac_cv_header_md5_h=no
62         export ac_cv_lib_elf_nlist=no
63         # blah, no real configure options #176333
64         export ac_cv_header_dns_sd_h=$(usex zeroconf)
65         export ac_cv_lib_dns_sd_DNSServiceRegister=${ac_cv_header_dns_sd_h}
66         # Increase the default memlimit from 32MiB to 128MiB.  #533232
67         econf \
68                 --with-lineeditlibs=readline,edit,editline \
69                 --with-yielding-select \
70                 --disable-local-libevent \
71                 --docdir='$(datarootdir)'/doc/${PF} \
72                 --htmldir='$(docdir)/html' \
73                 --with-memlock=256 \
74                 $(use_enable caps linuxcaps) \
75                 $(use_enable parse-clocks) \
76                 $(use_enable ipv6) \
77                 $(use_enable debug debugging) \
78                 $(use_with readline lineeditlibs readline) \
79                 $(use_enable samba ntp-signd) \
80                 $(use_with snmp ntpsnmpd) \
81                 $(use_with ssl crypto) \
82                 $(use_enable threads thread-support)
83 }
84
85 src_install() {
86         default
87         # move ntpd/ntpdate to sbin #66671
88         dodir /usr/sbin
89         mv "${ED}"/usr/bin/{ntpd,ntpdate} "${ED}"/usr/sbin/ || die "move to sbin"
90
91         dodoc INSTALL WHERE-TO-START
92         doman "${WORKDIR}"/man/*.[58]
93
94         insinto /etc
95         doins "${FILESDIR}"/ntp.conf
96         use ipv6 || sed -i '/^restrict .*::1/d' "${ED}"/etc/ntp.conf #524726
97         newinitd "${FILESDIR}"/ntpd.rc-r1 ntpd
98         newconfd "${FILESDIR}"/ntpd.confd ntpd
99         newinitd "${FILESDIR}"/ntp-client.rc ntp-client
100         newconfd "${FILESDIR}"/ntp-client.confd ntp-client
101         newinitd "${FILESDIR}"/sntp.rc sntp
102         newconfd "${FILESDIR}"/sntp.confd sntp
103         if ! use caps ; then
104                 sed -i "s|-u ntp:ntp||" "${ED}"/etc/conf.d/ntpd || die
105         fi
106         sed -i "s:/usr/bin:/usr/sbin:" "${ED}"/etc/init.d/ntpd || die
107
108         keepdir /var/lib/ntp
109         use prefix || fowners ntp:ntp /var/lib/ntp
110
111         if use openntpd ; then
112                 cd "${ED}"
113                 rm usr/sbin/ntpd || die
114                 rm -r var/lib
115                 rm etc/{conf,init}.d/ntpd
116                 rm usr/share/man/*/ntpd.8 || die
117         else
118                 systemd_newunit "${FILESDIR}"/ntpd.service-r2 ntpd.service
119                 use caps && sed -i '/ExecStart/ s|$| -u ntp:ntp|' "${ED}"/usr/lib/systemd/system/ntpd.service
120                 systemd_enable_ntpunit 60-ntpd ntpd.service
121         fi
122
123         systemd_newunit "${FILESDIR}"/ntpdate.service-r1 ntpdate.service
124         systemd_install_serviced "${FILESDIR}"/ntpdate.service.conf
125         systemd_newunit "${FILESDIR}"/sntp.service-r2 sntp.service
126         systemd_install_serviced "${FILESDIR}"/sntp.service.conf
127 }
128
129 pkg_postinst() {
130         if grep -qs '^[^#].*notrust' "${EROOT}"/etc/ntp.conf ; then
131                 eerror "The notrust option was found in your /etc/ntp.conf!"
132                 ewarn "If your ntpd starts sending out weird responses,"
133                 ewarn "then make sure you have keys properly setup and see"
134                 ewarn "https://bugs.gentoo.org/41827"
135         fi
136 }