diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-09 08:36:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-09 08:36:07 +0000 |
commit | e8c44275b9a1937b5948010a042294d580d36d7c (patch) | |
tree | e87c73e25556c3c9d5442f5ca4ba0cf46c64ec70 /packaging/cmake | |
parent | Adding upstream version 1.47.5. (diff) | |
download | netdata-e8c44275b9a1937b5948010a042294d580d36d7c.tar.xz netdata-e8c44275b9a1937b5948010a042294d580d36d7c.zip |
Adding upstream version 2.0.0.upstream/2.0.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/cmake')
-rw-r--r-- | packaging/cmake/Modules/NetdataDashboard.cmake | 85 | ||||
-rw-r--r-- | packaging/cmake/Modules/NetdataEBPFCORE.cmake | 4 | ||||
-rw-r--r-- | packaging/cmake/Modules/NetdataEBPFLegacy.cmake | 8 | ||||
-rw-r--r-- | packaging/cmake/Modules/NetdataJSONC.cmake | 2 | ||||
-rw-r--r-- | packaging/cmake/Modules/NetdataLibBPF.cmake | 2 | ||||
-rw-r--r-- | packaging/cmake/Modules/NetdataUtil.cmake | 75 | ||||
-rw-r--r-- | packaging/cmake/Modules/Packaging.cmake | 45 | ||||
-rw-r--r-- | packaging/cmake/config.cmake.h.in | 15 | ||||
-rwxr-xr-x | packaging/cmake/pkg-files/deb/dashboard/postinst | 11 | ||||
-rwxr-xr-x | packaging/cmake/pkg-files/deb/dashboard/postrm | 17 | ||||
-rwxr-xr-x | packaging/cmake/pkg-files/deb/dashboard/preinst | 11 | ||||
-rwxr-xr-x | packaging/cmake/pkg-files/deb/netdata/postinst | 4 | ||||
-rwxr-xr-x | packaging/cmake/pkg-files/deb/netdata/postrm | 8 |
13 files changed, 258 insertions, 29 deletions
diff --git a/packaging/cmake/Modules/NetdataDashboard.cmake b/packaging/cmake/Modules/NetdataDashboard.cmake new file mode 100644 index 00000000..070ce18e --- /dev/null +++ b/packaging/cmake/Modules/NetdataDashboard.cmake @@ -0,0 +1,85 @@ +# CMake module to handle fetching and installing the dashboard code +# +# Copyright (c) 2024 Netdata Inc. +# SPDX-License-Identifier: GPL-3.0-or-later + +include(NetdataUtil) + +function(handle_braindead_versioning_insanity prefix) + if(IS_DIRECTORY "${prefix}/v2" AND NOT IS_DIRECTORY "${prefix}/v3") + message(STATUS " Fixing incorrectly versioned paths generated by poorly written CI") + file(RENAME "${prefix}/v2" "${prefix}/v3") + + if(IS_DIRECTORY "${prefix}/v3" AND NOT IS_DIRECTORY "${prefix}/v2") + message(STATUS " Fixing incorrectly versioned paths generated by poorly written CI -- Done") + else() + message(FATAL_ERROR "Failed to fix incorrectly versioned paths") + endif() + endif() +endfunction() + +# Bundle the dashboard code for inclusion during install. +# +# This is unfortunately complicated due to how we need to handle the +# generation of the CMakeLists file for the dashboard code. +function(bundle_dashboard) + include(ExternalProject) + + set(dashboard_src_dir "${CMAKE_BINARY_DIR}/dashboard-src") + set(dashboard_src_prefix "${dashboard_src_dir}/dist/agent") + set(dashboard_bin_dir "${CMAKE_BINARY_DIR}/dashboard-bin") + set(DASHBOARD_URL "https://app.netdata.cloud/agent.tar.gz" CACHE STRING + "URL used to fetch the local agent dashboard code") + + message(STATUS "Preparing local agent dashboard code") + + message(STATUS " Fetching ${DASHBOARD_URL}") + file(DOWNLOAD + "${DASHBOARD_URL}" + "${CMAKE_BINARY_DIR}/dashboard.tar.gz" + TIMEOUT 180 + STATUS fetch_status) + + list(GET fetch_status 0 result) + + if(result) + message(FATAL_ERROR "Failed to fetch dashboard code") + else() + message(STATUS " Fetching ${DASHBOARD_URL} -- Done") + endif() + + message(STATUS " Extracting dashboard code") + extract_gzipped_tarball( + "${CMAKE_BINARY_DIR}/dashboard.tar.gz" + "${dashboard_src_dir}" + ) + message(STATUS " Extracting dashboard code -- Done") + + handle_braindead_versioning_insanity("${dashboard_src_prefix}") + + message(STATUS " Generating CMakeLists.txt file for dashboard code") + set(rules "") + + subdirlist(dash_dirs "${dashboard_src_prefix}") + + foreach(dir IN LISTS dash_dirs) + file(GLOB files + LIST_DIRECTORIES FALSE + RELATIVE "${dashboard_src_dir}" + "${dashboard_src_prefix}/${dir}/*") + + set(rules "${rules}install(FILES ${files} COMPONENT dashboard DESTINATION ${WEB_DEST}/${dir})\n") + endforeach() + + file(GLOB files + LIST_DIRECTORIES FALSE + RELATIVE "${dashboard_src_dir}" + "${dashboard_src_prefix}/*") + + set(rules "${rules}install(FILES ${files} COMPONENT dashboard DESTINATION ${WEB_DEST})\n") + + file(WRITE "${dashboard_src_dir}/CMakeLists.txt" "${rules}") + message(STATUS " Generating CMakeLists.txt file for dashboard code -- Done") + add_subdirectory("${dashboard_src_dir}" "${dashboard_bin_dir}") + message(STATUS "Preparing local agent dashboard code -- Done") +endfunction() diff --git a/packaging/cmake/Modules/NetdataEBPFCORE.cmake b/packaging/cmake/Modules/NetdataEBPFCORE.cmake index f4c918bf..bf98ce58 100644 --- a/packaging/cmake/Modules/NetdataEBPFCORE.cmake +++ b/packaging/cmake/Modules/NetdataEBPFCORE.cmake @@ -11,8 +11,8 @@ set(ebpf-co-re_SOURCE_DIR "${CMAKE_BINARY_DIR}/ebpf-co-re") function(netdata_fetch_ebpf_co_re) ExternalProject_Add( ebpf-co-re - URL https://github.com/netdata/ebpf-co-re/releases/download/v1.4.5.1/netdata-ebpf-co-re-glibc-v1.4.5.1.tar.xz - URL_HASH SHA256=10d49602c873932a4e0a3717a4af2137434b480d0170c2fb000ec70ae02f6e30 + URL https://github.com/netdata/ebpf-co-re/releases/download/v1.5.0/netdata-ebpf-co-re-glibc-v1.5.0.tar.xz + URL_HASH SHA256=9585a5a48853f70efa51c48f57df34b4e47b1af56eaaef731f57525ebd76b90c SOURCE_DIR "${ebpf-co-re_SOURCE_DIR}" CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/packaging/cmake/Modules/NetdataEBPFLegacy.cmake b/packaging/cmake/Modules/NetdataEBPFLegacy.cmake index 12dfce48..251ef464 100644 --- a/packaging/cmake/Modules/NetdataEBPFLegacy.cmake +++ b/packaging/cmake/Modules/NetdataEBPFLegacy.cmake @@ -20,19 +20,19 @@ function(netdata_fetch_legacy_ebpf_code) endif() if(need_static) - set(_hash 1c0c8f1177514e9e21a23c28841406595e57b7cfacd93746ff2d6b25987b94a6) + set(_hash ca0c6186b5c9c4640f8ba13ea375b66882203e8ca831a2e6e5e4e039b37f277a) set(_libc "static") elseif(_libc STREQUAL "glibc") - set(_hash e365a76a2bb25190f1d91e4dea2cfc5ff5db63b5238fbfbc89f72755cf85a12c) + set(_hash d3027685e15fdb6406fd36faf45287d79534d40601d388aca5ab87e90959846d) elseif(_libc STREQUAL "musl") - set(_hash ec14dcdfa29d4fba1cea6763740b9d37683515bde88a1a29b6e7c70ce01a604d) + set(_hash e2268ca1fa012e87d4d3d588e01b3a2389ad8a4b1c878508f6226ce1dad34acf) else() message(FATAL_ERROR "Could not determine libc implementation, unable to install eBPF legacy code.") endif() ExternalProject_Add( ebpf-code-legacy - URL https://github.com/netdata/kernel-collector/releases/download/v1.4.5.1/netdata-kernel-collector-${_libc}-v1.4.5.1.tar.xz + URL https://github.com/netdata/kernel-collector/releases/download/v1.5.0/netdata-kernel-collector-${_libc}-v1.5.0.tar.xz URL_HASH SHA256=${_hash} SOURCE_DIR "${ebpf-legacy_SOURCE_DIR}" CONFIGURE_COMMAND "" diff --git a/packaging/cmake/Modules/NetdataJSONC.cmake b/packaging/cmake/Modules/NetdataJSONC.cmake index 89ec7026..db18c14b 100644 --- a/packaging/cmake/Modules/NetdataJSONC.cmake +++ b/packaging/cmake/Modules/NetdataJSONC.cmake @@ -71,7 +71,7 @@ endfunction() # NETDATA_JSONC_* variables for later use. macro(netdata_detect_jsonc) if(NOT ENABLE_BUNDLED_JSONC) - pkg_check_modules(JSONC json-c) + pkg_check_modules(JSONC json-c>=0.14) endif() if(NOT JSONC_FOUND) diff --git a/packaging/cmake/Modules/NetdataLibBPF.cmake b/packaging/cmake/Modules/NetdataLibBPF.cmake index 9c3bf6d2..bc41e533 100644 --- a/packaging/cmake/Modules/NetdataLibBPF.cmake +++ b/packaging/cmake/Modules/NetdataLibBPF.cmake @@ -31,7 +31,7 @@ function(netdata_bundle_libbpf) if(USE_LEGACY_LIBBPF) set(_libbpf_tag 673424c56127bb556e64095f41fd60c26f9083ec) # v0.0.9_netdata-1 else() - set(_libbpf_tag 6923eb970e22682eaedff79f5be4f9934b99cf50) # v1.4.5p_netdata + set(_libbpf_tag ad7c3a4266bf5ce301a5691eb7b405dbb27c7f3d) # v1.5.0p_netdata endif() if(DEFINED BUILD_SHARED_LIBS) diff --git a/packaging/cmake/Modules/NetdataUtil.cmake b/packaging/cmake/Modules/NetdataUtil.cmake index c6a13309..0c1d803e 100644 --- a/packaging/cmake/Modules/NetdataUtil.cmake +++ b/packaging/cmake/Modules/NetdataUtil.cmake @@ -144,3 +144,78 @@ function(netdata_identify_libc _libc_name) set(${_libc_name} ${_ND_DETECTED_LIBC} PARENT_SCOPE) endif() endfunction() + +# Extract a tar archive. +# +# This will use CMake’s native support if available, but will still +# fall back cleanly if CMake is too old. +function(extract_gzipped_tarball tarball target) + if(CMAKE_VERSION VERSION_LESS 3.18) + find_program(TAR NAMES tar bsdtar DOC "TAR archive program") + + if(TAR STREQUAL "TAR-NOTFOUND") + message(FATAL_ERROR "Unable to find tar command") + endif() + + find_program(GZIP NAMES gzip DOC "GZIP compression program") + + if(GZIP STREQUAL "GZIP-NOTFOUND") + message(FATAL_ERROR "Unable to find gzip command") + endif() + + file(MAKE_DIRECTORY "${target}") + execute_process(COMMAND tar -x -z -f "${tarball}" -C "${target}" + RESULT_VARIABLE result) + + if(result) + message(FATAL_ERROR "Failed to extract ${tarball}") + endif() + else() + file(ARCHIVE_EXTRACT + INPUT "${tarball}" + DESTINATION "${target}") + endif() +endfunction() + +# Get a recursive list of all sub-directories of the specified directory, +# relative to that directory. +function(subdirlist result curdir) + file(GLOB_RECURSE children + LIST_DIRECTORIES TRUE + RELATIVE ${curdir} + ${curdir}/*) + + set(dirlist "") + + foreach(child ${children}) + if(IS_DIRECTORY ${curdir}/${child}) + list(APPEND dirlist ${child}) + endif() + endforeach() + + set(${result} ${dirlist} PARENT_SCOPE) +endfunction() + +# Precompile python code in the specified directory relative to the +# CMake install prefix at install time. +# This must be called _after_ the install directive for the python code +# in the specified directory +function(precompile_python dir component) + find_package(Python3) + + if(NOT ${Python3_Interpreter_FOUND}) + message(STATUS "Could not find Python3, skipping precompilation of Python code.") + return() + endif() + + set(prefix [=[${CMAKE_INSTALL_PREFIX}]=]) + + install( + CODE "message(STATUS \"Precompiling Python3 code in ${prefix}/${dir}\")" + COMPONENT ${component} + ) + install( + CODE "execute_process(COMMAND ${Python3_Interpreter} -O -m compileall -j0 -o2 ${prefix}/${dir} WORKING_DIRECTORY ${prefix}/${dir})" + COMPONENT ${component} + ) +endfunction() diff --git a/packaging/cmake/Modules/Packaging.cmake b/packaging/cmake/Modules/Packaging.cmake index 663dbe27..92960ca2 100644 --- a/packaging/cmake/Modules/Packaging.cmake +++ b/packaging/cmake/Modules/Packaging.cmake @@ -63,8 +63,17 @@ netdata-plugin-network-viewer") set(CPACK_DEBIAN_NETDATA_PACKAGE_CONFLICTS "netdata-core, netdata-plugins-bash, netdata-plugins-python, netdata-web") -list(APPEND _main_deps "netdata-plugin-chartsd") -list(APPEND _main_deps "netdata-plugin-pythond") +if(ENABLE_DASHBOARD) + list(APPEND _main_deps "netdata-dashboard") +endif() + +if(ENABLE_PLUGIN_CHARTS) + list(APPEND _main_deps "netdata-plugin-chartsd") +endif() + +if(ENABLE_PLUGIN_PYTHON) + list(APPEND _main_deps "netdata-plugin-pythond") +endif() if(ENABLE_PLUGIN_APPS) list(APPEND _main_deps "netdata-plugin-apps") @@ -105,6 +114,27 @@ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA set(CPACK_DEBIAN_NETDATA_DEBUGINFO_PACKAGE On) # +# dashboard +# + +set(CPACK_COMPONENT_DASHBOARD_DEPENDS "netdata") +set(CPACK_COMPONENT_DASHBOARD_DESCRIPTION + "The local dashboard for the Netdata Agent. + This allows access to the dashboard on the local node without internet access.") + +set(CPACK_DEBIAN_DASHBOARD_PACKAGE_NAME "netdata-dashboard") +set(CPACK_DEBIAN_DASHBOARD_PACKAGE_SECTION "net") +set(CPACK_DEBIAN_DASHBOARD_PACKAGE_CONFLICTS "netdata (<< ${CPACK_PACKAGE_VERSION})") +set(CPACK_DEBIAN_DASHBOARD_PACKAGE_PREDEPENDS "adduser") + +set(CPACK_DEBIAN_DASHBOARD_PACKAGE_CONTROL_EXTRA + "${PKG_FILES_PATH}/deb/plugin-apps/preinst" + "${PKG_FILES_PATH}/deb/plugin-apps/postinst" + "${PKG_FILES_PATH}/deb/plugin-apps/postrm") + +set(CPACK_DEBIAN_DASHBOARD_DEBUGINFO_PACKAGE Off) + +# # apps.plugin # @@ -434,10 +464,15 @@ set(CPACK_DEBIAN_PLUGIN-XENSTAT_DEBUGINFO_PACKAGE On) # list(APPEND CPACK_COMPONENTS_ALL "netdata") +if(ENABLE_DASHBOARD) + list(APPEND CPACK_COMPONENTS_ALL "dashboard") +endif() if(ENABLE_PLUGIN_APPS) list(APPEND CPACK_COMPONENTS_ALL "plugin-apps") endif() -list(APPEND CPACK_COMPONENTS_ALL "plugin-chartsd") +if(ENABLE_PLUGIN_CHARTS) + list(APPEND CPACK_COMPONENTS_ALL "plugin-chartsd") +endif() if(ENABLE_PLUGIN_CUPS) list(APPEND CPACK_COMPONENTS_ALL "plugin-cups") endif() @@ -465,7 +500,9 @@ endif() if(ENABLE_PLUGIN_PERF) list(APPEND CPACK_COMPONENTS_ALL "plugin-perf") endif() -list(APPEND CPACK_COMPONENTS_ALL "plugin-pythond") +if(ENABLE_PLUGIN_PYTHON) + list(APPEND CPACK_COMPONENTS_ALL "plugin-pythond") +endif() if(ENABLE_PLUGIN_SLABINFO) list(APPEND CPACK_COMPONENTS_ALL "plugin-slabinfo") endif() diff --git a/packaging/cmake/config.cmake.h.in b/packaging/cmake/config.cmake.h.in index 57d03269..0ea6ddd2 100644 --- a/packaging/cmake/config.cmake.h.in +++ b/packaging/cmake/config.cmake.h.in @@ -67,6 +67,12 @@ #cmakedefine HAVE_GETPRIORITY #cmakedefine HAVE_SETENV #cmakedefine HAVE_DLSYM +#cmakedefine HAVE_LIBCURL + +#cmakedefine HAVE_ARC4RANDOM_BUF +#cmakedefine HAVE_ARC4RANDOM_UNIFORM +#cmakedefine HAVE_RAND_S +#cmakedefine HAVE_GETRANDOM #cmakedefine HAVE_BACKTRACE #cmakedefine HAVE_CLOSE_RANGE @@ -103,14 +109,10 @@ // enabled features -#cmakedefine ENABLE_OPENSSL -#cmakedefine ENABLE_CLOUD -#cmakedefine ENABLE_ACLK #cmakedefine ENABLE_ML #cmakedefine ENABLE_EXPORTING_MONGODB #cmakedefine ENABLE_H2O #cmakedefine ENABLE_DBENGINE -#cmakedefine ENABLE_HTTPS #cmakedefine ENABLE_LZ4 #cmakedefine ENABLE_ZSTD #cmakedefine ENABLE_BROTLI @@ -172,6 +174,10 @@ #cmakedefine HAVE_LIBYAML #cmakedefine HAVE_LIBMNL +#cmakedefine HAVE_WEL +#cmakedefine HAVE_ETW +#cmakedefine RUN_UNDER_CLION + // /* Enable GNU extensions on systems that have them. */ // #ifndef _GNU_SOURCE // # define _GNU_SOURCE 1 @@ -182,7 +188,6 @@ // #cmakedefine ENABLE_PROMETHEUS_REMOTE_WRITE // /* NSA spy stuff */ -// #define ENABLE_HTTPS 1 // #cmakedefine01 HAVE_X509_VERIFY_PARAM_set1_host #define HAVE_CRYPTO diff --git a/packaging/cmake/pkg-files/deb/dashboard/postinst b/packaging/cmake/pkg-files/deb/dashboard/postinst new file mode 100755 index 00000000..320a649d --- /dev/null +++ b/packaging/cmake/pkg-files/deb/dashboard/postinst @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +case "$1" in + configure|reconfigure) + if ! dpkg-statoverride --list /usr/share/netdata/www > /dev/null 2>&1; then + dpkg-statoverride --update --add root netdata 0755 /usr/share/netdata/www + fi + ;; +esac diff --git a/packaging/cmake/pkg-files/deb/dashboard/postrm b/packaging/cmake/pkg-files/deb/dashboard/postrm new file mode 100755 index 00000000..85438ad1 --- /dev/null +++ b/packaging/cmake/pkg-files/deb/dashboard/postrm @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +case "$1" in + remove) ;; + + purge) + if dpkg-statoverride --list | grep -qw /var/lib/netdata/www; then + dpkg-statoverride --remove /var/lib/netdata/www + fi + + if dpkg-statoverride --list | grep -qw /usr/share/netdata/www; then + dpkg-statoverride --remove /usr/share/netdata/www + fi + ;; +esac diff --git a/packaging/cmake/pkg-files/deb/dashboard/preinst b/packaging/cmake/pkg-files/deb/dashboard/preinst new file mode 100755 index 00000000..57615ec0 --- /dev/null +++ b/packaging/cmake/pkg-files/deb/dashboard/preinst @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +case "$1" in + install) + if ! getent group netdata > /dev/null; then + addgroup --quiet --system netdata + fi + ;; +esac diff --git a/packaging/cmake/pkg-files/deb/netdata/postinst b/packaging/cmake/pkg-files/deb/netdata/postinst index 97593c23..7d2f0690 100755 --- a/packaging/cmake/pkg-files/deb/netdata/postinst +++ b/packaging/cmake/pkg-files/deb/netdata/postinst @@ -20,10 +20,6 @@ case "$1" in dpkg-statoverride --update --add netdata adm 02750 /var/log/netdata fi - if ! dpkg-statoverride --list /usr/share/netdata/www > /dev/null 2>&1; then - dpkg-statoverride --update --add root netdata 0755 /usr/share/netdata/www - fi - dpkg-statoverride --force --update --add root netdata 0775 /var/lib/netdata/registry > /dev/null 2>&1 grep /usr/libexec/netdata /var/lib/dpkg/info/netdata.list | xargs -n 30 chown root:netdata diff --git a/packaging/cmake/pkg-files/deb/netdata/postrm b/packaging/cmake/pkg-files/deb/netdata/postrm index 7a636863..daf28b74 100755 --- a/packaging/cmake/pkg-files/deb/netdata/postrm +++ b/packaging/cmake/pkg-files/deb/netdata/postrm @@ -10,14 +10,6 @@ case "$1" in dpkg-statoverride --remove /var/cache/netdata fi - if dpkg-statoverride --list | grep -qw /var/lib/netdata/www; then - dpkg-statoverride --remove /var/lib/netdata/www - fi - - if dpkg-statoverride --list | grep -qw /usr/share/netdata/www; then - dpkg-statoverride --remove /usr/share/netdata/www - fi - if dpkg-statoverride --list | grep -qw /var/lib/netdata/registry; then dpkg-statoverride --remove /var/lib/netdata/registry fi |