@cryptotaxi247 / netdata-1 / commits / d787fc15a

eBPF installation fixes (#12242)

thiagoftsm committed Feb 25, 2022 at 17:10 UTC d787fc15a4902f4ce10b2afd2516a5babef64c01
1 file changed +39 -19
netdata-installer.sh
+39 -19
@@ -904,6 +904,37 @@ get_kernel_version() {
904 printf "%03d%03d%03d" "${maj}" "${min}" "${patch}"
905 }
906
907 +detect_libc() {
908 + libc=
909 + if ldd --version 2>&1 | grep -q -i glibc; then
910 + echo >&2 " Detected GLIBC"
911 + libc="glibc"
912 + elif ldd --version 2>&1 | grep -q -i 'gnu libc'; then
913 + echo >&2 " Detected GLIBC"
914 + libc="glibc"
915 + elif ldd --version 2>&1 | grep -q -i musl; then
916 + echo >&2 " Detected musl"
917 + libc="musl"
918 + else
919 + ls_path=$(command -v ls)
920 + if [ -n "${ls_path}" ] ; then
921 + cmd=$(ldd "$ls_path" | grep -w libc | cut -d" " -f 3)
922 + if bash -c "${cmd}" 2>&1 | grep -q -i "GNU C Library"; then
923 + echo >&2 " Detected GLIBC"
924 + libc="glibc"
925 + fi
926 + fi
927 + fi
928 +
929 + if [ -z "$libc" ]; then
930 + echo >&2 " ERROR: Cannot detect a supported libc on your system!"
931 + return 1
932 + fi
933 +
934 + echo "${libc}"
935 + return 0
936 +}
937 +
938 rename_libbpf_packaging() {
939 if [ "$(get_kernel_version)" -ge "004014000" ]; then
940 cp packaging/current_libbpf.checksums packaging/libbpf.checksums
@@ -943,6 +974,14 @@ bundle_libbpf() {
974 return 0
975 fi
976
977 + # When libc is not detected, we do not have necessity to compile libbpf and we should not do download of eBPF programs
978 + libc="${EBPF_LIBC:-"$(detect_libc)"}"
979 + if [ -z "$libc" ]; then
980 + NETDATA_DISABLE_EBPF=1
981 + NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ebpf)}" | sed 's/$/ --disable-ebpf/g')"
982 + return 0
983 + fi
984 +
985 [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling libbpf."
986
987 rename_libbpf_packaging
@@ -1555,25 +1594,6 @@ install_go() {
1594
1595 install_go
1596
1558 -detect_libc() {
1559 - libc=
1560 - if ldd --version 2>&1 | grep -q -i glibc; then
1561 - echo >&2 " Detected GLIBC"
1562 - libc="glibc"
1563 - elif ldd --version 2>&1 | grep -q -i 'gnu libc'; then
1564 - echo >&2 " Detected GLIBC"
1565 - libc="glibc"
1566 - elif ldd --version 2>&1 | grep -q -i musl; then
1567 - echo >&2 " Detected musl"
1568 - libc="musl"
1569 - else
1570 - echo >&2 " ERROR: Cannot detect a supported libc on your system!"
1571 - return 1
1572 - fi
1573 - echo "${libc}"
1574 - return 0
1575 -}
1576 -
1597 should_install_ebpf() {
1598 if [ "${NETDATA_DISABLE_EBPF:=0}" -eq 1 ]; then
1599 run_failed "eBPF explicitly disabled."