Skip to content

Commit

Permalink
Add Sentry support to new CPack packages. (#17627)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferroin committed May 10, 2024
1 parent d42b9c6 commit f8ed61e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ endif()

set(NETDATA_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}.${FIELD_TWEAK})

if(FIELD_DESCR STREQUAL "N/A")
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH})
else()
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}-${FIELD_TWEAK}-${FIELD_DESCR})
endif()

#
# project
#
Expand Down
23 changes: 23 additions & 0 deletions packaging/build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,31 @@ case "${PKG_TYPE}" in
*) echo "Unrecognized package type ${PKG_TYPE}." ; exit 1 ;;
esac

if [ "${ENABLE_SENTRY}" = "true" ]; then
if [ -z "${SENTRY_DSN}" ]; then
echo "ERROR: Sentry enabled but no DSN specified, exiting."
exit 1
fi

add_cmake_option ENABLE_SENTRY On
add_cmake_option NETDATA_SENTRY_ENVIRONMENT "${RELEASE_PIPELINE:-Unknown}"
add_cmake_option NETDATA_SENTRY_DIST "${BUILD_DESTINATION:-Unknown}"
add_cmake_option NETDATA_SENTRY_DSN "${SENTRY_DSN}"

if [ -n "${VERSION}" ]; then
add_cmake_option NETDATA_SENTRY_RELEASE "${VERSION}"
fi
else
add_cmake_option ENABLE_SENTRY Off
fi

# shellcheck disable=SC2086
cmake ${CMAKE_ARGS}
cmake --build "${BUILD_DIR}" --parallel "$(nproc)"

if [ "${ENABLE_SENTRY}" = "true" ] && [ "${UPLOAD_SENTRY}" = "true" ]; then
sentry-cli debug-files upload -o netdata-inc -p netdata-agent --force-foreground --log-level=debug --wait --include-sources build/netdata
fi

cd "${BUILD_DIR}" || exit 1
cpack -V -G "${PKG_TYPE}"
4 changes: 4 additions & 0 deletions packaging/cmake/Modules/NetdataSentry.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function(netdata_bundle_sentry)
set(SENTRY_BACKEND "breakpad")
set(SENTRY_BUILD_SHARED_LIBS OFF)

if(NOT DEFINED NETDATA_SENTRY_RELEASE)
set(NETDATA_SENTRY_RELEASE "${CPACK_PACKAGE_VERSION}")
endif()

FetchContent_Declare(
sentry
GIT_REPOSITORY https://github.com/getsentry/sentry-native.git
Expand Down
6 changes: 0 additions & 6 deletions packaging/cmake/Modules/Packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ set(CPACK_DEBIAN_DEBUGINFO_PACKAGE NO)

set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)

if(FIELD_DESCR STREQUAL "N/A")
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH})
else()
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}-${FIELD_TWEAK}-${FIELD_DESCR})
endif()

set(CPACK_PACKAGING_INSTALL_PREFIX "/")

set(CPACK_PACKAGE_VENDOR "Netdata Inc.")
Expand Down

0 comments on commit f8ed61e

Please sign in to comment.