build-package.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/sh
  2. #
  3. # Invoked by the package builder images to actually build native packages.
  4. set -e
  5. PKG_TYPE="${1}"
  6. BUILD_DIR="${2}"
  7. SCRIPT_SOURCE="$(
  8. self=${0}
  9. while [ -L "${self}" ]
  10. do
  11. cd "${self%/*}" || exit 1
  12. self=$(readlink "${self}")
  13. done
  14. cd "${self%/*}" || exit 1
  15. echo "$(pwd -P)/${self##*/}"
  16. )"
  17. SOURCE_DIR="$(dirname "$(dirname "${SCRIPT_SOURCE}")")"
  18. CMAKE_ARGS="-S ${SOURCE_DIR} -B ${BUILD_DIR}"
  19. add_cmake_option() {
  20. CMAKE_ARGS="${CMAKE_ARGS} -D${1}=${2}"
  21. }
  22. add_cmake_option CMAKE_BUILD_TYPE RelWithDebInfo
  23. add_cmake_option CMAKE_INSTALL_PREFIX /
  24. add_cmake_option ENABLE_DASHBOARD on
  25. add_cmake_option ENABLE_DBENGINE On
  26. add_cmake_option ENABLE_H2O On
  27. add_cmake_option ENABLE_ML On
  28. add_cmake_option ENABLE_PLUGIN_APPS On
  29. add_cmake_option ENABLE_PLUGIN_CGROUP_NETWORK On
  30. add_cmake_option ENABLE_PLUGIN_DEBUGFS On
  31. add_cmake_option ENABLE_PLUGIN_FREEIPMI On
  32. add_cmake_option ENABLE_PLUGIN_GO On
  33. add_cmake_option ENABLE_PLUGIN_PYTHON On
  34. add_cmake_option ENABLE_PLUGIN_CHARTS On
  35. add_cmake_option ENABLE_PLUGIN_LOCAL_LISTENERS On
  36. add_cmake_option ENABLE_PLUGIN_NFACCT On
  37. add_cmake_option ENABLE_PLUGIN_PERF On
  38. add_cmake_option ENABLE_PLUGIN_SLABINFO On
  39. add_cmake_option ENABLE_PLUGIN_SYSTEMD_JOURNAL On
  40. add_cmake_option ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE On
  41. add_cmake_option ENABLE_EXPORTER_MONGODB On
  42. add_cmake_option ENABLE_BUNDLED_PROTOBUF Off
  43. add_cmake_option ENABLE_BUNDLED_JSONC Off
  44. add_cmake_option ENABLE_BUNDLED_YAML Off
  45. add_cmake_option BUILD_FOR_PACKAGING On
  46. case "${PKG_TYPE}" in
  47. DEB)
  48. case "$(dpkg-architecture -q DEB_TARGET_ARCH)" in
  49. amd64)
  50. add_cmake_option ENABLE_PLUGIN_XENSTAT On
  51. add_cmake_option ENABLE_PLUGIN_EBPF On
  52. ;;
  53. arm64)
  54. add_cmake_option ENABLE_PLUGIN_XENSTAT On
  55. add_cmake_option ENABLE_PLUGIN_EBPF Off
  56. ;;
  57. *)
  58. add_cmake_option ENABLE_PLUGIN_XENSTAT Off
  59. add_cmake_option ENABLE_PLUGIN_EBPF Off
  60. ;;
  61. esac
  62. ;;
  63. RPM) ;;
  64. *) echo "Unrecognized package type ${PKG_TYPE}." ; exit 1 ;;
  65. esac
  66. if [ "${ENABLE_SENTRY}" = "true" ]; then
  67. if [ -z "${SENTRY_DSN}" ]; then
  68. echo "ERROR: Sentry enabled but no DSN specified, exiting."
  69. exit 1
  70. fi
  71. add_cmake_option ENABLE_SENTRY On
  72. add_cmake_option NETDATA_SENTRY_ENVIRONMENT "${RELEASE_PIPELINE:-Unknown}"
  73. add_cmake_option NETDATA_SENTRY_DIST "${BUILD_DESTINATION:-Unknown}"
  74. add_cmake_option NETDATA_SENTRY_DSN "${SENTRY_DSN}"
  75. else
  76. add_cmake_option ENABLE_SENTRY Off
  77. fi
  78. # shellcheck disable=SC2086
  79. cmake ${CMAKE_ARGS} -G Ninja
  80. cmake --build "${BUILD_DIR}" --parallel "$(nproc)" -- -k 1
  81. if [ "${ENABLE_SENTRY}" = "true" ] && [ "${UPLOAD_SENTRY}" = "true" ]; then
  82. sentry-cli debug-files upload -o netdata-inc -p netdata-agent --force-foreground --log-level=debug --wait --include-sources build/netdata
  83. fi
  84. cd "${BUILD_DIR}" || exit 1
  85. cpack -V -G "${PKG_TYPE}"