Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/nagios-core/, net-analyzer/nagios-core/files/
Date: Tue, 05 Nov 2019 17:44:41
Message-Id: 1572975799.1d689dbb5a8783f717d85f10344bf24991e557e1.mjo@gentoo
1 commit: 1d689dbb5a8783f717d85f10344bf24991e557e1
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Sun Nov 3 00:26:57 2019 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 5 17:43:19 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d689dbb
7
8 net-analyzer/nagios-core: synchronize econf and web server paths.
9
10 The nagios ./configure script takes two custom "cgibindir" and
11 "webdir" paths that tell it where to put its CGI files and public
12 document root. The web server configuration files that we ship also
13 need to know these paths, which normally wouldn't be a problem, except
14 that they involve a call to $(get_libdir).
15
16 There doesn't seem to be an elegant place to upstream these conf files
17 (which are Gentoo-specific), so we adopt the next-best solution: use
18 @CGIBINDIR@ and @WEBDIR@ as placeholders, and then replace them with
19 sed in src_configure().
20
21 For consistency with the PMS definition of econf, these paths (and all
22 others) now have EPREFIX prepended.
23
24 Closes: https://bugs.gentoo.org/699002
25 Package-Manager: Portage-2.3.76, Repoman-2.3.16
26 Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
27
28 net-analyzer/nagios-core/files/99_nagios4-r1.conf | 16 ++
29 .../nagios-core/files/lighttpd_nagios4-r1.conf | 15 ++
30 .../nagios-core/nagios-core-4.4.5-r4.ebuild | 245 +++++++++++++++++++++
31 3 files changed, 276 insertions(+)
32
33 diff --git a/net-analyzer/nagios-core/files/99_nagios4-r1.conf b/net-analyzer/nagios-core/files/99_nagios4-r1.conf
34 new file mode 100644
35 index 00000000000..54531ed6275
36 --- /dev/null
37 +++ b/net-analyzer/nagios-core/files/99_nagios4-r1.conf
38 @@ -0,0 +1,16 @@
39 +<IfDefine NAGIOS>
40 +
41 + ScriptAlias /nagios/cgi-bin/ @CGIBINDIR@
42 + <Directory "@CGIBINDIR@">
43 + AllowOverride AuthConfig
44 + Options ExecCGI
45 + Require all granted
46 + </Directory>
47 +
48 + Alias /nagios @WEBDIR@
49 + <Directory "@WEBDIR@">
50 + AllowOverride AuthConfig
51 + Require all granted
52 + </Directory>
53 +
54 +</IfDefine>
55
56 diff --git a/net-analyzer/nagios-core/files/lighttpd_nagios4-r1.conf b/net-analyzer/nagios-core/files/lighttpd_nagios4-r1.conf
57 new file mode 100644
58 index 00000000000..2653922ddc9
59 --- /dev/null
60 +++ b/net-analyzer/nagios-core/files/lighttpd_nagios4-r1.conf
61 @@ -0,0 +1,15 @@
62 +server.modules += ("mod_cgi")
63 +server.modules += ("mod_alias")
64 +
65 +$HTTP["url"] =~ "^/nagios/cgi-bin/" {
66 + dir-listing.activate = "disable"
67 + cgi.assign = (
68 + ".pl" => "/usr/bin/perl",
69 + ".cgi" => ""
70 + )
71 +}
72 +
73 +alias.url += (
74 + "/nagios/cgi-bin" => "@CGIBINDIR@",
75 + "/nagios" => "@WEBDIR@"
76 +)
77
78 diff --git a/net-analyzer/nagios-core/nagios-core-4.4.5-r4.ebuild b/net-analyzer/nagios-core/nagios-core-4.4.5-r4.ebuild
79 new file mode 100644
80 index 00000000000..4a5ffee95d4
81 --- /dev/null
82 +++ b/net-analyzer/nagios-core/nagios-core-4.4.5-r4.ebuild
83 @@ -0,0 +1,245 @@
84 +# Copyright 1999-2019 Gentoo Authors
85 +# Distributed under the terms of the GNU General Public License v2
86 +
87 +EAPI=6
88 +
89 +inherit toolchain-funcs user
90 +
91 +MY_P=${PN/-core}-${PV}
92 +DESCRIPTION="Nagios core - monitoring daemon, web GUI, and documentation"
93 +HOMEPAGE="https://www.nagios.org/"
94 +
95 +# The name of the directory into which our Gentoo icons will be
96 +# extracted, and also the basename of the archive containing it.
97 +GENTOO_ICONS="${PN}-gentoo-icons-20141125"
98 +SRC_URI="mirror://sourceforge/nagios/${MY_P}.tar.gz
99 + web? ( https://dev.gentoo.org/~mjo/distfiles/${GENTOO_ICONS}.tar )"
100 +
101 +LICENSE="GPL-2"
102 +SLOT="0"
103 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~sparc ~x86"
104 +IUSE="apache2 classicui lighttpd perl +web vim-syntax"
105 +
106 +# In pkg_postinst(), we change the group of the Nagios configuration
107 +# directory to that of the web server user. It can't belong to both
108 +# apache/lighttpd groups at the same time, so we block this combination
109 +# for our own sanity.
110 +#
111 +# This could be made to work, but we would need a better way to allow
112 +# the web user read-only access to Nagios's configuration directory.
113 +#
114 +REQUIRED_USE="apache2? ( !lighttpd )"
115 +
116 +#
117 +# Note, we require one of the apache2 CGI modules:
118 +#
119 +# * mod_cgi
120 +# * mod_cgid
121 +# * mod_fcgid
122 +#
123 +# We just don't care /which/ one. And of course PHP supports both CGI
124 +# (USE=cgi) and FastCGI (USE=fpm). We're pretty lenient with the
125 +# dependencies, and expect the user not to do anything /too/
126 +# stupid. (For example, installing Apache with only FastCGI support, and
127 +# PHP with only CGI support.)
128 +#
129 +# Another annoyance is that the upstream Makefile uses app-arch/unzip to
130 +# extract a snapshot of AngularJS, but that's only needed when USE=web.
131 +#
132 +MOD_ALIAS=apache2_modules_alias
133 +DEPEND="dev-libs/libltdl:0
134 + virtual/mailx
135 + perl? ( dev-lang/perl:= )
136 + web? (
137 + app-arch/unzip
138 + media-libs/gd[jpeg,png]
139 + lighttpd? ( www-servers/lighttpd[php] )
140 + apache2? (
141 + || (
142 + >=www-servers/apache-2.4[${MOD_ALIAS},apache2_modules_cgi]
143 + >=www-servers/apache-2.4[${MOD_ALIAS},apache2_modules_cgid]
144 + >=www-servers/apache-2.4[${MOD_ALIAS},apache2_modules_fcgid] )
145 + || (
146 + dev-lang/php:*[apache2]
147 + dev-lang/php:*[cgi]
148 + dev-lang/php:*[fpm] )
149 + )
150 + )"
151 +RDEPEND="${DEPEND}
152 + vim-syntax? ( app-vim/nagios-syntax )"
153 +
154 +S="${WORKDIR}/${MY_P}"
155 +
156 +pkg_setup() {
157 + enewgroup nagios
158 + enewuser nagios -1 -1 -1 nagios
159 +}
160 +
161 +src_configure() {
162 + local myconf
163 +
164 + if use perl; then
165 + myconf="${myconf} --enable-embedded-perl --with-perlcache"
166 + fi
167 +
168 + if use !apache2 && use !lighttpd ; then
169 + myconf="${myconf} --with-command-group=nagios"
170 + else
171 + if use apache2 ; then
172 + myconf="${myconf} --with-command-group=apache"
173 + myconf="${myconf} --with-httpd-conf=/etc/apache2/conf.d"
174 + elif use lighttpd ; then
175 + myconf="${myconf} --with-command-group=lighttpd"
176 + fi
177 + fi
178 +
179 + econf ${myconf} \
180 + --prefix="${EPREFIX}/usr" \
181 + --bindir="${EPREFIX}/usr/sbin" \
182 + --localstatedir="${EPREFIX}/var/lib/nagios" \
183 + --sysconfdir="${EPREFIX}/etc/nagios" \
184 + --libexecdir="${EPREFIX}/usr/$(get_libdir)/nagios/plugins" \
185 + --with-cgibindir="${EPREFIX}/usr/$(get_libdir)/nagios/cgi-bin" \
186 + --with-webdir="${EPREFIX}/usr/share/nagios/htdocs"
187 +
188 + # The paths in the web server configuration files need to match
189 + # those passed to econf above.
190 + cp "${FILESDIR}/99_nagios4-r1.conf" \
191 + "${FILESDIR}/lighttpd_nagios4-r1.conf" \
192 + "${T}/" || die "failed to create copies of web server conf files"
193 +
194 + sed -e "s|@CGIBINDIR@|${EPREFIX}/usr/$(get_libdir)/nagios/cgi-bin|g" \
195 + -e "s|@WEBDIR@|${EPREFIX}/usr/share/nagios/htdocs|" \
196 + -i "${T}/99_nagios4-r1.conf" \
197 + -i "${T}/lighttpd_nagios4-r1.conf" \
198 + || die "failed to substitute paths into web server conf files"
199 +
200 +}
201 +
202 +src_compile() {
203 + emake CC=$(tc-getCC) nagios
204 +
205 + if use web; then
206 + # Only compile the CGIs/HTML when USE=web is set.
207 + emake CC=$(tc-getCC) DESTDIR="${D}" cgis html
208 + fi
209 +}
210 +
211 +src_install() {
212 + dodoc Changelog CONTRIBUTING.md README.md THANKS UPGRADING
213 +
214 + # There is no way to install the CGIs unstripped from the top-level
215 + # makefile, so descend into base/ here. The empty INSTALL_OPTS
216 + # ensures that root:root: owns the nagios executables.
217 + cd "${S}/base" || die
218 + emake INSTALL_OPTS="" DESTDIR="${D}" install-unstripped
219 + cd "${S}" || die
220 +
221 + # Otherwise this gets installed as 770 and you get "access denied"
222 + # for some reason or other when starting nagios. The permissions
223 + # on nagiostats are just for consistency (these should both get
224 + # fixed upstream).
225 + fperms 775 /usr/sbin/nagios /usr/sbin/nagiostats
226 +
227 + # INSTALL_OPTS are needed for most of install-basic, but we don't
228 + # want them on the LIBEXECDIR, argh.
229 + emake DESTDIR="${D}" install-basic
230 + fowners root:root /usr/$(get_libdir)/nagios/plugins
231 +
232 + # Don't make the configuration owned by the nagios user, because
233 + # then he can edit nagios.cfg and trick nagios into running as root
234 + # and doing his bidding.
235 + emake INSTALL_OPTS="" DESTDIR="${D}" install-config
236 +
237 + # No INSTALL_OPTS used in install-commandmode, thankfully.
238 + emake DESTDIR="${D}" install-commandmode
239 +
240 + # The build system installs these directories, but portage assumes
241 + # that the build system doesn't know what it's doing so we have to
242 + # keepdir them, too. I guess you'll have to manually re-check the
243 + # upstream build system forever to see if this is still necessary.
244 + keepdir /var/lib/nagios{,/archives,/rw,/spool,/spool/checkresults}
245 +
246 + if use web; then
247 + # There is no way to install the CGIs unstripped from the
248 + # top-level makefile, so descend into cgi/ here. The empty
249 + # INSTALL_OPTS ensures that root:root: owns the CGI executables.
250 + cd "${S}/cgi" || die
251 + emake INSTALL_OPTS="" DESTDIR="${D}" install-unstripped
252 + cd "${S}" || die
253 +
254 + # install-html installs the new exfoliation theme
255 + emake INSTALL_OPTS="" DESTDIR="${D}" install-html
256 +
257 + if use classicui; then
258 + # This overwrites the already-installed exfoliation theme
259 + emake INSTALL_OPTS="" DESTDIR="${D}" install-classicui
260 + fi
261 +
262 + # Install cute Gentoo icons (bug #388323), setting their
263 + # owner, group, and mode to match those of the rest of Nagios's
264 + # images.
265 + insinto /usr/share/nagios/htdocs/images/logos
266 + doins "${WORKDIR}/${GENTOO_ICONS}"/*.*
267 + fi
268 +
269 + newinitd startup/openrc-init nagios
270 +
271 + if use web ; then
272 + if use apache2 ; then
273 + # Install the Nagios configuration file for Apache.
274 + insinto "/etc/apache2/modules.d"
275 + doins "${T}/99_nagios4-r1.conf"
276 + elif use lighttpd ; then
277 + # Install the Nagios configuration file for Lighttpd.
278 + insinto /etc/lighttpd
279 + newins "${T}/lighttpd_nagios4-r1.conf" nagios.conf
280 + else
281 + ewarn "${CATEGORY}/${PF} only supports apache or lighttpd"
282 + ewarn "out of the box. Since you are not using one of them, you"
283 + ewarn "will have to configure your webserver yourself."
284 + fi
285 + fi
286 +}
287 +
288 +pkg_postinst() {
289 +
290 + if use web; then
291 + if use apache2 || use lighttpd ; then
292 + if use apache2; then
293 + elog "To enable the Nagios web front-end, please edit"
294 + elog "${ROOT}etc/conf.d/apache2 and add \"-D NAGIOS -D PHP\""
295 + elog "to APACHE2_OPTS. Then Nagios will be available at,"
296 + elog
297 + elif use lighttpd; then
298 + elog "To enable the Nagios web front-end, please add"
299 + elog "'include \"nagios.conf\"' to the lighttpd configuration"
300 + elog "file at ${ROOT}etc/lighttpd/lighttpd.conf. Then Nagios"
301 + elog "will be available at,"
302 + elog
303 + fi
304 +
305 + elog " http://localhost/nagios/"
306 + fi
307 + fi
308 +
309 + elog
310 + elog "If your kernel has /proc protection, nagios"
311 + elog "will not be happy as it relies on accessing the proc"
312 + elog "filesystem. You can fix this by adding nagios into"
313 + elog "the group wheel, but this is not recomended."
314 + elog
315 +
316 + if [ -n "${REPLACING_VERSIONS}" ]; then
317 + ewarn "The local state directory for nagios has changed in v4.4.5,"
318 + ewarn "from ${EROOT}var/nagios to ${EROOT}var/lib/nagios. If you"
319 + ewarn "wish to migrate your state to the new location, first stop"
320 + ewarn "nagios and then run"
321 + ewarn ""
322 + ewarn " diff --recursive --brief ${EROOT}var/nagios ${EROOT}var/lib/nagios"
323 + ewarn ""
324 + ewarn "to identify any files that should be moved to the new"
325 + ewarn "location. They can simply be moved with \"mv\" before"
326 + ewarn "restarting nagios."
327 + fi
328 +}