Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-metrics/collectd/
Date: Fri, 05 Feb 2021 18:09:32
Message-Id: 1612548553.2f41c6647286fb4c39a56753b255cc7ce802bb52.whissi@gentoo
1 commit: 2f41c6647286fb4c39a56753b255cc7ce802bb52
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Fri Feb 5 17:04:17 2021 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Fri Feb 5 18:09:13 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2f41c664
7
8 app-metrics/collectd: rev bump
9
10 - Migrate to EAPI 7.
11
12 - Migrate to LUA eclass. [Bug 752558]
13
14 - Migrate to acct-* eclass. [Bug 701254]
15
16 - Install UDEV rule when USE=collectd_plugins_disk with USE=udev.
17 [Bug 763090]
18
19 Bug: https://bugs.gentoo.org/701254
20 Closes: https://bugs.gentoo.org/752558
21 Closes: https://bugs.gentoo.org/763090
22 Package-Manager: Portage-3.0.14, Repoman-3.0.2
23 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
24
25 app-metrics/collectd/collectd-5.12.0-r1.ebuild | 568 +++++++++++++++++++++++++
26 1 file changed, 568 insertions(+)
27
28 diff --git a/app-metrics/collectd/collectd-5.12.0-r1.ebuild b/app-metrics/collectd/collectd-5.12.0-r1.ebuild
29 new file mode 100644
30 index 00000000000..d405d80f4cd
31 --- /dev/null
32 +++ b/app-metrics/collectd/collectd-5.12.0-r1.ebuild
33 @@ -0,0 +1,568 @@
34 +# Copyright 1999-2021 Gentoo Authors
35 +# Distributed under the terms of the GNU General Public License v2
36 +
37 +EAPI="7"
38 +
39 +JAVA_PKG_OPT_USE="collectd_plugins_java"
40 +LUA_COMPAT=( lua5-{1..3} )
41 +PYTHON_COMPAT=( python3_{7..9} )
42 +
43 +inherit autotools fcaps flag-o-matic java-pkg-opt-2 linux-info lua-single \
44 + multilib perl-functions python-single-r1 systemd tmpfiles udev
45 +
46 +DESCRIPTION="Collects system statistics and provides mechanisms to store the values"
47 +
48 +HOMEPAGE="https://collectd.org/"
49 +SRC_URI="https://github.com/${PN}/${PN}/releases/download/${P}/${P}.tar.bz2"
50 +
51 +LICENSE="MIT GPL-2 GPL-2+ GPL-3 GPL-3+"
52 +SLOT="0"
53 +KEYWORDS="~alpha ~amd64 ~arm ~x86"
54 +IUSE="contrib debug java kernel_Darwin kernel_FreeBSD kernel_linux perl selinux static-libs udev xfs"
55 +
56 +# The plugin lists have to follow here since they extend IUSE
57 +
58 +# Plugins that don't build (e.g. dependencies not in Gentoo)
59 +# apple_sensors: Requires libIOKit
60 +# amqp1: Requires libqpid-proton
61 +# aquaero: Requires aerotools-ng/libaquaero5
62 +# barometer: Requires libi2c (i2c_smbus_read_i2c_block_data)
63 +# dpdkevents: Requires dpdk
64 +# dpdkstat: Requires dpdk
65 +# dpdk_telemetry: Requires dpdk
66 +# grpc: Requires libgrpc
67 +# intel_pmu: Requires libjevents (pmu-tools)
68 +# intel_rdt: Requires libpqos from intel-cmt-cat project
69 +# lpar: Requires libperfstat (AIX only)
70 +# mic: Requires Intel Many Integrated Core Architecture API
71 +# (part of Intel's Xeon Phi software)
72 +# netapp: Requires libnetapp (http://communities.netapp.com/docs/DOC-1110)
73 +# onewire: Requires sys-fs/owfs which was removed from repository
74 +# pf: Requires BSD packet filter
75 +# pinba: Requires MySQL Pinba engine (http://pinba.org/)
76 +# redfish: Requires libredfish
77 +# tape: Requires libkstat (Solaris only)
78 +# tokyotyrant: Requires tokyotyrant
79 +# write_riemann: Requires riemann-c-client
80 +# xmms: Requires libxmms (v1)
81 +# zone: Solaris only...
82 +COLLECTD_IMPOSSIBLE_PLUGINS="apple_sensors amqp1 aquaero barometer
83 + dpdkevents dpdkstat dpdk_telemetry grpc intel_pmu intel_rdt lpar
84 + mic netapp onewire pf pinba redfish tape tokyotyrant write_riemann
85 + xmms zone"
86 +
87 +# Plugins that have been (compile) tested and can be enabled via COLLECTD_PLUGINS
88 +COLLECTD_TESTED_PLUGINS="aggregation amqp apache apcups ascent battery bind
89 + buddyinfo capabilities ceph cgroups check_uptime chrony connectivity
90 + conntrack contextswitch cpu cpufreq cpusleep csv curl curl_json
91 + curl_xml dbi df disk dns drbd email entropy ethstat exec fhcount
92 + filecount fscache gmond gps gpu_nvidia hddtemp hugepages interface ipc
93 + ipmi iptables ipvs irq java lua load logfile logparser log_logstash
94 + madwifi match_empty_counter match_hashed match_regex match_timediff
95 + match_value mbmon mcelog md memcachec memcached memory modbus mqtt
96 + multimeter mysql netlink network network nfs nginx notify_desktop
97 + notify_email notify_nagios ntpd numa nut olsrd onewire openldap
98 + openvpn oracle ovs_events ovs_stats pcie_errors perl ping postgresql
99 + powerdns procevent processes protocols python redis routeros
100 + rrdcached rrdtool sensors serial sigrok slurm smart snmp snmp_agent
101 + statsd swap synproxy sysevent syslog table tail tail_csv
102 + target_notification target_replace target_scale target_set tcpconns
103 + teamspeak2 ted thermal threshold turbostat ubi unixsock uptime users
104 + uuid varnish virt vmem vserver wireless write_graphite write_http
105 + write_influxdb_udp write_kafka write_log write_mongodb write_prometheus
106 + write_redis write_sensu write_stackdriver write_syslog write_tsdb
107 + xencpu zfs_arc zookeeper"
108 +
109 +COLLECTD_DISABLED_PLUGINS="${COLLECTD_IMPOSSIBLE_PLUGINS}"
110 +
111 +COLLECTD_ALL_PLUGINS=${COLLECTD_TESTED_PLUGINS}
112 +
113 +for plugin in ${COLLECTD_ALL_PLUGINS}; do
114 + IUSE="${IUSE} collectd_plugins_${plugin}"
115 +done
116 +unset plugin
117 +
118 +# Now come the dependencies.
119 +
120 +COMMON_DEPEND="
121 + acct-group/collectd
122 + acct-user/collectd
123 + dev-libs/libgcrypt:=
124 + dev-libs/libltdl:0=
125 + sys-libs/libcap
126 + perl? ( dev-lang/perl:=[ithreads] )
127 + udev? ( virtual/udev )
128 + xfs? ( sys-fs/xfsprogs )
129 + collectd_plugins_amqp? ( net-libs/rabbitmq-c )
130 + collectd_plugins_apache? ( net-misc/curl:0= )
131 + collectd_plugins_ascent? ( net-misc/curl:0= dev-libs/libxml2:2= )
132 + collectd_plugins_bind? ( net-misc/curl:0= dev-libs/libxml2:2= )
133 + collectd_plugins_ceph? ( dev-libs/yajl:= )
134 + collectd_plugins_capabilities? ( dev-libs/jansson net-libs/libmicrohttpd:= )
135 + collectd_plugins_connectivity? ( dev-libs/yajl:= net-libs/libmnl )
136 + collectd_plugins_curl? ( net-misc/curl:0= )
137 + collectd_plugins_curl_json? ( net-misc/curl:0= dev-libs/yajl:= )
138 + collectd_plugins_curl_xml? ( net-misc/curl:0= dev-libs/libxml2:2= )
139 + collectd_plugins_dbi? ( dev-db/libdbi )
140 + collectd_plugins_dns? ( net-libs/libpcap )
141 + collectd_plugins_gmond? ( sys-cluster/ganglia )
142 + collectd_plugins_gps? ( sci-geosciences/gpsd:= )
143 + collectd_plugins_gpu_nvidia? ( dev-util/nvidia-cuda-toolkit )
144 + collectd_plugins_ipmi? ( >=sys-libs/openipmi-2.0.16-r1 )
145 + collectd_plugins_iptables? ( >=net-firewall/iptables-1.4.13:0= )
146 + collectd_plugins_log_logstash? ( dev-libs/yajl:= )
147 + collectd_plugins_lua? ( ${LUA_DEPS} )
148 + collectd_plugins_memcachec? ( dev-libs/libmemcached )
149 + collectd_plugins_modbus? ( dev-libs/libmodbus )
150 + collectd_plugins_mqtt? ( app-misc/mosquitto )
151 + collectd_plugins_mysql? ( dev-db/mysql-connector-c:= )
152 + collectd_plugins_netlink? ( net-libs/libmnl )
153 + collectd_plugins_nginx? ( net-misc/curl:0= )
154 + collectd_plugins_notify_desktop? ( x11-libs/libnotify )
155 + collectd_plugins_notify_email? ( net-libs/libesmtp )
156 + collectd_plugins_nut? ( >=sys-power/nut-2.7.2-r2 )
157 + collectd_plugins_openldap? ( net-nds/openldap )
158 + collectd_plugins_oracle? ( dev-db/oracle-instantclient-basic )
159 + collectd_plugins_ovs_events? ( dev-libs/yajl:= )
160 + collectd_plugins_ovs_stats? ( dev-libs/yajl:= )
161 + collectd_plugins_perl? ( dev-lang/perl:=[ithreads] )
162 + collectd_plugins_ping? ( net-libs/liboping )
163 + collectd_plugins_postgresql? ( dev-db/postgresql:= )
164 + collectd_plugins_procevent? ( dev-libs/yajl:= )
165 + collectd_plugins_python? ( ${PYTHON_DEPS} )
166 + collectd_plugins_redis? ( dev-libs/hiredis:= )
167 + collectd_plugins_routeros? ( net-libs/librouteros )
168 + collectd_plugins_rrdcached? ( net-analyzer/rrdtool:= )
169 + collectd_plugins_rrdtool? ( net-analyzer/rrdtool:= )
170 + collectd_plugins_sensors? ( sys-apps/lm-sensors:= )
171 + collectd_plugins_sigrok? ( >=sci-libs/libsigrok-0.4:= dev-libs/glib:2 )
172 + collectd_plugins_slurm? ( sys-cluster/slurm )
173 + collectd_plugins_smart? ( dev-libs/libatasmart:0= )
174 + collectd_plugins_snmp? ( net-analyzer/net-snmp )
175 + collectd_plugins_snmp_agent? ( net-analyzer/net-snmp )
176 + collectd_plugins_sysevent? ( dev-libs/yajl:= )
177 + collectd_plugins_varnish? ( www-servers/varnish:= )
178 + collectd_plugins_virt? ( app-emulation/libvirt:= dev-libs/libxml2:2= )
179 + collectd_plugins_write_http? ( net-misc/curl:0= dev-libs/yajl:= )
180 + collectd_plugins_write_kafka? ( >=dev-libs/librdkafka-0.9.0.99:= dev-libs/yajl:= )
181 + collectd_plugins_write_mongodb? ( >=dev-libs/mongo-c-driver-1.8.2:= )
182 + collectd_plugins_write_prometheus? ( >=dev-libs/protobuf-c-1.2.1-r1:= net-libs/libmicrohttpd:= )
183 + collectd_plugins_write_redis? ( dev-libs/hiredis:= )
184 + collectd_plugins_write_stackdriver? ( net-misc/curl:0= dev-libs/yajl:= )
185 + collectd_plugins_xencpu? ( app-emulation/xen-tools:= )
186 +
187 + kernel_FreeBSD? (
188 + collectd_plugins_disk? ( sys-libs/libstatgrab:= )
189 + collectd_plugins_interface? ( sys-libs/libstatgrab:= )
190 + collectd_plugins_load? ( sys-libs/libstatgrab:= )
191 + collectd_plugins_memory? ( sys-libs/libstatgrab:= )
192 + collectd_plugins_swap? ( sys-libs/libstatgrab:= )
193 + collectd_plugins_users? ( sys-libs/libstatgrab:= )
194 + )"
195 +
196 +# FIXME: should virtual/jdk be here as well?
197 +BDEPEND="virtual/pkgconfig"
198 +
199 +# Enforcing !=sys-kernel/linux-headers-4.5 > due to #577846
200 +DEPEND="${COMMON_DEPEND}
201 + collectd_plugins_iptables? ( || ( <=sys-kernel/linux-headers-4.4 >=sys-kernel/linux-headers-4.6 ) )
202 + collectd_plugins_java? ( >=virtual/jdk-1.6 )"
203 +
204 +RDEPEND="${COMMON_DEPEND}
205 + collectd_plugins_java? ( >=virtual/jre-1.6 )
206 + collectd_plugins_syslog? ( virtual/logger )
207 + selinux? ( sec-policy/selinux-collectd )"
208 +
209 +REQUIRED_USE="
210 + collectd_plugins_lua? ( ${LUA_REQUIRED_USE} )
211 + collectd_plugins_python? ( ${PYTHON_REQUIRED_USE} )
212 + collectd_plugins_smart? ( udev )
213 + contrib? ( perl )"
214 +
215 +PATCHES=( "${FILESDIR}"/${PN}-5.11.0-libsigrok-0.4+.patch )
216 +
217 +# @FUNCTION: collectd_plugin_kernel_linux
218 +# @DESCRIPTION:
219 +# USAGE: <plugin name> <kernel_options> <severity>
220 +# kernel_options is a list of kernel configurations options; the check tests whether at least
221 +# one of them is enabled. If no, depending on the third argument an elog, ewarn, or eerror message
222 +# is emitted.
223 +collectd_plugin_kernel_linux() {
224 + local multi_opt opt
225 + if has ${1} ${COLLECTD_ALL_PLUGINS}; then
226 + if use collectd_plugins_${1}; then
227 + for opt in ${2}; do
228 + if linux_chkconfig_present ${opt}; then
229 + return 0;
230 + fi
231 + done
232 + multi_opt=${2//\ /\ or\ }
233 + case ${3} in
234 + (info)
235 + elog "The ${1} plugin can use kernel features that are disabled now; enable ${multi_opt} in your kernel"
236 + ;;
237 + (warn)
238 + ewarn "The ${1} plugin uses kernel features that are disabled now; enable ${multi_opt} in your kernel"
239 + ;;
240 + (error)
241 + eerror "The ${1} plugin needs kernel features that are disabled now; enable ${multi_opt} in your kernel"
242 + ;;
243 + (*)
244 + die "function collectd_plugin_kernel_linux called with invalid third argument"
245 + ;;
246 + esac
247 + fi
248 + fi
249 +}
250 +
251 +collectd_linux_kernel_checks() {
252 + if ! linux_chkconfig_present PROC_FS; then
253 + ewarn "/proc file system support is disabled, many plugins will not be able to read any statistics from your system unless you enable PROC_FS in your kernel"
254 + fi
255 +
256 + if ! linux_chkconfig_present SYSFS; then
257 + ewarn "/sys file system support is disabled, many plugins will not be able to read any statistics from your system unless you enable SYSFS in your kernel"
258 + fi
259 +
260 + # battery.c: /proc/pmu/battery_%i
261 + # battery.c: /proc/acpi/battery
262 + collectd_plugin_kernel_linux battery ACPI_BATTERY warn
263 +
264 + # cgroups.c: /sys/fs/cgroup/
265 + collectd_plugin_kernel_linux cgroups CGROUPS warn
266 +
267 + # cpufreq.c: /sys/devices/system/cpu/cpu%d/cpufreq/
268 + collectd_plugin_kernel_linux cpufreq SYSFS warn
269 + collectd_plugin_kernel_linux cpufreq CPU_FREQ_STAT warn
270 +
271 + # drbd.c: /proc/drbd
272 + collectd_plugin_kernel_linux drbd BLK_DEV_DRBD warn
273 +
274 + # conntrack.c: /proc/sys/net/netfilter/*
275 + collectd_plugin_kernel_linux conntrack NETFILTER warn
276 +
277 + # fscache.c: /proc/fs/fscache/stats
278 + collectd_plugin_kernel_linux fscache FSCACHE warn
279 +
280 + # nfs.c: /proc/net/rpc/nfs
281 + # nfs.c: /proc/net/rpc/nfsd
282 + collectd_plugin_kernel_linux nfs NFS_COMMON warn
283 +
284 + # serial.c: /proc/tty/driver/serial
285 + # serial.c: /proc/tty/driver/ttyS
286 + collectd_plugin_kernel_linux serial SERIAL_CORE warn
287 +
288 + # swap.c: /proc/meminfo
289 + collectd_plugin_kernel_linux swap SWAP warn
290 +
291 + # thermal.c: /proc/acpi/thermal_zone
292 + # thermal.c: /sys/class/thermal
293 + collectd_plugin_kernel_linux thermal ACPI_THERMAL warn
294 +
295 + # turbostat.c: /dev/cpu/%d/msr
296 + collectd_plugin_kernel_linux turbostat X86_MSR warn
297 +
298 + # vmem.c: /proc/vmstat
299 + collectd_plugin_kernel_linux vmem VM_EVENT_COUNTERS warn
300 +
301 + # vserver.c: /proc/virtual
302 + collectd_plugin_kernel_linux vserver VSERVER warn
303 +
304 + # uuid.c: /sys/hypervisor/uuid
305 + collectd_plugin_kernel_linux uuid SYSFS info
306 +
307 + # wireless.c: /proc/net/wireless
308 + collectd_plugin_kernel_linux wireless "WIRELESS MAC80211 IEEE80211" warn
309 +
310 + # zfs_arc.c: /proc/spl/kstat/zfs/arcstats
311 + collectd_plugin_kernel_linux zfs_arc "SPL ZFS" warn
312 +}
313 +
314 +pkg_setup() {
315 + if use kernel_linux; then
316 + linux-info_pkg_setup
317 +
318 + if linux_config_exists; then
319 + einfo "Checking your linux kernel configuration:"
320 + collectd_linux_kernel_checks
321 + else
322 + elog "Cannot find a linux kernel configuration. Continuing anyway."
323 + fi
324 + fi
325 +
326 + if use collectd_plugins_java; then
327 + java-pkg-opt-2_pkg_setup
328 + fi
329 +
330 + use collectd_plugins_lua && lua-single_pkg_setup
331 + use collectd_plugins_python && python-single-r1_pkg_setup
332 +}
333 +
334 +src_prepare() {
335 + default
336 +
337 + # There's some strange prefix handling in the default config file, resulting in
338 + # paths like "/usr/var/..."
339 + sed -i -e "s:@prefix@/var:/var:g" src/collectd.conf.in || die
340 +
341 + # Adjust upstream's systemd unit
342 + # - Get rid of EnvironmentFile directive; These files don't exist on Gentoo!
343 + # - Add User=collectd to run collectd as user "collectd" per default
344 + sed -i \
345 + -e '/^EnvironmentFile=.*/d' \
346 + -e '/^\[Service\]/aUser=collectd' \
347 + contrib/systemd.${PN}.service || die
348 +
349 + eautoreconf
350 +}
351 +
352 +src_configure() {
353 + # Now come the lists of os-dependent plugins. Any plugin that is not listed anywhere here
354 + # should work independent of the operating system.
355 +
356 + local linux_plugins="barometer battery cpu cpufreq disk
357 + drbd entropy ethstat hugepages interface iptables
358 + ipvs irq ipc load memory md netlink nfs numa processes
359 + serial swap tcpconns thermal turbostat users vmem wireless
360 + zfc_arc"
361 +
362 + local need_libstatgrab=0
363 + local libstatgrab_plugins="cpu disk interface load memory swap users"
364 + local bsd_plugins="cpu tcpconns ${libstatgrab_plugins} zfc_arc"
365 +
366 + local darwin_plugins="apple_sensors battery cpu disk interface memory processes tcpconns"
367 +
368 + local osdependent_plugins="${linux_plugins} ${bsd_plugins} ${darwin_plugins}"
369 + local myos_plugins=""
370 + if use kernel_linux; then
371 + einfo "Enabling Linux plugins."
372 + myos_plugins=${linux_plugins}
373 + elif use kernel_FreeBSD; then
374 + einfo "Enabling FreeBSD plugins."
375 + myos_plugins=${bsd_plugins}
376 + elif use kernel_Darwin; then
377 + einfo "Enabling Darwin plugins."
378 + myos_plugins=${darwin_plugins}
379 + fi
380 +
381 + local myconf="--disable-werror"
382 +
383 + # Do we debug?
384 + myconf+=" $(use_enable debug)"
385 +
386 + # udev support?
387 + # Required for smart plugin via REQUIRED_USE; Optional for disk plugin
388 + if use udev; then
389 + myconf+=" --with-libudev"
390 + else
391 + myconf+=" --without-libudev"
392 + fi
393 +
394 + local plugin
395 +
396 + # Disable what needs to be disabled.
397 + for plugin in ${COLLECTD_DISABLED_PLUGINS}; do
398 + if [[ "${plugin}" == 'dpdkstat' ]]; then
399 + myconf+=" --without-libdpdk"
400 + else
401 + myconf+=" --disable-${plugin}"
402 + fi
403 + done
404 +
405 + # Set enable/disable for each single plugin.
406 + for plugin in ${COLLECTD_ALL_PLUGINS}; do
407 + if has ${plugin} ${osdependent_plugins}; then
408 + # plugin is os-dependent ...
409 + if has ${plugin} ${myos_plugins}; then
410 + # ... and available in this os
411 + myconf+=" $(use_enable collectd_plugins_${plugin} ${plugin})"
412 + # ... must we link against libstatgrab? Bug #541518
413 + if use kernel_FreeBSD && has ${plugin} ${libstatgrab_plugins}; then
414 + einfo "We must link against libstatgrab due to plugin \"${plugin}\" ..."
415 + need_libstatgrab=1
416 + fi
417 + else
418 + # ... and NOT available in this os
419 + if use collectd_plugins_${plugin}; then
420 + ewarn "You try to enable the ${plugin} plugin, but it is not available for this"
421 + ewarn "kernel. Disabling it automatically."
422 + fi
423 + myconf+=" --disable-${plugin}"
424 + fi
425 + elif [[ "${plugin}" = "collectd_plugins_perl" ]]; then
426 + if use collectd_plugins_perl && ! use perl; then
427 + ewarn "Perl plugin disabled as perl bindings disabled by -perl use flag"
428 + myconf+= --disable-perl
429 + else
430 + myconf+=" $(use_enable collectd_plugins_${plugin} ${plugin})"
431 + fi
432 + else
433 + myconf+=" $(use_enable collectd_plugins_${plugin} ${plugin})"
434 + fi
435 + done
436 +
437 + if [ "${need_libstatgrab}" -eq 1 ]; then
438 + myconf+=" --with-libstatgrab"
439 + else
440 + myconf+=" --without-libstatgrab"
441 + fi
442 +
443 + # JAVA_HOME is set by eclasses.
444 + if use collectd_plugins_java; then
445 + myconf+=" --with-java"
446 + fi
447 +
448 + # Need libiptc ONLY for iptables. If we try to use it otherwise bug 340109 happens.
449 + # lots of libs are only needed for plugins, if they are disabled, also disable the lib
450 + use collectd_plugins_iptables || myconf+=" --with-libiptc=no"
451 + use collectd_plugins_openldap || myconf+=" --with-libldap=no"
452 + use collectd_plugins_redis || use collectd_plugins_write_redis || myconf+=" --with-libhiredis=no"
453 + use collectd_plugins_smart || myconf+=" --with-libatasmart=no"
454 + use collectd_plugins_gps || myconf+=" --with-libgps=no"
455 +
456 + if use collectd_plugins_gpu_nvidia; then
457 + myconf+=" --with-cuda=${EPREFIX}/opt/cuda"
458 + else
459 + myconf+=" --with-cuda=no"
460 + fi
461 +
462 + if use perl; then
463 + myconf+=" --with-perl-bindings=INSTALLDIRS=vendor"
464 + else
465 + myconf+=" --without-perl-bindings"
466 + fi
467 +
468 + # No need for v5upgrade
469 + myconf+=" --disable-target_v5upgrade"
470 +
471 + # Python
472 + if use collectd_plugins_python; then
473 + myconf+=" --with-libpython=yes"
474 + export PYTHON_CONFIG=$(python_get_PYTHON_CONFIG)
475 + else
476 + myconf+=" --with-libpython=no"
477 + fi
478 +
479 + # XFS support
480 + myconf+=" $(use_enable xfs)"
481 +
482 + # Finally, run econf.
483 + KERNEL_DIR="${KERNEL_DIR}" econf --config-cache \
484 + $(use_enable static-libs static) \
485 + --localstatedir=/var ${myconf}
486 +}
487 +
488 +src_install() {
489 + emake DESTDIR="${D}" install
490 +
491 + perl_delete_localpod
492 +
493 + find "${ED}"/usr/ -name "*.la" -delete || die
494 +
495 + if use collectd_plugins_java; then
496 + java-pkg_regjar "${ED}"/usr/share/${PN}/java/*.jar
497 + fi
498 +
499 + if use collectd_plugins_disk && use udev; then
500 + udev_newrules contrib/99-storage-collectd.rules 60-persistent-storage-collectd.rules
501 + fi
502 +
503 + fowners root:collectd /etc/collectd.conf
504 + fperms u=rw,g=r,o= /etc/collectd.conf
505 +
506 + einstalldocs
507 +
508 + if use contrib; then
509 + insinto /usr/share/${PN}
510 + doins -r contrib
511 + fi
512 +
513 + keepdir /var/lib/${PN}
514 + fowners collectd:collectd /var/lib/${PN}
515 +
516 + newinitd "${FILESDIR}/${PN}.initd-r2" ${PN}
517 + newconfd "${FILESDIR}/${PN}.confd-r2" ${PN}
518 + systemd_newunit "contrib/systemd.${PN}.service" ${PN}.service
519 +
520 + insinto /etc/logrotate.d
521 + newins "${FILESDIR}/${PN}.logrotate" ${PN}
522 +
523 + newtmpfiles "${FILESDIR}"/${PN}.tmpfile ${PN}.conf
524 +
525 + sed -i -e 's:^.*PIDFile "/var/run/collectd.pid":#PIDFile "/run/collectd.pid":' "${ED}"/etc/collectd.conf || die
526 + sed -i -e 's:^# SocketFile "/var/run/collectd-unixsock":# SocketFile "/run/collectd/collectd.socket":' "${ED}"/etc/collectd.conf || die
527 + sed -i -e 's:^.*LoadPlugin perl$:# The new, correct way to load the perl plugin -- \n# <LoadPlugin perl>\n# Globals true\n# </LoadPlugin>:' "${ED}"/etc/collectd.conf || die
528 + sed -i -e 's:^.*LoadPlugin python$:# The new, correct way to load the python plugin -- \n# <LoadPlugin python>\n# Globals true\n# </LoadPlugin>:' "${ED}"/etc/collectd.conf || die
529 +}
530 +
531 +pkg_postinst() {
532 + tmpfiles_process "${PN}.conf"
533 +
534 + if use filecaps; then
535 + local caps=()
536 + use collectd_plugins_ceph && caps+=('CAP_DAC_OVERRIDE')
537 + use collectd_plugins_exec && caps+=('CAP_SETUID' 'CAP_SETGID')
538 + use collectd_plugins_iptables && caps+=('CAP_NET_ADMIN')
539 + use collectd_plugins_filecount && caps+=('CAP_DAC_READ_SEARCH')
540 +
541 + if use collectd_plugins_dns || use collectd_plugins_ping; then
542 + caps+=('CAP_NET_RAW')
543 + fi
544 +
545 + if use collectd_plugins_turbostat || use collectd_plugins_smart; then
546 + caps+=('CAP_SYS_RAWIO')
547 + fi
548 +
549 + if [ ${#caps[@]} -gt 0 ]; then
550 + local caps_str=$(IFS=","; echo "${caps[*]}")
551 + fcaps ${caps_str} usr/sbin/collectd
552 + elog "Capabilities for ${EROOT}/usr/sbin/collectd set to:"
553 + elog " ${caps_str}+EP"
554 + elog
555 +
556 + local systemd_unit="$(systemd_get_systemunitdir)/collectd.service"
557 + if [[ -e "${systemd_unit}" ]]; then
558 + caps_str="${caps[*]}"
559 + sed -i -e "s:^CapabilityBoundingSet=.*:CapabilityBoundingSet=${caps_str}:" "${systemd_unit}" || \
560 + die "Failed to set CapabilityBoundingSet in '${systemd_unit}'"
561 +
562 + elog "CapabilityBoundingSet in '${systemd_unit}'"
563 + elog "updated to match capabilities set above."
564 + elog
565 + else
566 + if has_version "sys-apps/systemd"; then
567 + # Bug 596852
568 + ewarn "Failed to update CapabilityBoundingSet in '${systemd_unit}'"
569 + ewarn "because unit was not found. Please file a bug about this."
570 + fi
571 + fi
572 + fi
573 + fi
574 +
575 + elog "Note: Collectd is only the collector."
576 + elog " You need to install 'data' sources (applications) locally or"
577 + elog " remotely on your own."
578 +
579 + elog
580 + elog "Collectd is configured to run as unprivileged user by default."
581 + elog "You may want to revisit the configuration."
582 + elog
583 +
584 + if use collectd_plugins_email; then
585 + ewarn "The email plug-in is deprecated. To submit statistics please use the unixsock plugin."
586 + fi
587 +
588 + if use collectd_plugins_smart; then
589 + elog ""
590 + elog "If you are using smart plugin and don't run collectd as root make sure"
591 + elog "that the collectd user is allowed to access the disk you want to monitor"
592 + elog "(can be done via udev rule for example) and that collectd has the required"
593 + elog "capabilities set (which is the default when package was emerged with"
594 + elog "'filecaps' USE flag set)."
595 + fi
596 +
597 + if use contrib; then
598 + elog "The scripts in /usr/share/doc/${PF}/collection3 for generating graphs need dev-perl/HTML-Parser,"
599 + elog "dev-perl/CGI, dev-perl/Config-General and net-analyzer/rrdtool[perl] to be installed."
600 + fi
601 +}