icinga2-9999.ebuild 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. if [[ ${PV} != 9999 ]]; then
  5. inherit cmake-utils depend.apache eutils systemd toolchain-funcs user wxwidgets
  6. SRC_URI="https://github.com/Icinga/icinga2/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  7. KEYWORDS="~amd64 ~arm ~arm64 ~x86"
  8. else
  9. inherit cmake-utils depend.apache eutils git-2 systemd toolchain-funcs user wxwidgets
  10. EGIT_REPO_URI="https://github.com/Icinga/icinga2.git"
  11. EGIT_BRANCH="master"
  12. KEYWORDS=""
  13. fi
  14. DESCRIPTION="Distributed, general purpose, network monitoring engine"
  15. HOMEPAGE="http://icinga.org/icinga2"
  16. LICENSE="GPL-2"
  17. SLOT="0"
  18. IUSE="+mysql postgres classicui console libressl lto mail minimal nano-syntax +plugins studio +vim-syntax"
  19. WX_GTK_VER="3.0"
  20. CDEPEND="
  21. !libressl? ( dev-libs/openssl:0= )
  22. libressl? ( dev-libs/libressl:0= )
  23. >=dev-libs/boost-1.41
  24. console? ( dev-libs/libedit )
  25. mysql? ( virtual/mysql )
  26. postgres? ( dev-db/postgresql:= )"
  27. DEPEND="
  28. ${CDEPEND}
  29. sys-devel/bison
  30. >=sys-devel/flex-2.5.35"
  31. RDEPEND="
  32. ${CDEPEND}
  33. plugins? ( || (
  34. net-analyzer/monitoring-plugins
  35. net-analyzer/nagios-plugins
  36. ) )
  37. mail? ( virtual/mailx )
  38. classicui? ( net-analyzer/icinga[web] )
  39. studio? ( x11-libs/wxGTK:3.0 )"
  40. REQUIRED_USE="!minimal? ( || ( mysql postgres ) )"
  41. want_apache2
  42. pkg_setup() {
  43. depend.apache_pkg_setup
  44. if use studio ; then
  45. setup-wxwidgets
  46. fi
  47. enewgroup icinga
  48. enewgroup icingacmd
  49. enewgroup nagios # for plugins
  50. enewuser icinga -1 -1 /var/lib/icinga2 "icinga,icingacmd,nagios"
  51. }
  52. src_configure() {
  53. sed -i 's/FLAGS\}\ \-g/FLAGS\}\ \-lpthread\ /g' CMakeLists.txt || die
  54. local mycmakeargs=(
  55. -DICINGA2_UNITY_BUILD=FALSE
  56. -DCMAKE_VERBOSE_MAKEFILE=ON
  57. -DCMAKE_BUILD_TYPE=None
  58. -DCMAKE_INSTALL_PREFIX=/usr
  59. -DCMAKE_INSTALL_SYSCONFDIR=/etc
  60. -DCMAKE_INSTALL_LOCALSTATEDIR=/var
  61. -DICINGA2_SYSCONFIGFILE=/etc/conf.d/icinga2
  62. -DICINGA2_USER=icinga
  63. -DICINGA2_GROUP=icingacmd
  64. -DICINGA2_COMMAND_USER=icinga
  65. -DICINGA2_COMMAND_GROUP=icingacmd
  66. -DINSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=yes
  67. -DLOGROTATE_HAS_SU=ON
  68. )
  69. # default to off if minimal, allow the flags to be set otherwise
  70. if use minimal; then
  71. mycmakeargs+=(
  72. -DICINGA2_WITH_MYSQL=OFF
  73. -DICINGA2_WITH_PGSQL=OFF
  74. )
  75. else
  76. mycmakeargs+=(
  77. -DICINGA2_WITH_PGSQL=$(usex postgres ON OFF)
  78. -DICINGA2_WITH_MYSQL=$(usex mysql ON OFF)
  79. )
  80. fi
  81. # LTO
  82. if use lto; then
  83. mycmakeargs+=(
  84. -DICINGA2_LTO_BUILD=ON
  85. )
  86. else
  87. mycmakeargs+=(
  88. -DICINGA2_LTO_BUILD=OFF
  89. )
  90. fi
  91. # STUDIO
  92. if use studio; then
  93. mycmakeargs+=(
  94. -DICINGA2_WITH_STUDIO=ON
  95. )
  96. else
  97. mycmakeargs+=(
  98. -DICINGA2_WITH_STUDIO=OFF
  99. )
  100. fi
  101. cmake-utils_src_configure
  102. }
  103. src_install() {
  104. BUILDDIR="${WORKDIR}"/icinga2-${PV}_build
  105. cd "${BUILDDIR}" || die
  106. emake DESTDIR="${D}" install
  107. einstalldocs
  108. newinitd "${FILESDIR}"/icinga2.initd icinga2
  109. newconfd "${FILESDIR}"/icinga2.confd icinga2
  110. if use mysql ; then
  111. docinto schema
  112. newdoc "${WORKDIR}"/icinga2-${PV}/lib/db_ido_mysql/schema/mysql.sql mysql.sql
  113. docinto schema/upgrade
  114. dodoc "${WORKDIR}"/icinga2-${PV}/lib/db_ido_mysql/schema/upgrade/*
  115. elif use postgres ; then
  116. docinto schema
  117. newdoc "${WORKDIR}"/icinga2-${PV}/lib/db_ido_pgsql/schema/pgsql.sql pgsql.sql
  118. docinto schema/upgrade
  119. dodoc "${WORKDIR}"/icinga2-${PV}/lib/db_ido_pgsql/schema/upgrade/*
  120. fi
  121. keepdir /etc/icinga2
  122. keepdir /var/lib/icinga2/api/zones
  123. keepdir /var/lib/icinga2/api/repository
  124. keepdir /var/lib/icinga2/api/log
  125. keepdir /var/spool/icinga2/perfdata
  126. rm -r "${D}/var/run" || die "failed to remove /var/run"
  127. rm -r "${D}/var/cache" || die "failed to remove /var/cache"
  128. fowners icinga:icinga /etc/icinga2
  129. fowners icinga:icinga /var/lib/icinga2
  130. fowners icinga:icinga /var/spool/icinga2
  131. fowners -R icinga:icingacmd /var/lib/icinga2/api
  132. fowners icinga:icinga /var/spool/icinga2/perfdata
  133. fowners icinga:icingacmd /var/log/icinga2
  134. fperms ug+rwX,o-rwx /etc/icinga2
  135. fperms ug+rwX,o-rwx /var/lib/icinga2
  136. fperms ug+rwX,o-rwx /var/spool/icinga2
  137. fperms ug+rwX,o-rwx /var/log/icinga2
  138. if use vim-syntax; then
  139. insinto /usr/share/vim/vimfiles
  140. doins -r "${WORKDIR}"/${P}/tools/syntax/vim/ftdetect
  141. doins -r "${WORKDIR}"/${P}/tools/syntax/vim/syntax
  142. fi
  143. if use nano-syntax; then
  144. insinto /usr/share/nano
  145. doins "${WORKDIR}"/${P}/tools/syntax/nano/icinga2.nanorc
  146. fi
  147. }
  148. pkg_postinst() {
  149. if [[ ${PV} != 9999 && -n ${REPLACING_VERSIONS} && ${REPLACING_VERSIONS} != ${PV} ]]; then
  150. elog "DB IDO schema upgrade may be required required.
  151. http://docs.icinga.org/icinga2/snapshot/doc/module/icinga2/chapter/upgrading-icinga-2"
  152. fi
  153. }