ntp-4.2.8_p10.ebuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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}"/${PN}-4.2.8_p10-ntpq-fpic.patch
  36. "${FILESDIR}"/${PN}-4.2.8_p10-libressl.patch
  37. )
  38. pkg_setup() {
  39. enewgroup ntp 123
  40. enewuser ntp 123 -1 /dev/null ntp
  41. }
  42. src_prepare() {
  43. epatch "${PATCHES[@]}"
  44. append-cppflags -D_GNU_SOURCE #264109
  45. # Make sure every build uses the same install layout. #539092
  46. find sntp/loc/ -type f '!' -name legacy -delete || die
  47. # Disable pointless checks.
  48. touch .checkChangeLog .gcc-warning FRC.html html/.datecheck
  49. }
  50. src_configure() {
  51. # avoid libmd5/libelf
  52. export ac_cv_search_MD5Init=no ac_cv_header_md5_h=no
  53. export ac_cv_lib_elf_nlist=no
  54. # blah, no real configure options #176333
  55. export ac_cv_header_dns_sd_h=$(usex zeroconf)
  56. export ac_cv_lib_dns_sd_DNSServiceRegister=${ac_cv_header_dns_sd_h}
  57. # Increase the default memlimit from 32MiB to 128MiB. #533232
  58. econf \
  59. --with-lineeditlibs=readline,edit,editline \
  60. --with-yielding-select \
  61. --disable-local-libevent \
  62. --docdir='$(datarootdir)'/doc/${PF} \
  63. --htmldir='$(docdir)/html' \
  64. --with-memlock=256 \
  65. $(use_enable caps linuxcaps) \
  66. $(use_enable parse-clocks) \
  67. $(use_enable ipv6) \
  68. $(use_enable debug debugging) \
  69. $(use_with readline lineeditlibs readline) \
  70. $(use_enable samba ntp-signd) \
  71. $(use_with snmp ntpsnmpd) \
  72. $(use_with ssl crypto) \
  73. $(use_enable threads thread-support)
  74. }
  75. src_install() {
  76. default
  77. # move ntpd/ntpdate to sbin #66671
  78. dodir /usr/sbin
  79. mv "${ED}"/usr/bin/{ntpd,ntpdate} "${ED}"/usr/sbin/ || die "move to sbin"
  80. dodoc INSTALL WHERE-TO-START
  81. doman "${WORKDIR}"/man/*.[58]
  82. insinto /etc
  83. doins "${FILESDIR}"/ntp.conf
  84. use ipv6 || sed -i '/^restrict .*::1/d' "${ED}"/etc/ntp.conf #524726
  85. newinitd "${FILESDIR}"/ntpd.rc-r1 ntpd
  86. newconfd "${FILESDIR}"/ntpd.confd ntpd
  87. newinitd "${FILESDIR}"/ntp-client.rc ntp-client
  88. newconfd "${FILESDIR}"/ntp-client.confd ntp-client
  89. newinitd "${FILESDIR}"/sntp.rc sntp
  90. newconfd "${FILESDIR}"/sntp.confd sntp
  91. if ! use caps ; then
  92. sed -i "s|-u ntp:ntp||" "${ED}"/etc/conf.d/ntpd || die
  93. fi
  94. sed -i "s:/usr/bin:/usr/sbin:" "${ED}"/etc/init.d/ntpd || die
  95. keepdir /var/lib/ntp
  96. use prefix || fowners ntp:ntp /var/lib/ntp
  97. if use openntpd ; then
  98. cd "${ED}"
  99. rm usr/sbin/ntpd || die
  100. rm -r var/lib
  101. rm etc/{conf,init}.d/ntpd
  102. rm usr/share/man/*/ntpd.8 || die
  103. else
  104. systemd_newunit "${FILESDIR}"/ntpd.service-r2 ntpd.service
  105. use caps && sed -i '/ExecStart/ s|$| -u ntp:ntp|' "${ED}"/usr/lib/systemd/system/ntpd.service
  106. systemd_enable_ntpunit 60-ntpd ntpd.service
  107. fi
  108. systemd_newunit "${FILESDIR}"/ntpdate.service-r1 ntpdate.service
  109. systemd_install_serviced "${FILESDIR}"/ntpdate.service.conf
  110. systemd_newunit "${FILESDIR}"/sntp.service-r2 sntp.service
  111. systemd_install_serviced "${FILESDIR}"/sntp.service.conf
  112. }
  113. pkg_postinst() {
  114. if grep -qs '^[^#].*notrust' "${EROOT}"/etc/ntp.conf ; then
  115. eerror "The notrust option was found in your /etc/ntp.conf!"
  116. ewarn "If your ntpd starts sending out weird responses,"
  117. ewarn "then make sure you have keys properly setup and see"
  118. ewarn "https://bugs.gentoo.org/41827"
  119. fi
  120. }