summaryrefslogtreecommitdiffstats
path: root/packaging/cmake/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/cmake/Modules')
-rw-r--r--packaging/cmake/Modules/NetdataDashboard.cmake85
-rw-r--r--packaging/cmake/Modules/NetdataEBPFCORE.cmake4
-rw-r--r--packaging/cmake/Modules/NetdataEBPFLegacy.cmake8
-rw-r--r--packaging/cmake/Modules/NetdataJSONC.cmake2
-rw-r--r--packaging/cmake/Modules/NetdataLibBPF.cmake2
-rw-r--r--packaging/cmake/Modules/NetdataUtil.cmake75
-rw-r--r--packaging/cmake/Modules/Packaging.cmake45
7 files changed, 209 insertions, 12 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()