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