openntpd-6.0_p1.ebuild 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils systemd user
  5. MY_P="${P/_p/p}"
  6. DESCRIPTION="Lightweight NTP server ported from OpenBSD"
  7. HOMEPAGE="http://www.openntpd.org/"
  8. SRC_URI="mirror://openbsd/OpenNTPD/${MY_P}.tar.gz"
  9. LICENSE="BSD GPL-2"
  10. SLOT="0"
  11. KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~x86-fbsd"
  12. IUSE="libressl selinux"
  13. DEPEND="!<=net-misc/ntp-4.2.0-r2
  14. !net-misc/ntp[-openntpd]
  15. libressl? ( >=dev-libs/libressl-2.3.2 )"
  16. RDEPEND="${DEPEND}
  17. selinux? ( sec-policy/selinux-ntp )"
  18. S="${WORKDIR}/${MY_P}"
  19. pkg_setup() {
  20. export NTP_HOME="${NTP_HOME:=/var/lib/openntpd/chroot}"
  21. enewgroup ntp
  22. enewuser ntp -1 -1 "${NTP_HOME}" ntp
  23. # make sure user has correct HOME as flipping between the standard ntp pkg
  24. # and this one was possible in the past
  25. if [[ $(egethome ntp) != ${NTP_HOME} ]]; then
  26. ewarn "From this version on, the homedir of the ntp user cannot be changed"
  27. ewarn "dynamically after the installation. For homedir different from"
  28. ewarn "/var/lib/openntpd/chroot set NTP_HOME in your make.conf and re-emerge."
  29. esethome ntp "${NTP_HOME}"
  30. fi
  31. }
  32. src_prepare() {
  33. # fix /run path
  34. sed -i 's:/var/run/ntpd:/run/ntpd:g' src/ntpctl.8 src/ntpd.8 || die
  35. sed -i 's:LOCALSTATEDIR "/run/ntpd:"/run/ntpd:' src/ntpd.h || die
  36. # fix ntpd.drift path
  37. sed -i 's:/var/db/ntpd.drift:/var/lib/openntpd/ntpd.drift:g' src/ntpd.8 || die
  38. sed -i 's:"/db/ntpd.drift":"/openntpd/ntpd.drift":' src/ntpd.h || die
  39. # fix default config to use gentoo pool
  40. sed -i 's:servers pool.ntp.org:#servers pool.ntp.org:' ntpd.conf || die
  41. printf "\n# Choose servers announced from Gentoo NTP Pool\nservers 0.gentoo.pool.ntp.org\nservers 1.gentoo.pool.ntp.org\nservers 2.gentoo.pool.ntp.org\nservers 3.gentoo.pool.ntp.org\n" >> ntpd.conf || die
  42. }
  43. src_configure() {
  44. econf --with-privsep-user=ntp --with-privsep-path=${NTP_HOME} $(use_enable libressl https-constraint)
  45. }
  46. src_install() {
  47. default
  48. rm -r "${ED}"/var
  49. newinitd "${FILESDIR}/${PN}.init.d-20080406-r6" ntpd
  50. newconfd "${FILESDIR}/${PN}.conf.d-20080406-r6" ntpd
  51. systemd_newunit "${FILESDIR}/${PN}.service-20080406-r4" ntpd.service
  52. }
  53. pkg_postinst() {
  54. # Clean up chroot localtime copy from older versions
  55. if [ -d "${EROOT%/}${NTP_HOME}"/etc ] ; then
  56. if [ -f "${EROOT%/}${NTP_HOME}"/etc/localtime ] ; then
  57. rm -f "${EROOT%/}${NTP_HOME}"/etc/localtime
  58. fi
  59. rmdir "${EROOT%/}${NTP_HOME}"/etc ||
  60. ewarn "Unable to remove legacy ${EROOT%/}${NTP_HOME}/etc directory"
  61. fi
  62. # Fix permissions on home directory
  63. chown root:root "${EROOT%/}${NTP_HOME}" || die
  64. [[ -f ${EROOT}var/log/ntpd.log ]] && \
  65. ewarn "Logfile '${EROOT}var/log/ntpd.log' might be orphaned, please remove it if not in use via syslog."
  66. if [[ -f ${EROOT}var/lib/ntpd.drift ]] ; then
  67. einfo "Moving ntpd.drift file to new location."
  68. mv "${EROOT}var/lib/ntpd.drift" "${EROOT}var/lib/openntpd/ntpd.drift"
  69. fi
  70. }