Gentoo Archives: gentoo-commits

From: Hans de Graaff <graaff@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/munin/
Date: Sat, 19 Jun 2021 07:41:35
Message-Id: 1624087979.35bc95be7d9124cf2fb3f4306cc01e0cd7f80e5d.graaff@gentoo
1 commit: 35bc95be7d9124cf2fb3f4306cc01e0cd7f80e5d
2 Author: Hans de Graaff <graaff <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 18 07:16:54 2021 +0000
4 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 19 07:32:59 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=35bc95be
7
8 net-analyzer/munin: avoid /var/cache warning
9
10 Don't keepdir the /var/cache/munin-cgi directory anymore. Files in
11 /var/cache are not guaranteed to exists over time. Drop the creation
12 altogether since this is an option directory that needs to be configured
13 by hand anyway.
14
15 Closes: https://bugs.gentoo.org/795846
16 Package-Manager: Portage-3.0.20, Repoman-3.0.2
17 Signed-off-by: Hans de Graaff <graaff <AT> gentoo.org>
18
19 net-analyzer/munin/munin-2.0.67-r3.ebuild | 414 ++++++++++++++++++++++++++++++
20 1 file changed, 414 insertions(+)
21
22 diff --git a/net-analyzer/munin/munin-2.0.67-r3.ebuild b/net-analyzer/munin/munin-2.0.67-r3.ebuild
23 new file mode 100644
24 index 00000000000..a0ed5615dc5
25 --- /dev/null
26 +++ b/net-analyzer/munin/munin-2.0.67-r3.ebuild
27 @@ -0,0 +1,414 @@
28 +# Copyright 1999-2021 Gentoo Authors
29 +# Distributed under the terms of the GNU General Public License v2
30 +
31 +EAPI=7
32 +
33 +PATCHSET=1
34 +
35 +inherit java-pkg-opt-2 systemd
36 +
37 +MY_P=${P/_/-}
38 +
39 +DESCRIPTION="Munin Server Monitoring Tool"
40 +HOMEPAGE="https://munin-monitoring.org/"
41 +SRC_URI="
42 + https://github.com/munin-monitoring/munin/archive/${PV}.tar.gz -> ${P}.tar.gz
43 + https://dev.gentoo.org/~graaff/munin/${P}-gentoo-${PATCHSET}.tar.xz"
44 +
45 +LICENSE="GPL-2"
46 +SLOT="0"
47 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
48 +IUSE="asterisk irc java ldap memcached minimal mysql postgres selinux ssl test cgi ipv6 syslog ipmi http dhcpd doc apache2"
49 +REQUIRED_USE="cgi? ( !minimal ) apache2? ( cgi )"
50 +RESTRICT="!test? ( test )"
51 +
52 +# Upstream's listing of required modules is NOT correct!
53 +# Some of the postgres plugins use DBD::Pg, while others call psql directly.
54 +# Some of the mysql plugins use DBD::mysql, while others call mysqladmin directly.
55 +# We replace the original ipmi plugins with the freeipmi_ plugin which at least works.
56 +DEPEND_COM="
57 + acct-user/munin
58 + acct-user/munin-async
59 + acct-group/munin
60 + dev-lang/perl:=[berkdb]
61 + dev-perl/DBI
62 + dev-perl/Date-Manip
63 + dev-perl/File-Copy-Recursive
64 + dev-perl/List-MoreUtils
65 + dev-perl/Log-Log4perl
66 + dev-perl/Net-CIDR
67 + dev-perl/Net-DNS
68 + dev-perl/Net-Netmask
69 + dev-perl/Net-SNMP
70 + dev-perl/Net-Server[ipv6(-)?]
71 + virtual/perl-Digest-MD5
72 + virtual/perl-Getopt-Long
73 + virtual/perl-MIME-Base64
74 + virtual/perl-Storable
75 + virtual/perl-Text-Balanced
76 + virtual/perl-Time-HiRes
77 + apache2? ( www-servers/apache[apache2_modules_cgi,apache2_modules_cgid,apache2_modules_rewrite] )
78 + asterisk? ( dev-perl/Net-Telnet )
79 + cgi? (
80 + dev-perl/FCGI
81 + dev-perl/CGI-Fast
82 + )
83 + dhcpd? (
84 + >=net-misc/dhcp-3[server]
85 + dev-perl/Net-IP
86 + dev-perl/HTTP-Date
87 + )
88 + doc? ( dev-python/sphinx )
89 + http? ( dev-perl/libwww-perl )
90 + irc? ( dev-perl/Net-IRC )
91 + ldap? ( dev-perl/perl-ldap )
92 + kernel_linux? ( sys-process/procps )
93 + memcached? ( dev-perl/Cache-Memcached )
94 + mysql? (
95 + virtual/mysql
96 + dev-perl/Cache-Cache
97 + dev-perl/DBD-mysql
98 + )
99 + postgres? ( dev-perl/DBD-Pg dev-db/postgresql:* )
100 + ssl? ( dev-perl/Net-SSLeay )
101 + syslog? ( virtual/perl-Sys-Syslog )
102 + !minimal? (
103 + dev-perl/HTML-Template
104 + dev-perl/IO-Socket-INET6
105 + dev-perl/URI
106 + >=net-analyzer/rrdtool-1.3[graph,perl]
107 + virtual/ssh
108 + )
109 + "
110 +
111 +# Keep this seperate, as previous versions have had other deps here
112 +DEPEND="${DEPEND_COM}
113 + dev-perl/Module-Build
114 + java? ( >=virtual/jdk-1.8 )
115 + test? (
116 + dev-perl/Test-Deep
117 + dev-perl/Test-Exception
118 + dev-perl/Test-LongString
119 + dev-perl/Test-Differences
120 + dev-perl/Test-MockModule
121 + dev-perl/Test-MockObject
122 + dev-perl/File-Slurp
123 + dev-perl/IO-stringy
124 + dev-perl/IO-Socket-INET6
125 + )"
126 +RDEPEND="${DEPEND_COM}
127 + virtual/awk
128 + ipmi? ( >=sys-libs/freeipmi-1.1.6-r1 )
129 + java? (
130 + >=virtual/jre-1.8:*
131 + || ( net-analyzer/netcat net-analyzer/openbsd-netcat )
132 + )
133 + !minimal? (
134 + virtual/cron
135 + media-fonts/dejavu
136 + )
137 + selinux? ( sec-policy/selinux-munin )"
138 +
139 +S="${WORKDIR}/${MY_P}"
140 +
141 +pkg_setup() {
142 + java-pkg-opt-2_pkg_setup
143 +}
144 +
145 +src_prepare() {
146 + echo ${PV} > RELEASE || die
147 +
148 + eapply "${WORKDIR}"/patches/*.patch
149 +
150 + eapply_user
151 +
152 + java-pkg-opt-2_src_prepare
153 +}
154 +
155 +src_configure() {
156 + local cgidir='$(DESTDIR)/usr/libexec/munin/cgi'
157 + use cgi || cgidir="${T}/useless/cgi-bin"
158 +
159 + local cgiuser=$(usex apache2 apache munin)
160 +
161 + cat >> "${S}"/Makefile.config <<- EOF
162 + PREFIX=\$(DESTDIR)/usr
163 + CONFDIR=\$(DESTDIR)/etc/munin
164 + DOCDIR=${T}/useless/doc
165 + MANDIR=\$(PREFIX)/share/man
166 + LIBDIR=\$(PREFIX)/libexec/munin
167 + HTMLDIR=\$(DESTDIR)/var/www/localhost/htdocs/munin
168 + CGIDIR=${cgidir}
169 + CGITMPDIR=\$(DESTDIR)/var/cache/munin-cgi
170 + CGIUSER=${cgiuser}
171 + DBDIR=\$(DESTDIR)/var/lib/munin
172 + DBDIRNODE=\$(DESTDIR)/var/lib/munin-node
173 + SPOOLDIR=\$(DESTDIR)/var/spool/munin-async
174 + LOGDIR=\$(DESTDIR)/var/log/munin
175 + PERLLIB=\$(DESTDIR)$(perl -V:vendorlib | cut -d"'" -f2)
176 + JCVALID=$(usex java yes no)
177 + STATEDIR=\$(DESTDIR)/run/munin
178 + EOF
179 +}
180 +
181 +# parallel make and install need to be fixed before, and I haven't
182 +# gotten around to do so yet.
183 +src_compile() {
184 + emake -j1
185 + use doc && emake -C doc html
186 +}
187 +
188 +src_test() {
189 + if [[ ${EUID} == 0 ]]; then
190 + eerror "You cannot run tests as root."
191 + eerror "Please enable FEATURES=userpriv before proceeding."
192 + return 1
193 + fi
194 +
195 + local testtargets="test-common test-node test-plugins"
196 + use minimal || testtargets+=" test-master"
197 +
198 + LC_ALL=C emake -j1 ${testtargets}
199 +}
200 +
201 +src_install() {
202 + local dirs="
203 + /var/log/munin
204 + /var/lib/munin/plugin-state
205 + /var/lib/munin-node/plugin-state
206 + /var/www/localhost/htdocs/munin
207 + /etc/munin/plugin-conf.d
208 + /etc/munin/plugins"
209 + use minimal || dirs+=" /etc/munin/munin-conf.d/"
210 +
211 + keepdir ${dirs}
212 + fowners munin:munin ${dirs}
213 +
214 + # parallel install doesn't work and it's also pointless to have this
215 + # run in parallel for now (because it uses internal loops).
216 + emake -j1 CHOWN=true DESTDIR="${D}" $(usex minimal "install-minimal install-man" install)
217 +
218 + # we remove /run from the install, as it's not the package's to deal
219 + # with.
220 + rm -rf "${D}"/run || die
221 +
222 + # remove the plugins for non-Gentoo package managers; use -f so that
223 + # it doesn't fail when installing on non-Linux platforms.
224 + rm -f "${D}"/usr/libexec/munin/plugins/{apt{,_all},yum} || die
225 +
226 + insinto /etc/munin/plugin-conf.d/
227 + newins "${FILESDIR}"/${PN}-1.3.2-plugins.conf munin-node
228 +
229 + newinitd "${FILESDIR}"/munin-node_init.d_2.0.19 munin-node
230 + newconfd "${FILESDIR}"/munin-node_conf.d_1.4.6-r2 munin-node
231 +
232 + newinitd "${FILESDIR}"/munin-asyncd.init.2 munin-asyncd
233 +
234 + dodir /usr/lib/tmpfiles.d
235 + cat > "${D}"/usr/lib/tmpfiles.d/${CATEGORY}:${PN}:${SLOT}.conf <<- EOF
236 + d /run/munin 0700 munin munin - -
237 + EOF
238 +
239 + systemd_dounit "${FILESDIR}"/munin-async.service
240 + systemd_dounit "${FILESDIR}"/munin-graph.{service,socket}
241 + systemd_dounit "${FILESDIR}"/munin-html.{service,socket}
242 + systemd_dounit "${FILESDIR}"/munin-node.service
243 +
244 + cat >> "${T}"/munin.env <<- EOF
245 + CONFIG_PROTECT=/var/spool/munin-async/.ssh
246 + EOF
247 + newenvd "${T}"/munin.env 50munin
248 +
249 + dodoc README ChangeLog INSTALL
250 + if use doc; then
251 + cd "${S}"/doc/_build/html || die
252 + docinto html
253 + dodoc -r *
254 + cd "${S}" || die
255 + fi
256 +
257 + dodir /etc/logrotate.d/
258 + sed -e "s:@CGIUSER@:$(usex apache2 apache munin):g" \
259 + "${FILESDIR}"/logrotate.d-munin.3 > "${D}"/etc/logrotate.d/munin
260 +
261 + dosym ipmi_ /usr/libexec/munin/plugins/ipmi_sensor_
262 +
263 + if use syslog; then
264 + sed -i -e '/log_file/s| .*| Sys::Syslog|' \
265 + "${D}"/etc/munin/munin-node.conf || die
266 + fi
267 +
268 + # Use a simpler pid file to avoid trouble with /run in tmpfs. The
269 + # munin-node service is ran as user root, and only later drops
270 + # privileges.
271 + sed -i -e 's:/run/munin/munin-node.pid:/run/munin-node.pid:' \
272 + "${D}"/etc/munin/munin-node.conf || die
273 +
274 + keepdir /var/spool/munin-async/.ssh
275 + touch "${D}"/var/spool/munin-async/.ssh/authorized_keys
276 + fowners munin-async:munin /var/spool/munin-async{,/.ssh/{,authorized_keys}}
277 + fperms 0750 /var/spool/munin-async{,/.ssh}
278 + fperms 0600 /var/spool/munin-async/.ssh/authorized_keys
279 +
280 + if use minimal; then
281 + # This requires the presence of munin-update, which is part of
282 + # the non-minimal install...
283 + rm "${D}"/usr/libexec/munin/plugins/munin_stats
284 + else
285 + # remove font files so that we don't have to keep them around
286 + rm "${D}"/usr/libexec/${PN}/*.ttf || die
287 +
288 + if use cgi; then
289 + sed -i -e '/#graph_strategy cgi/s:^#::' "${D}"/etc/munin/munin.conf || die
290 +
291 + touch "${D}"/var/log/munin/munin-cgi-{graph,html}.log
292 + fowners $(usex apache2 apache munin) \
293 + /var/log/munin/munin-cgi-{graph,html}.log
294 +
295 + if use apache2; then
296 + insinto /etc/apache2/vhosts.d
297 + newins "${FILESDIR}"/munin.apache.include munin.include
298 + newins "${FILESDIR}"/munin.apache.include-2.4 munin-2.4.include
299 + fi
300 + else
301 + sed \
302 + -e '/#graph_strategy cgi/s:#graph_strategy cgi:graph_strategy cron:' \
303 + -i "${D}"/etc/munin/munin.conf || die
304 + fi
305 +
306 + keepdir /var/lib/munin/.ssh
307 + cat >> "${D}"/var/lib/munin/.ssh/config <<- EOF
308 + IdentityFile /var/lib/munin/.ssh/id_ecdsa
309 + IdentityFile /var/lib/munin/.ssh/id_rsa
310 + EOF
311 +
312 + fowners munin:munin /var/lib/munin/.ssh/{,config}
313 + fperms go-rwx /var/lib/munin/.ssh/{,config}
314 +
315 + dodir /usr/share/${PN}
316 + cat >> "${D}"/usr/share/${PN}/crontab <<- EOF
317 + # Force the shell to bash
318 + SHELL=/bin/bash
319 + # Mail reports to root@, not munin@
320 + MAILTO=root
321 +
322 + # This runs the munin task every 5 minutes.
323 + */5 * * * * /usr/bin/munin-cron
324 +
325 + # Alternatively, this route works differently
326 + # Update once a minute (for busy sites)
327 + #*/1 * * * * /usr/libexec/munin/munin-update
328 + ## Check for limit excess every 2 minutes
329 + #*/2 * * * * /usr/libexec/munin/munin-limits
330 + ## Update graphs every 5 minutes
331 + #*/5 * * * * nice /usr/libexec/munin/munin-graph
332 + ## Update HTML pages every 15 minutes
333 + #*/15 * * * * nice /usr/libexec/munin/munin-html
334 + EOF
335 +
336 + cat >> "${D}"/usr/share/${PN}/fcrontab <<- EOF
337 + # Mail reports to root@, not munin@, only execute one at a time
338 + !mailto(root),serial(true)
339 +
340 + # This runs the munin task every 5 minutes.
341 + @ 5 /usr/bin/munin-cron
342 +
343 + # Alternatively, this route works differently
344 + # Update once a minute (for busy sites)
345 + #@ 1 /usr/libexec/munin/munin-update
346 + ## Check for limit excess every 2 minutes
347 + #@ 2 /usr/libexec/munin/munin-limits
348 + ## Update graphs every 5 minutes
349 + #@ 5 nice /usr/libexec/munin/munin-graph
350 + ## Update HTML pages every 15 minutes
351 + #@ 15 nice /usr/libexec/munin/munin-html
352 + EOF
353 +
354 + # remove .htaccess file
355 + find "${D}" -name .htaccess -delete || die
356 + fi
357 +}
358 +
359 +pkg_config() {
360 + if use minimal; then
361 + einfo "Nothing to do."
362 + return 0
363 + fi
364 +
365 + einfo "Press enter to install the default crontab for the munin master"
366 + einfo "installation from /usr/share/${PN}/f?crontab"
367 + einfo "If you have a large site, you may wish to customize it."
368 + read
369 +
370 + ebegin "Setting up cron ..."
371 + if has_version sys-process/fcron; then
372 + fcrontab - -u munin < /usr/share/${PN}/fcrontab
373 + else
374 + # dcron is very fussy about syntax
375 + # the following is the only form that works in BOTH dcron and vixie-cron
376 + crontab - -u munin < /usr/share/${PN}/crontab
377 + fi
378 + eend $?
379 +
380 + einfo "Press enter to set up the SSH keys used for SSH transport"
381 + read
382 +
383 + # generate one rsa (for legacy) and one ecdsa (for new systems)
384 + ssh-keygen -t rsa \
385 + -f /var/lib/munin/.ssh/id_rsa -N '' \
386 + -C "created by portage for ${CATEGORY}/${PN}" || die
387 + ssh-keygen -t ecdsa \
388 + -f /var/lib/munin/.ssh/id_ecdsa -N '' \
389 + -C "created by portage for ${CATEGORY}/${PN}" || die
390 + chown -R munin:munin /var/lib/munin/.ssh || die
391 + chmod 0600 /var/lib/munin/.ssh/id_{rsa,ecdsa} || die
392 +
393 + einfo "Your public keys are available in "
394 + einfo " /var/lib/munin/.ssh/id_rsa.pub"
395 + einfo " /var/lib/munin/.ssh/id_ecdsa.pub"
396 + einfo "and follows for convenience"
397 + echo
398 + cat /var/lib/munin/.ssh/id_*.pub
399 +}
400 +
401 +pkg_postinst() {
402 + elog "Please follow the munin documentation to set up the plugins you"
403 + elog "need, afterwards start munin-node."
404 + elog ""
405 + elog "To make use of munin-async, make sure to set up the corresponding"
406 + elog "SSH key in /var/lib/munin-async/.ssh/authorized_keys"
407 + elog ""
408 + if ! use minimal; then
409 + elog "Please run"
410 + elog " emerge --config net-analyzer/munin"
411 + elog "to automatically configure munin's cronjobs as well as generate"
412 + elog "passwordless SSH keys to be used with munin-async."
413 + fi
414 + elog ""
415 + elog "Further information about setting up Munin in Gentoo can be found"
416 + elog "in the Gentoo Wiki: https://wiki.gentoo.org/wiki/Munin"
417 +
418 + if use cgi; then
419 + chown $(usex apache2 apache munin) \
420 + "${ROOT}"/var/log/munin/munin-cgi-{graph,html}.log
421 +
422 + if use apache2; then
423 + elog "To use Munin with CGI you should include /etc/apache2/vhosts.d/munin.include"
424 + elog "or /etc/apache2/vhosts.d/munin-2.4.include (for Apache 2.4) from the virtual"
425 + elog "host you want it to be served."
426 + elog "If you want to enable CGI-based HTML as well, you have to add to"
427 + elog "/etc/conf.d/apache2 the option -D MUNIN_HTML_CGI."
428 + else
429 + elog "Effective CGI support has just been added in 2.0.7-r6."
430 + elog "Documentation on how to use it is still sparse."
431 + fi
432 + fi
433 +
434 + # we create this here as we don't want Portage to check /run
435 + # symlinks but we still need this to be present before the reboot.
436 + if ! use minimal && ! [[ -d "${ROOT}"/run/munin ]]; then
437 + mkdir "${ROOT}"/run/munin
438 + chown munin:munin "${ROOT}"/run/munin
439 + chmod 0700 "${ROOT}"/run/munin
440 + fi
441 +}