70-netdata-git.install.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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="-static -O2 -I/openssl-static/include -pipe"
  8. else
  9. export CFLAGS="-static -O1 -pipe -ggdb -Wall -Wextra -Wformat-signedness -fstack-protector-all -D_FORTIFY_SOURCE=2 -DNETDATA_INTERNAL_CHECKS=1 -I/openssl-static/include"
  10. fi
  11. export LDFLAGS="-static -L/openssl-static/lib"
  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_PATH="/openssl-static/lib/pkgconfig"
  18. # Set correct CMake flags for building against non-System OpenSSL
  19. # See: https://github.com/warmcat/libwebsockets/blob/master/READMEs/README.build.md
  20. 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"
  21. run ./netdata-installer.sh \
  22. --install-prefix "${NETDATA_INSTALL_PARENT}" \
  23. --dont-wait \
  24. --dont-start-it \
  25. --require-cloud \
  26. --use-system-protobuf \
  27. --dont-scrub-cflags-even-though-it-may-break-things \
  28. --one-time-build
  29. # shellcheck disable=SC2015
  30. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Finishing netdata install" || true
  31. # Properly mark the install type
  32. cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF
  33. INSTALL_TYPE='manual-static'
  34. PREBUILT_ARCH='${BUILDARCH}'
  35. EOF
  36. # Remove the netdata.conf file from the tree. It has hard-coded sensible defaults builtin.
  37. run rm -f "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
  38. # Ensure the netdata binary is in fact statically linked
  39. if run readelf -l "${NETDATA_INSTALL_PATH}"/bin/netdata | grep 'INTERP'; then
  40. printf >&2 "Ooops. %s is not a statically linked binary!\n" "${NETDATA_INSTALL_PATH}"/bin/netdata
  41. ldd "${NETDATA_INSTALL_PATH}"/bin/netdata
  42. exit 1
  43. fi
  44. # shellcheck disable=SC2015
  45. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true