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