# Template file for 'netdata'
pkgname=netdata
version=1.33.0
revision=1
wrksrc="${pkgname}-v${version}"
build_style=gnu-configure
configure_args="--with-user=_netdata ac_cv_file_externaldeps_libbpf_libbpf_a=no"
hostmakedepends="pkg-config autoconf automake"
makedepends="json-c-devel judy-devel libcap-devel liblz4-devel libmnl-devel
 libnetfilter_acct-devel openssl-devel libuuid-devel libuv-devel zlib-devel"
depends="libcap-progs"
short_desc="Real-time performance monitoring, done right"
maintainer="Michael Aldridge <maldridge@voidlinux.org>"
license="GPL-3.0-or-later"
homepage="https://www.netdata.cloud/"
distfiles="https://github.com/netdata/netdata/releases/download/v${version}/netdata-v${version}.tar.gz"
checksum=d167d4b2d8529119fa4047ae40d22833dac9d360a6ed07c314ba313807c027eb
python_version=3
make_dirs="
 /var/lib/netdata          0755 _netdata _netdata
 /var/lib/netdata/registry 0755 _netdata root
 /var/cache/netdata        0755 _netdata _netdata
 /var/log/netdata          0755 _netdata _netdata
"

system_accounts="_netdata"
conf_files="/etc/${pkgname}/*.conf"

pre_configure() {
	autoreconf -ivf
}

post_install() {
	vsv netdata
	vcopy ${FILESDIR}/netdata.conf etc/$pkgname/
	if [ -n "$_without_node" ]; then
		rm -rf ${DESTDIR}/usr/libexec/netdata/node.d
		rm -rf ${DESTDIR}/usr/libexec/netdata/plugins.d/node.d.plugin
	fi
}

netdata-plugins-nodejs_package() {
	short_desc+=" - NodeJS Plugins"
	depends="${sourcepkg}>=${version}_${revision} virtual?nodejs-runtime"
	pkg_install() {
		vmove usr/libexec/netdata/plugins.d/node.d.plugin
		vmove usr/libexec/netdata/node.d
	}
}

netdata-plugins-python_package() {
	short_desc+=" - Python Plugins"
	depends="${sourcepkg}>=${version}_${revision} python3"
	pkg_install() {
		vmove usr/libexec/netdata/plugins.d/python.d.plugin
		vmove usr/libexec/netdata/python.d
		vmove etc/netdata/python.d
	}
}
