Properly handle eBPF plugin in RPM packages. (#11362)
Austin S. Hemmelgarn committed
Jul 26, 2021 at 07:05 UTC
1bc3051f8e4736b1a71c3744a1c0d0fd59eed40c
2 files changed
+10
-20
netdata.spec.in
-12
@@ -10,12 +10,6 @@
10
# PACKAGE IS BROKEN WITHOUT THEM.
11
AutoReqProv: yes
12
13
-%if "@HAVE_LIBBPF@" == "1"
14
-%global have_bpf 1
15
-%else
16
-%global have_bpf 0
17
-%endif
18
-
13
# This is temporary and should eventually be resolved. This bypasses
14
# the default rhel __os_install_post which throws a python compile
15
# error.
@@ -228,9 +222,7 @@ export CFLAGS="${CFLAGS} -fPIC" && ${RPM_BUILD_DIR}/%{name}-%{version}/packaging
222
%if 0%{!?fedora:1} && 0%{!?suse_version:1}
223
export CFLAGS="${CFLAGS} -fPIC" && ${RPM_BUILD_DIR}/%{name}-%{version}/packaging/bundle-judy.sh ${RPM_BUILD_DIR}/%{name}-%{version}
224
%endif
231
-%if 0%{?have_bpf}
225
export CFLAGS="${CFLAGS} -fPIC" && ${RPM_BUILD_DIR}/%{name}-%{version}/packaging/bundle-libbpf.sh ${RPM_BUILD_DIR}/%{name}-%{version}
233
-%endif
226
227
%build
228
# Conf step
@@ -282,9 +274,7 @@ install -m 4750 -p perf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.
274
275
# ###########################################################
276
# Install ebpf.plugin
285
-%if 0%{?have_bpf}
277
install -m 4750 -p ebpf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/ebpf.plugin"
287
-%endif
278
279
# ###########################################################
280
# Install cups.plugin
@@ -411,9 +401,7 @@ install_go() {
401
install_go
402
install -m 0640 -p go.d.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/go.d.plugin"
403
414
-%if 0%{?have_bpf}
404
${RPM_BUILD_DIR}/%{name}-%{version}/packaging/bundle-ebpf.sh ${RPM_BUILD_DIR}/%{name}-%{version} ${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d
416
-%endif
405
406
%pre
407
packaging/bundle-ebpf.sh
+10
-8
@@ -6,12 +6,14 @@ PLUGINDIR="${2}"
6
EBPF_VERSION="$(cat "${SRCDIR}/packaging/ebpf.version")"
7
EBPF_TARBALL="netdata-kernel-collector-glibc-${EBPF_VERSION}.tar.xz"
8
9
-mkdir -p "${SRCDIR}/tmp/ebpf"
10
-curl -sSL --connect-timeout 10 --retry 3 "https://github.com/netdata/kernel-collector/releases/download/${EBPF_VERSION}/${EBPF_TARBALL}" > "${EBPF_TARBALL}" || exit 1
11
-grep "${EBPF_TARBALL}" "${SRCDIR}/packaging/ebpf.checksums" | sha256sum -c - || exit 1
12
-tar -xaf "${EBPF_TARBALL}" -C "${SRCDIR}/tmp/ebpf" || exit 1
13
-if [ ! -d "${PLUGINDIR}/ebpf.d" ];then
14
- mkdir "${PLUGINDIR}/ebpf.d"
9
+if [ -x "${PLUGINDIR}/ebpf.plugin" ] ; then
10
+ mkdir -p "${SRCDIR}/tmp/ebpf"
11
+ curl -sSL --connect-timeout 10 --retry 3 "https://github.com/netdata/kernel-collector/releases/download/${EBPF_VERSION}/${EBPF_TARBALL}" > "${EBPF_TARBALL}" || exit 1
12
+ grep "${EBPF_TARBALL}" "${SRCDIR}/packaging/ebpf.checksums" | sha256sum -c - || exit 1
13
+ tar -xaf "${EBPF_TARBALL}" -C "${SRCDIR}/tmp/ebpf" || exit 1
14
+ if [ ! -d "${PLUGINDIR}/ebpf.d" ];then
15
+ mkdir "${PLUGINDIR}/ebpf.d"
16
+ fi
17
+ # shellcheck disable=SC2046
18
+ cp -a $(find "${SRCDIR}/tmp/ebpf" -mindepth 1 -maxdepth 1) "${PLUGINDIR}/ebpf.d"
19
fi
16
-# shellcheck disable=SC2046
17
-cp -a $(find "${SRCDIR}/tmp/ebpf" -mindepth 1 -maxdepth 1) "${PLUGINDIR}/ebpf.d"