70-netdata-git.install.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # shellcheck source=./packaging/makeself/functions.sh
  4. . "${NETDATA_MAKESELF_PATH}"/functions.sh "${@}" || exit 1
  5. cd "${NETDATA_SOURCE_PATH}" || exit 1
  6. if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then
  7. export CFLAGS="-ffunction-sections -fdata-sections -static -O2 -funroll-loops -I/openssl-static/include -I/libnetfilter-acct-static/include/libnetfilter_acct -I/usr/include/libmnl -pipe"
  8. else
  9. export CFLAGS="-static -O1 -pipe -ggdb -Wall -Wextra -Wformat-signedness -DNETDATA_INTERNAL_CHECKS=1 -I/openssl-static/include -I/libnetfilter-acct-static/include/libnetfilter_acct -I/usr/include/libmnl"
  10. fi
  11. export LDFLAGS="-Wl,--gc-sections -static -L/openssl-static/lib -L/libnetfilter-acct-static/lib -lnetfilter_acct -L/usr/lib -lmnl"
  12. # We export this to 'yes', installer sets this to .environment.
  13. # The updater consumes this one, so that it can tell whether it should update a static install or a non-static one
  14. export IS_NETDATA_STATIC_BINARY="yes"
  15. # Set eBPF LIBC to "static" to bundle the `-static` variant of the kernel-collector
  16. export EBPF_LIBC="static"
  17. export PKG_CONFIG="pkg-config --static"
  18. export PKG_CONFIG_PATH="/openssl-static/lib/pkgconfig:/libnetfilter-acct-static/lib/pkgconfig:/usr/lib/pkgconfig"
  19. # Set correct CMake flags for building against non-System OpenSSL
  20. # See: https://github.com/warmcat/libwebsockets/blob/master/READMEs/README.build.md
  21. export CMAKE_FLAGS="-DOPENSSL_ROOT_DIR=/openssl-static -DOPENSSL_LIBRARIES=/openssl-static/lib -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static -DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include -DLWS_OPENSSL_LIBRARIES=/openssl-static/lib/libssl.a;/openssl-static/lib/libcrypto.a"
  22. run ./netdata-installer.sh \
  23. --install-prefix "${NETDATA_INSTALL_PARENT}" \
  24. --dont-wait \
  25. --dont-start-it \
  26. --require-cloud \
  27. --use-system-protobuf \
  28. --dont-scrub-cflags-even-though-it-may-break-things \
  29. --one-time-build \
  30. --enable-lto
  31. # shellcheck disable=SC2015
  32. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Finishing netdata install" || true
  33. # Properly mark the install type
  34. cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF
  35. INSTALL_TYPE='manual-static'
  36. PREBUILT_ARCH='${BUILDARCH}'
  37. EOF
  38. # Remove the netdata.conf file from the tree. It has hard-coded sensible defaults builtin.
  39. run rm -f "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
  40. # Ensure the netdata binary is in fact statically linked
  41. if run readelf -l "${NETDATA_INSTALL_PATH}"/bin/netdata | grep 'INTERP'; then
  42. printf >&2 "Ooops. %s is not a statically linked binary!\n" "${NETDATA_INSTALL_PATH}"/bin/netdata
  43. ldd "${NETDATA_INSTALL_PATH}"/bin/netdata
  44. exit 1
  45. fi
  46. # shellcheck disable=SC2015
  47. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true