PKGBUILDs/extra/netdata/PKGBUILD
2024-02-22 17:44:52 +00:00

97 lines
4.3 KiB
Bash

# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: SanskritFritz (gmail)
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - disable LTO
pkgname=netdata
pkgver=1.44.3
pkgrel=1
_go_ver="0.57.2"
pkgdesc="Real-time performance monitoring, in the greatest possible detail, over the web"
url="https://github.com/netdata/netdata"
arch=('x86_64')
license=('GPL')
backup=('etc/netdata/netdata.conf')
depends=('libmnl' 'libnetfilter_acct' 'zlib' 'judy' 'libuv' 'json-c' 'libcap' 'lz4' 'openssl' 'which' 'snappy' 'protobuf'
'libwebsockets' 'mongo-c-driver' 'libyaml')
makedepends=('cups' 'go')
optdepends=('nodejs: for monitoring named and SNMP devices'
'lm_sensors: for monitoring hardware sensors'
'iproute2: for monitoring Linux QoS'
'python: for most of the external plugins'
'python-psycopg2: for monitoring PostgreSQL databases'
'python-mysqlclient: for monitoring MySQL/MariaDB databases'
'python-requests: for monitoring elasticsearch'
'hddtemp: for monitoring hhd temperature'
'fping: for for fping module'
'apcupsd: for monitoring APC UPS'
'cups: for CUPS plugin'
'iw: for monitoring Linux as access point')
source=("$pkgname-$pkgver.tar.gz::https://github.com/netdata/netdata/releases/download/v$pkgver/netdata-v$pkgver.tar.gz"
"go.d.plugin-${_go_ver}.tar.gz::https://github.com/netdata/go.d.plugin/archive/refs/tags/v${_go_ver}.tar.gz"
"https://github.com/netdata/go.d.plugin/releases/download/v${_go_ver}/go.d.plugin-config-v${_go_ver}.tar.gz"
"netdata.sysusers")
sha512sums=('cbc0698b33d27d78b13fe0a915288a22fc4bb3246c37cf48037650ef9465553a6a92f1702ca273c05cdd9385eecc0713f230939a8341dfe174403d8623388922'
'b8bc855d18245bfa69407a1449be4179375ecd6b6d9014f8726b0ac0c9b52a7ff193e50df82cf09c7a598f96a4edc8f9178b4f77c78af07a1e15e49a2d06b9e8'
'a64683be6d3327ce9500606b22d8d908cf36206934b5437d1c91d893c72cd8e44057f895c7e3986aa22335884903f2835d4b64196a65060d4dee41a6bca321b1'
'a910809a823ba58ca7bdaa72e8d68427b48f452c1fbb2343fa182ecb0a091a7640e73af24b8ba2fdd90e00aed8ef53b7fccd25cb8f04ca9b9fa6c8e52223ca66')
prepare() {
cd $pkgname-v$pkgver
# protobuf 23 requires c++17
sed -e 's|\# AX_CXX_COMPILE_STDCXX(17, noext, optional)|AX_CXX_COMPILE_STDCXX(17, noext, optional)|' -i configure.ac
}
build() {
cd "$pkgname-v$pkgver"
autoreconf -i
./configure \
--prefix="/usr" \
--sbindir="/usr/bin" \
--sysconfdir="/etc" \
--libexecdir="/usr/lib" \
--localstatedir="/var" \
--disable-lto \
--with-zlib \
--with-math \
--with-user=netdata
make
cd ../go.d.plugin-${_go_ver}
go build \
-trimpath \
-buildmode=pie \
-mod=readonly \
-modcacherw \
-ldflags "-X main.version=${_go_ver} -linkmode external -extldflags \"${LDFLAGS}\"" \
-o go.d.plugin \
./cmd/godplugin
}
package() {
cd "$pkgname-v$pkgver"
make DESTDIR="$pkgdir" install
# go.d.plugin
install -Dm755 ${srcdir}/go.d.plugin-${_go_ver}/go.d.plugin "${pkgdir}/usr/lib/netdata/plugins.d/go.d.plugin"
cp -r "${srcdir}/go.d.conf" "${srcdir}/go.d" "${pkgdir}/usr/lib/${pkgname}/conf.d"
install -Dm644 system/netdata.conf "$pkgdir"/etc/netdata/netdata.conf
chown -R 0:134 "$pkgdir"/usr/share/netdata/web
install -Dm0644 "system/systemd/netdata.service.v235" "${pkgdir}/usr/lib/systemd/system/netdata.service"
install -Dm0644 "system/logrotate/netdata" "${pkgdir}/etc/logrotate.d/netdata"
install -Dm0644 "${srcdir}/netdata.sysusers" "${pkgdir}/usr/lib/sysusers.d/netdata.conf"
# https://github.com/netdata/netdata/tree/master/collectors/apps.plugin#permissions
# Also check curl -Ss https://raw.githubusercontent.com/netdata/netdata/master/netdata.spec.in | grep "%caps"
setcap cap_net_admin,cap_net_raw+eip "${pkgdir}/usr/lib/netdata/plugins.d/go.d.plugin"
setcap cap_dac_read_search,cap_sys_ptrace+ep "${pkgdir}/usr/lib/netdata/plugins.d/apps.plugin"
setcap cap_dac_read_search+ep "${pkgdir}/usr/lib/netdata/plugins.d/slabinfo.plugin"
setcap cap_perfmon,cap_sys_admin+ep "${pkgdir}/usr/lib/netdata/plugins.d/perf.plugin"
setcap cap_dac_read_search+ep "${pkgdir}/usr/lib/netdata/plugins.d/debugfs.plugin"
setcap cap_dac_read_search+ep "${pkgdir}/usr/lib/netdata/plugins.d/systemd-journal.plugin"
}