logo

overlay

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

openntpd-6.0_p1.ebuild (2792B)


  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils 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="selinux"
  13. DEPEND="!<=net-misc/ntp-4.2.0-r2
  14. !net-misc/ntp[-openntpd]"
  15. RDEPEND="${DEPEND}
  16. selinux? ( sec-policy/selinux-ntp )"
  17. S="${WORKDIR}/${MY_P}"
  18. pkg_setup() {
  19. export NTP_HOME="${NTP_HOME:=/var/lib/openntpd/chroot}"
  20. enewgroup ntp
  21. enewuser ntp -1 -1 "${NTP_HOME}" ntp
  22. # make sure user has correct HOME as flipping between the standard ntp pkg
  23. # and this one was possible in the past
  24. if [[ $(egethome ntp) != ${NTP_HOME} ]]; then
  25. ewarn "From this version on, the homedir of the ntp user cannot be changed"
  26. ewarn "dynamically after the installation. For homedir different from"
  27. ewarn "/var/lib/openntpd/chroot set NTP_HOME in your make.conf and re-emerge."
  28. esethome ntp "${NTP_HOME}"
  29. fi
  30. }
  31. src_prepare() {
  32. # fix /run path
  33. sed -i 's:/var/run/ntpd:/run/ntpd:g' src/ntpctl.8 src/ntpd.8 || die
  34. sed -i 's:LOCALSTATEDIR "/run/ntpd:"/run/ntpd:' src/ntpd.h || die
  35. # fix ntpd.drift path
  36. sed -i 's:/var/db/ntpd.drift:/var/lib/openntpd/ntpd.drift:g' src/ntpd.8 || die
  37. sed -i 's:"/db/ntpd.drift":"/openntpd/ntpd.drift":' src/ntpd.h || die
  38. # fix default config to use gentoo pool
  39. sed -i 's:servers pool.ntp.org:#servers pool.ntp.org:' ntpd.conf || die
  40. 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
  41. }
  42. src_configure() {
  43. econf --with-privsep-user=ntp --with-privsep-path=${NTP_HOME}
  44. }
  45. src_install() {
  46. default
  47. rm -r "${ED}"/var
  48. newinitd "${FILESDIR}/${PN}.init.d-20080406-r6" ntpd
  49. newconfd "${FILESDIR}/${PN}.conf.d-20080406-r6" ntpd
  50. }
  51. pkg_postinst() {
  52. # Clean up chroot localtime copy from older versions
  53. if [ -d "${EROOT%/}${NTP_HOME}"/etc ] ; then
  54. if [ -f "${EROOT%/}${NTP_HOME}"/etc/localtime ] ; then
  55. rm -f "${EROOT%/}${NTP_HOME}"/etc/localtime
  56. fi
  57. rmdir "${EROOT%/}${NTP_HOME}"/etc ||
  58. ewarn "Unable to remove legacy ${EROOT%/}${NTP_HOME}/etc directory"
  59. fi
  60. # Fix permissions on home directory
  61. chown 0:0 "${EROOT%/}${NTP_HOME}" || die
  62. [[ -f ${EROOT}var/log/ntpd.log ]] && \
  63. ewarn "Logfile '${EROOT}var/log/ntpd.log' might be orphaned, please remove it if not in use via syslog."
  64. if [[ -f ${EROOT}var/lib/ntpd.drift ]] ; then
  65. einfo "Moving ntpd.drift file to new location."
  66. mv "${EROOT}var/lib/ntpd.drift" "${EROOT}var/lib/openntpd/ntpd.drift"
  67. fi
  68. }