logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

chrony-4.2-r2.ebuild (5669B)


  1. # Copyright 1999-2022 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=7
  4. inherit systemd tmpfiles toolchain-funcs
  5. DESCRIPTION="NTP client and server programs"
  6. HOMEPAGE="https://chrony.tuxfamily.org/ https://git.tuxfamily.org/chrony/chrony.git"
  7. if [[ ${PV} == "9999" ]] ; then
  8. EGIT_REPO_URI="https://git.tuxfamily.org/chrony/chrony.git"
  9. inherit git-r3
  10. else
  11. VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/mlichvar.asc
  12. inherit verify-sig
  13. SRC_URI="https://download.tuxfamily.org/${PN}/${P/_/-}.tar.gz"
  14. SRC_URI+=" verify-sig? ( https://download.tuxfamily.org/chrony/${P/_/-}-tar-gz-asc.txt -> ${P/_/-}.tar.gz.asc )"
  15. if [[ ${PV} != *_pre* ]] ; then
  16. KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
  17. fi
  18. fi
  19. S="${WORKDIR}/${P/_/-}"
  20. LICENSE="GPL-2"
  21. SLOT="0"
  22. IUSE="+cmdmon debug html ipv6 libedit libtomcrypt +nettle nss +ntp +nts +phc pps +refclock +rtc samba +seccomp +sechash selinux"
  23. # nettle > nss > libtomcrypt in configure
  24. REQUIRED_USE="
  25. sechash? ( || ( nettle nss libtomcrypt ) )
  26. nettle? ( !nss )
  27. nss? ( !nettle )
  28. libtomcrypt? ( !nettle !nss )
  29. !sechash? ( !nss )
  30. !sechash? ( !nts? ( !nettle ) )
  31. "
  32. DEPEND="
  33. acct-group/ntp
  34. acct-user/ntp
  35. libedit? ( dev-libs/libedit )
  36. !libedit? ( sys-libs/readline:= )
  37. nettle? ( dev-libs/nettle:= )
  38. nss? ( dev-libs/nss:= )
  39. nts? ( net-libs/gnutls:= )
  40. pps? ( net-misc/pps-tools )
  41. seccomp? ( sys-libs/libseccomp )
  42. "
  43. RDEPEND="
  44. ${DEPEND}
  45. selinux? ( sec-policy/selinux-chronyd )
  46. >=sys-apps/openrc-0.45
  47. "
  48. BDEPEND="
  49. html? ( dev-ruby/asciidoctor )
  50. nts? ( virtual/pkgconfig )
  51. sechash? (
  52. nettle? ( virtual/pkgconfig )
  53. nss? ( virtual/pkgconfig )
  54. )
  55. "
  56. if [[ ${PV} == "9999" ]] ; then
  57. # Needed for doc generation in 9999
  58. REQUIRED_USE+=" html"
  59. BDEPEND+=" virtual/w3m"
  60. else
  61. BDEPEND+=" verify-sig? ( >=sec-keys/openpgp-keys-mlichvar-20210513 )"
  62. fi
  63. PATCHES=(
  64. "${FILESDIR}"/${PN}-3.5-pool-vendor-gentoo.patch
  65. "${FILESDIR}"/${PN}-4.2-systemd-gentoo.patch
  66. "${FILESDIR}"/${P}-test-mawk.patch
  67. "${FILESDIR}"/${P}-seccomp-rseq.patch
  68. )
  69. src_prepare() {
  70. default
  71. sed -i \
  72. -e 's:/etc/chrony\.conf:/etc/chrony/chrony.conf:g' \
  73. doc/* examples/* || die
  74. cp "${FILESDIR}"/chronyd.conf-r3 "${T}"/chronyd.conf || die
  75. }
  76. src_configure() {
  77. if ! use seccomp ; then
  78. sed -i \
  79. -e 's/ -F 2//' \
  80. "${T}"/chronyd.conf examples/chronyd.service || die
  81. fi
  82. tc-export CC PKG_CONFIG
  83. # Update from time to time with output from "date +%s"
  84. # on a system that is time-synced.
  85. export SOURCE_DATE_EPOCH=1607976314
  86. # Not an autotools generated script
  87. local myconf=(
  88. $(use_enable seccomp scfilter)
  89. --disable-linuxcaps
  90. $(usex cmdmon '' '--disable-cmdmon')
  91. $(usex debug '--enable-debug' '')
  92. $(usex ipv6 '' '--disable-ipv6')
  93. $(usex libedit '' '--without-editline')
  94. $(usex libtomcrypt '' '--without-tomcrypt')
  95. $(usex nettle '' '--without-nettle')
  96. $(usex nss '' '--without-nss')
  97. $(usex ntp '' '--disable-ntp')
  98. $(usex nts '' '--disable-nts')
  99. $(usex nts '' '--without-gnutls')
  100. $(usex phc '' '--disable-phc')
  101. $(usex pps '' '--disable-pps')
  102. $(usex refclock '' '--disable-refclock')
  103. $(usex rtc '' '--disable-rtc')
  104. $(usex samba '--enable-ntp-signd' '')
  105. $(usex sechash '' '--disable-sechash')
  106. --chronysockdir="${EPREFIX}/run/chrony"
  107. --docdir="${EPREFIX}/usr/share/doc/${PF}"
  108. --mandir="${EPREFIX}/usr/share/man"
  109. --prefix="${EPREFIX}/usr"
  110. --sysconfdir="${EPREFIX}/etc/chrony"
  111. --with-hwclockfile="${EPREFIX}/etc/adjtime"
  112. --with-pidfile="${EPREFIX}/run/chrony/chronyd.pid"
  113. --with-user="ntp"
  114. ${EXTRA_ECONF}
  115. )
  116. # Print the ./configure call
  117. echo sh ./configure "${myconf[@]}" >&2
  118. sh ./configure "${myconf[@]}" || die
  119. }
  120. src_compile() {
  121. if [[ ${PV} == "9999" ]] ; then
  122. # Uses w3m
  123. emake -C doc man txt
  124. fi
  125. emake all docs $(usex html '' 'ADOC=true')
  126. }
  127. src_install() {
  128. default
  129. newinitd "${FILESDIR}"/chronyd.init-r3 chronyd
  130. newconfd "${T}"/chronyd.conf chronyd
  131. insinto /etc/${PN}
  132. newins examples/chrony.conf.example1 chrony.conf
  133. docinto examples
  134. dodoc examples/*.example*
  135. newtmpfiles - chronyd.conf <<<"d /run/chrony 0750 ntp ntp"
  136. if use html ; then
  137. docinto html
  138. dodoc doc/*.html
  139. fi
  140. keepdir /var/{lib,log}/chrony
  141. fowners ntp:ntp /var/{lib,log}/chrony
  142. fperms 770 /var/lib/chrony
  143. insinto /etc/logrotate.d
  144. newins "${FILESDIR}"/chrony-2.4-r1.logrotate chrony
  145. systemd_dounit examples/chronyd.service
  146. systemd_dounit examples/chrony-wait.service
  147. systemd_enable_ntpunit 50-chrony chronyd.service
  148. }
  149. pkg_preinst() {
  150. HAD_SECCOMP=0
  151. HAD_PRE_NEW_SECCOMP_LEVEL=0
  152. if has_version 'net-misc/chrony[seccomp]' ; then
  153. HAD_SECCOMP=1
  154. fi
  155. if has_version '>=net-misc/chrony-4.1[seccomp]' ; then
  156. # This version introduced a new filter level: -F 2
  157. # It's a limited set of seccomp filters designed to be 'bare minimum'
  158. HAD_PRE_NEW_SECCOMP_LEVEL=1
  159. fi
  160. }
  161. pkg_postinst() {
  162. tmpfiles_process chronyd.conf
  163. # See bug #783915 for general discussion on enabling seccomp filtering
  164. # by default.
  165. local show_seccomp_enable_msg=0
  166. # Was seccomp disabled before and now enabled?
  167. if [[ ${HAD_SECCOMP} -eq 0 ]] && use seccomp ; then
  168. show_seccomp_enable_msg=1
  169. fi
  170. # Are we coming from an old version without the new 'minimal' filter?
  171. # (-F 2)
  172. if [[ ${HAD_PRE_NEW_SECCOMP_LEVEL} -eq 0 ]] ; then
  173. show_seccomp_enable_msg=1
  174. fi
  175. if [[ ${show_seccomp_enable_msg} -eq 1 ]] ; then
  176. elog "To enable seccomp in a stricter mode, please modify:"
  177. elog "- /etc/conf.d/chronyd for OpenRC"
  178. elog "- systemctl edit chronyd for systemd"
  179. elog "to use -F 1 or -F -1 instead of -F 2 (see man chronyd)"
  180. elog "By default, we now use -F 2 which is a baseline/minimal filter."
  181. fi
  182. }