ntp-4.2.8_p9.ebuild 4.3 KB

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