summaryrefslogtreecommitdiffstats
path: root/packaging/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/cmake')
-rw-r--r--packaging/cmake/Modules/NetdataCompilerFlags.cmake69
-rw-r--r--packaging/cmake/Modules/NetdataEBPFCORE.cmake27
-rw-r--r--packaging/cmake/Modules/NetdataEBPFLegacy.cmake48
-rw-r--r--packaging/cmake/Modules/NetdataFetchContentExtra.cmake14
-rw-r--r--packaging/cmake/Modules/NetdataGoTools.cmake6
-rw-r--r--packaging/cmake/Modules/NetdataJSONC.cmake108
-rw-r--r--packaging/cmake/Modules/NetdataLibBPF.cmake102
-rw-r--r--packaging/cmake/Modules/NetdataProtobuf.cmake194
-rw-r--r--packaging/cmake/Modules/NetdataSentry.cmake30
-rw-r--r--packaging/cmake/Modules/NetdataUtil.cmake146
-rw-r--r--packaging/cmake/Modules/NetdataVersion.cmake51
-rw-r--r--packaging/cmake/Modules/NetdataYAML.cmake10
-rw-r--r--packaging/cmake/Modules/Packaging.cmake503
-rw-r--r--packaging/cmake/config.cmake.h.in40
-rw-r--r--packaging/cmake/pkg-files/copyright10
-rwxr-xr-xpackaging/cmake/pkg-files/deb/ebpf-code-legacy/postinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/ebpf-code-legacy/preinst11
-rw-r--r--packaging/cmake/pkg-files/deb/netdata/conffiles5
-rw-r--r--packaging/cmake/pkg-files/deb/netdata/etc/default/netdata3
-rwxr-xr-xpackaging/cmake/pkg-files/deb/netdata/etc/init.d/netdata56
-rwxr-xr-xpackaging/cmake/pkg-files/deb/netdata/postinst53
-rwxr-xr-xpackaging/cmake/pkg-files/deb/netdata/postrm55
-rwxr-xr-xpackaging/cmake/pkg-files/deb/netdata/preinst26
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-apps/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-apps/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-chartsd/postinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-chartsd/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-cups/postinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-cups/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-debugfs/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-debugfs/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-ebpf/postinst12
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-ebpf/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-freeipmi/postinst12
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-freeipmi/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-go/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-go/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-logs-management/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-logs-management/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-network-viewer/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-network-viewer/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-nfacct/postinst12
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-nfacct/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-perf/postinst18
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-perf/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-pythond/postinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-pythond/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-slabinfo/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-slabinfo/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-systemd-journal/postinst15
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-systemd-journal/preinst11
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-xenstat/postinst12
-rwxr-xr-xpackaging/cmake/pkg-files/deb/plugin-xenstat/preinst11
53 files changed, 1795 insertions, 152 deletions
diff --git a/packaging/cmake/Modules/NetdataCompilerFlags.cmake b/packaging/cmake/Modules/NetdataCompilerFlags.cmake
index 894e244ce..28b43b4ec 100644
--- a/packaging/cmake/Modules/NetdataCompilerFlags.cmake
+++ b/packaging/cmake/Modules/NetdataCompilerFlags.cmake
@@ -20,30 +20,29 @@ endfunction()
#
# If the language flags already match the `match` argument, skip this flag.
# Otherwise, check for support for `flag` and if support is found, add it to
-# the language-specific `target` flag group.
-function(add_simple_extra_compiler_flag match flag target)
+# the compiler flags for the run.
+function(add_simple_extra_compiler_flag match flag)
set(CMAKE_REQUIRED_FLAGS "-Werror")
make_cpp_safe_name("${flag}" flag_name)
if(NOT ${CMAKE_C_FLAGS} MATCHES ${match})
check_c_compiler_flag("${flag}" HAVE_C_${flag_name})
- if(HAVE_C_${flag_name})
- set(${target}_C_FLAGS "${${target}_C_FLAGS} ${flag}" PARENT_SCOPE)
- endif()
endif()
if(NOT ${CMAKE_CXX_FLAGS} MATCHES ${match})
check_cxx_compiler_flag("${flag}" HAVE_CXX_${flag_name})
- if(HAVE_CXX_${flag_name})
- set(${target}_CXX_FLAGS "${${target}_CXX_FLAGS} ${flag}" PARENT_SCOPE)
- endif()
+ endif()
+
+ if(HAVE_C_${flag_name} AND HAVE_CXX_${flag_name})
+ add_compile_options("${flag}")
+ add_link_options("${flag}")
endif()
endfunction()
# Same as add_simple_extra_compiler_flag, but check for a second flag if the
# first one is unsupported.
-function(add_double_extra_compiler_flag match flag1 flag2 target)
+function(add_double_extra_compiler_flag match flag1 flag2)
set(CMAKE_REQUIRED_FLAGS "-Werror")
make_cpp_safe_name("${flag1}" flag1_name)
@@ -51,25 +50,53 @@ function(add_double_extra_compiler_flag match flag1 flag2 target)
if(NOT ${CMAKE_C_FLAGS} MATCHES ${match})
check_c_compiler_flag("${flag1}" HAVE_C_${flag1_name})
- if(HAVE_C_${flag1_name})
- set(${target}_C_FLAGS "${${target}_C_FLAGS} ${flag1}" PARENT_SCOPE)
- else()
+ if(NOT HAVE_C_${flag1_name})
check_c_compiler_flag("${flag2}" HAVE_C_${flag2_name})
- if(HAVE_C_${flag2_name})
- set(${target}_C_FLAGS "${${target}_C_FLAGS} ${flag2}" PARENT_SCOPE)
- endif()
endif()
endif()
if(NOT ${CMAKE_CXX_FLAGS} MATCHES ${match})
check_cxx_compiler_flag("${flag1}" HAVE_CXX_${flag1_name})
- if(HAVE_CXX_${flag1_name})
- set(${target}_CXX_FLAGS "${${target}_CXX_FLAGS} ${flag1}" PARENT_SCOPE)
- else()
+ if(NOT HAVE_CXX_${flag1_name})
check_cxx_compiler_flag("${flag2}" HAVE_CXX_${flag2_name})
- if(HAVE_CXX_${flag2_name})
- set(${target}_CXX_FLAGS "${${target}_CXX_FLAGS} ${flag2}" PARENT_SCOPE)
- endif()
endif()
endif()
+
+ if(HAVE_C_${flag1_name} AND HAVE_CXX_${flag1_name})
+ add_compile_options("${flag1}")
+ add_link_options("${flag1}")
+ elseif(HAVE_C_${flag2_name} AND HAVE_CXX${flag2_name})
+ add_compile_options("${flag2}")
+ add_link_options("${flag2}")
+ endif()
endfunction()
+
+if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ option(DISABLE_HARDENING "Disable adding extra compiler flags for hardening" TRUE)
+else()
+ option(DISABLE_HARDENING "Disable adding extra compiler flags for hardening" FALSE)
+endif()
+
+option(ENABLE_ADDRESS_SANITIZER "Build with address sanitizer enabled" False)
+mark_as_advanced(ENABLE_ADDRESS_SANITIZER)
+
+if(ENABLE_ADDRESS_SANITIZER)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
+endif()
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
+
+if(NOT ${DISABLE_HARDENING})
+ add_double_extra_compiler_flag("stack-protector" "-fstack-protector-strong" "-fstack-protector")
+ add_double_extra_compiler_flag("_FORTIFY_SOURCE" "-D_FORTIFY_SOURCE=3" "-D_FORTIFY_SOURCE=2")
+ add_simple_extra_compiler_flag("stack-clash-protection" "-fstack-clash-protection")
+ add_simple_extra_compiler_flag("-fcf-protection" "-fcf-protection=full")
+ add_simple_extra_compiler_flag("branch-protection" "-mbranch-protection=standard")
+endif()
+
+foreach(FLAG function-sections data-sections)
+ add_simple_extra_compiler_flag("${FLAG}" "-f${FLAG}")
+endforeach()
+
+add_simple_extra_compiler_flag("-Wbuiltin-macro-redefined" "-Wno-builtin-macro-redefined")
+add_simple_extra_compiler_flag("-fexecptions" "-fexceptions")
diff --git a/packaging/cmake/Modules/NetdataEBPFCORE.cmake b/packaging/cmake/Modules/NetdataEBPFCORE.cmake
new file mode 100644
index 000000000..936124dee
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataEBPFCORE.cmake
@@ -0,0 +1,27 @@
+# Handling for eBPF CO-RE files
+#
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+include(ExternalProject)
+
+set(ebpf-co-re_SOURCE_DIR "${CMAKE_BINARY_DIR}/ebpf-co-re")
+
+# Fetch and install our eBPF CO-RE files
+function(netdata_fetch_ebpf_co_re)
+ ExternalProject_Add(
+ ebpf-co-re
+ URL https://github.com/netdata/ebpf-co-re/releases/download/v1.4.3/netdata-ebpf-co-re-glibc-v1.4.3.tar.xz
+ URL_HASH SHA256=52a8cf65b4659d173ec3d9fb69315ba48c1f091d1882968748b37a8f7bf9f92d
+ SOURCE_DIR "${ebpf-co-re_SOURCE_DIR}"
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ EXCLUDE_FROM_ALL 1
+ )
+endfunction()
+
+function(netdata_add_ebpf_co_re_to_target _target)
+ add_dependencies(${_target} ebpf-co-re)
+ target_include_directories(${_target} BEFORE PRIVATE "${ebpf-co-re_SOURCE_DIR}")
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataEBPFLegacy.cmake b/packaging/cmake/Modules/NetdataEBPFLegacy.cmake
new file mode 100644
index 000000000..7658a0e94
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataEBPFLegacy.cmake
@@ -0,0 +1,48 @@
+# Handling for eBPF legacy programs
+#
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+include(ExternalProject)
+include(NetdataUtil)
+
+set(ebpf-legacy_SOURCE_DIR "${CMAKE_BINARY_DIR}/ebpf-legacy")
+set(ebpf-legacy_BUILD_DIR "${CMAKE_BINARY_DIR}/ebpf-legacy-build")
+
+# Fetch the legacy eBPF code.
+function(netdata_fetch_legacy_ebpf_code)
+ netdata_identify_libc(_libc)
+
+ if(DEFINED BUILD_SHARED_LIBS)
+ if(NOT BUILD_SHARED_LIBS)
+ set(need_static TRUE)
+ endif()
+ endif()
+
+ if(need_static)
+ set(_hash 73cfe6ceb0098447c2a016d8f9674ad8a80ba6dd61cfdd8646710a0dc5c52d9f)
+ set(_libc "static")
+ elseif(_libc STREQUAL "glibc")
+ set(_hash e9b89ff215c56f04249a2169bee15cdae6e61ef913468add258719e8afe6eac2)
+ elseif(_libc STREQUAL "musl")
+ set(_hash 1574e3bbdcac7dae534d783fa6fc6452268240d7477aefd87fadc4e7f705d48e)
+ 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.3/netdata-kernel-collector-${_libc}-v1.4.3.tar.xz
+ URL_HASH SHA256=${_hash}
+ SOURCE_DIR "${ebpf-legacy_SOURCE_DIR}"
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND sh -c "mkdir -p ${ebpf-legacy_BUILD_DIR}/ebpf.d && mv ${ebpf-legacy_SOURCE_DIR}/*netdata_ebpf_*.o ${ebpf-legacy_BUILD_DIR}/ebpf.d"
+ INSTALL_COMMAND ""
+ )
+endfunction()
+
+function(netdata_install_legacy_ebpf_code)
+ install(DIRECTORY ${ebpf-legacy_BUILD_DIR}/ebpf.d
+ DESTINATION usr/libexec/netdata/plugins.d
+ COMPONENT ebpf-code-legacy)
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataFetchContentExtra.cmake b/packaging/cmake/Modules/NetdataFetchContentExtra.cmake
index 1de1dcef9..cc70448de 100644
--- a/packaging/cmake/Modules/NetdataFetchContentExtra.cmake
+++ b/packaging/cmake/Modules/NetdataFetchContentExtra.cmake
@@ -25,3 +25,17 @@ macro(FetchContent_MakeAvailable_NoInstall name)
add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endmacro()
+
+# NETDATA_PROPAGATE_TOOLCHAIN_ARGS
+#
+# Defines a set of CMake flags to be passed to CMAKE_ARGS for
+# FetchContent_Declare and ExternalProject_Add to ensure that toolchain
+# configuration propagates correctly to sub-projects.
+#
+# This needs to be explicitly included for any sub-project that needs
+# to be built for the target system.
+set(NETDATA_PROPAGATE_TOOLCHAIN_ARGS
+ "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ $<$<BOOL:${CMAKE_C_COMPILER_TARGET}>:-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}
+ $<$<BOOL:${CMAKE_CXX_COMPILER_TARGET}>:-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}")
diff --git a/packaging/cmake/Modules/NetdataGoTools.cmake b/packaging/cmake/Modules/NetdataGoTools.cmake
index 9bb09cdc5..6526c8d7b 100644
--- a/packaging/cmake/Modules/NetdataGoTools.cmake
+++ b/packaging/cmake/Modules/NetdataGoTools.cmake
@@ -4,10 +4,10 @@
#
# SPDX-License-Identifier: GPL
-if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
- set(GO_LDFLAGS "-X github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo.Version=${NETDATA_VERSION}")
+if(CMAKE_BUILD_TYPE STREQUAL Debug)
+ set(GO_LDFLAGS "-X github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo.Version=${NETDATA_VERSION_STRING}")
else()
- set(GO_LDFLAGS "-w -s -X github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo.Version=${NETDATA_VERSION}")
+ set(GO_LDFLAGS "-w -s -X github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo.Version=${NETDATA_VERSION_STRING}")
endif()
# add_go_target: Add a new target that needs to be built using the Go toolchain.
diff --git a/packaging/cmake/Modules/NetdataJSONC.cmake b/packaging/cmake/Modules/NetdataJSONC.cmake
new file mode 100644
index 000000000..9bbb424e1
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataJSONC.cmake
@@ -0,0 +1,108 @@
+# Functions and macros for handling of JSON-C
+#
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Handle bundling of json-c.
+#
+# This pulls it in as a sub-project using FetchContent functionality.
+#
+# This needs to be a function and not a macro for variable scoping
+# reasons. All the things we care about from the sub-project are exposed
+# as targets, which are globally scoped and not function scoped.
+function(netdata_bundle_jsonc)
+ include(FetchContent)
+ include(NetdataFetchContentExtra)
+
+ message(STATUS "Preparing vendored copy of JSON-C")
+
+ if(ENABLE_BUNDLED_JSONC)
+ set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER)
+ endif()
+
+ set(FETCHCONTENT_FULLY_DISCONNECTED Off)
+
+ # JSON-C supports older versions of CMake than we do, so set
+ # the correct values for the few policies we actually need.
+ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
+
+ # JSON-C's build system does string comparisons against option
+ # values instead of treating them as booleans, so we need to use
+ # proper strings for option values instead of just setting them
+ # to true or false.
+ set(DISABLE_BSYMBOLIC ON)
+ set(DISABLE_WERROR ON)
+ set(DISABLE_EXTRA_LIBS ON)
+ set(BUILD_SHARED_LIBS OFF)
+ set(BUILD_STATIC_LIBS ON)
+ set(BUILD_APPS OFF)
+
+ FetchContent_Declare(json-c
+ GIT_REPOSITORY https://github.com/json-c/json-c
+ GIT_TAG b4c371fa0cbc4dcbaccc359ce9e957a22988fb34 # json-c-0.17-20230812
+ CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
+ )
+
+ FetchContent_MakeAvailable_NoInstall(json-c)
+
+ message(STATUS "Finished preparing vendored copy of JSON-C")
+endfunction()
+
+# Handle setup of json-c for the build.
+#
+# This will attempt to find json-c using pkg_check_modules. If it finds
+# a usable copy, that will be used. If not, it will bundle a vendored copy
+# as a sub-project.
+#
+# Irrespective of how json-c is to be included, library names,
+# include directories, and compile definitions will be specified in the
+# NETDATA_JSONC_* variables for later use.
+macro(netdata_detect_jsonc)
+ if(NOT ENABLE_BUNDLED_JSONC)
+ pkg_check_modules(JSONC json-c)
+ endif()
+
+ if(NOT JSONC_FOUND)
+ set(ENABLE_BUNDLED_JSONC True PARENT_SCOPE)
+ netdata_bundle_jsonc()
+ set(NETDATA_JSONC_LDFLAGS json-c)
+ set(NETDATA_JSONC_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/include)
+ get_target_property(NETDATA_JSONC_CFLAGS_OTHER json-c INTERFACE_COMPILE_DEFINITIONS)
+
+ if(NETDATA_JSONC_CFLAGS_OTHER STREQUAL NETDATA_JSONC_CFLAGS_OTHER-NOTFOUND)
+ set(NETDATA_JSONC_CFLAGS_OTHER "")
+ endif()
+
+ add_custom_command(
+ OUTPUT ${PROJECT_BINARY_DIR}/include/json-c
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/include
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${json-c_BINARY_DIR} ${PROJECT_BINARY_DIR}/include/json-c
+ COMMENT "Create compatibility symlink for vendored JSON-C headers"
+ DEPENDS json-c
+ )
+ add_custom_target(
+ json-c-compat-link
+ DEPENDS ${PROJECT_BINARY_DIR}/include/json-c
+ )
+ else()
+ set(NETDATA_JSONC_LDFLAGS ${JSONC_LDFLAGS})
+ set(NETDATA_JSONC_CFLAGS_OTHER ${JSONC_CFLAGS_OTHER})
+ set(NETDATA_JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIRS})
+ add_custom_target(json-c-compat-link)
+ endif()
+endmacro()
+
+# Add json-c as a public link dependency of the specified target.
+#
+# The specified target must already exist, and the netdata_detect_json-c
+# macro must have already been run at least once for this to work correctly.
+function(netdata_add_jsonc_to_target _target)
+ if(ENABLE_BUNDLED_JSONC)
+ target_include_directories(${_target} BEFORE PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
+ else()
+ target_include_directories(${_target} PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
+ endif()
+ target_compile_options(${_target} PUBLIC ${NETDATA_JSONC_CFLAGS_OTHER})
+ target_link_libraries(${_target} PUBLIC ${NETDATA_JSONC_LDFLAGS})
+ add_dependencies(${_target} json-c-compat-link)
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataLibBPF.cmake b/packaging/cmake/Modules/NetdataLibBPF.cmake
new file mode 100644
index 000000000..17a26a10f
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataLibBPF.cmake
@@ -0,0 +1,102 @@
+# Handling for libbpf (used by the eBPF plugin)
+#
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+include(ExternalProject)
+include(NetdataUtil)
+
+set(libbpf_SOURCE_DIR "${CMAKE_BINARY_DIR}/libbpf")
+
+# Check if the kernel is old enough that we need to use a legacy copy of eBPF.
+function(_need_legacy_libbpf _var)
+ if(FORCE_LEGACY_LIBBPF)
+ set(${_var} TRUE PARENT_SCOPE)
+ return()
+ endif()
+
+ netdata_detect_host_kernel_version()
+
+ if(HOST_KERNEL_VERSION VERSION_LESS "4.14.0")
+ set(${_var} TRUE PARENT_SCOPE)
+ else()
+ set(${_var} FALSE PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Prepare a vendored copy of libbpf
+function(netdata_bundle_libbpf)
+ _need_legacy_libbpf(USE_LEGACY_LIBBPF)
+
+ if(USE_LEGACY_LIBBPF)
+ set(_libbpf_tag 673424c56127bb556e64095f41fd60c26f9083ec) # v0.0.9_netdata-1
+ else()
+ set(_libbpf_tag 3d78a726c618560ad7fb03ceaf0fd03e8b2656b4) # v1.4.3p_netdata
+ endif()
+
+ if(DEFINED BUILD_SHARED_LIBS)
+ if(NOT BUILD_SHARED_LIBS)
+ set(need_static TRUE)
+ endif()
+ endif()
+
+ if(NOT need_static)
+ netdata_identify_libc(_libc)
+
+ string(REGEX MATCH "glibc|musl" _libc_supported "${_libc}")
+
+ if(NOT _libc_supported)
+ message(FATAL_ERROR "This system’s libc (detected: ${_libc}) is not not supported by the eBPF plugin.")
+ endif()
+ endif()
+
+ find_program(MAKE_COMMAND make)
+
+ if(MAKE_COMMAND STREQUAL MAKE_COMMAND-NOTFOUND)
+ message(FATAL_ERROR "GNU Make is required when building the eBPF plugin, but could not be found.")
+ endif()
+
+ pkg_check_modules(ELF REQUIRED libelf)
+ pkg_check_modules(ZLIB REQUIRED zlib)
+
+ set(_libbpf_lib_dir lib)
+
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(_libbpf_lib_dir lib64)
+ endif()
+
+ set(_libbpf_library "${libbpf_SOURCE_DIR}/usr/${_libbpf_lib_dir}/libbpf.a")
+
+ ExternalProject_Add(
+ libbpf
+ GIT_REPOSITORY https://github.com/netdata/libbpf.git
+ GIT_TAG ${_libbpf_tag}
+ SOURCE_DIR "${libbpf_SOURCE_DIR}"
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ${MAKE_COMMAND} -C src CC=${CMAKE_C_COMPILER} BUILD_STATIC_ONLY=1 OBJDIR=build/ DESTDIR=../ install
+ BUILD_IN_SOURCE 1
+ BUILD_BYPRODUCTS "${_libbpf_library}"
+ INSTALL_COMMAND ""
+ EXCLUDE_FROM_ALL 1
+ )
+
+ add_library(libbpf_library STATIC IMPORTED GLOBAL)
+ set_property(
+ TARGET libbpf_library
+ PROPERTY IMPORTED_LOCATION "${_libbpf_library}"
+ )
+ set_property(
+ TARGET libbpf_library
+ PROPERTY INTERFACE_LINK_LIBRARIES "${ELF_LIBRARIES};${ZLIB_LIBRARIES}"
+ )
+ set(NETDATA_LIBBPF_INCLUDE_DIRECTORIES "${libbpf_SOURCE_DIR}/usr/include;${libbpf_SOURCE_DIR}/include;${ELF_INCLUDE_DIRECTORIES};${ZLIB_INCLUDE_DIRECTORIES}" PARENT_SCOPE)
+ set(NETDATA_LIBBPF_COMPILE_OPTIONS "${ELF_CFLAGS_OTHER};${ZLIB_CFLAGS_OTHER}" PARENT_SCOPE)
+endfunction()
+
+# Add libbpf as a link dependency for the given target.
+function(netdata_add_libbpf_to_target _target)
+ target_link_libraries(${_target} PUBLIC libbpf_library)
+ target_include_directories(${_target} BEFORE PUBLIC "${NETDATA_LIBBPF_INCLUDE_DIRECTORIES}")
+ target_compile_options(${_target} PUBLIC "${NETDATA_LIBBPF_COMPILE_OPTIONS}")
+ add_dependencies(${_target} libbpf)
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataProtobuf.cmake b/packaging/cmake/Modules/NetdataProtobuf.cmake
index d4ae3aec6..c142d6566 100644
--- a/packaging/cmake/Modules/NetdataProtobuf.cmake
+++ b/packaging/cmake/Modules/NetdataProtobuf.cmake
@@ -3,52 +3,24 @@
# Copyright (c) 2024 Netdata Inc.
# SPDX-License-Identifier: GPL-3.0-or-later
-macro(netdata_protobuf_21_tags)
- set(PROTOBUF_TAG f0dc78d7e6e331b8c6bb2d5283e06aa26883ca7c) # v21.12
- set(NEED_ABSL False)
-endmacro()
-
-macro(netdata_protobuf_25_tags)
- set(PROTOBUF_TAG 4a2aef570deb2bfb8927426558701e8bfc26f2a4) # v25.3
- set(NEED_ABSL True)
- set(ABSL_TAG 2f9e432cce407ce0ae50676696666f33a77d42ac) # 20240116.1
-endmacro()
-
-# Determine what version of protobuf and abseil to bundle.
-#
-# This is unfortunately very complicated because we support systems
-# older than what Google officially supports for C++.
-macro(netdata_set_bundled_protobuf_tags)
- netdata_protobuf_21_tags()
-
- if(NOT USE_CXX_11)
- if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.3.1)
- netdata_protobuf_25_tags()
- endif()
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0.0)
- netdata_protobuf_25_tags()
- endif()
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
- netdata_protobuf_25_tags()
- endif()
- endif()
- endif()
-endmacro()
-
# Prepare a vendored copy of Protobuf for use with Netdata.
function(netdata_bundle_protobuf)
include(FetchContent)
include(NetdataFetchContentExtra)
- netdata_set_bundled_protobuf_tags()
+ set(PROTOBUF_TAG f0dc78d7e6e331b8c6bb2d5283e06aa26883ca7c) # v21.12
+ set(NEED_ABSL False)
+
+ if(CMAKE_CXX_STANDARD GREATER_EQUAL 14)
+ set(PROTOBUF_TAG 4a2aef570deb2bfb8927426558701e8bfc26f2a4) # v25.3
+ set(NEED_ABSL True)
+ set(ABSL_TAG 2f9e432cce407ce0ae50676696666f33a77d42ac) # 20240116.1
+ endif()
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER)
- string(REPLACE "-fsanitize=address" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
- string(REPLACE "-fsanitize=address" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ string(REPLACE "-fsanitize=address" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ string(REPLACE "-fsanitize=address" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# ignore debhelper
set(FETCHCONTENT_FULLY_DISCONNECTED Off)
@@ -56,11 +28,13 @@ function(netdata_bundle_protobuf)
if(NEED_ABSL)
set(ABSL_PROPAGATE_CXX_STD On)
set(ABSL_ENABLE_INSTALL Off)
+ set(BUILD_SHARED_LIBS Off)
message(STATUS "Preparing bundled Abseil (required by bundled Protobuf)")
FetchContent_Declare(absl
GIT_REPOSITORY https://github.com/abseil/abseil-cpp
GIT_TAG ${ABSL_TAG}
+ CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
FetchContent_MakeAvailable_NoInstall(absl)
message(STATUS "Finished preparing bundled Abseil")
@@ -75,102 +49,77 @@ function(netdata_bundle_protobuf)
FetchContent_Declare(protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG ${PROTOBUF_TAG}
+ CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
FetchContent_MakeAvailable_NoInstall(protobuf)
message(STATUS "Finished preparing bundled Protobuf.")
- set(BUNDLED_PROTOBUF True PARENT_SCOPE)
+ set(ENABLE_BUNDLED_PROTOBUF True PARENT_SCOPE)
endfunction()
# Handle detection of Protobuf
macro(netdata_detect_protobuf)
- if(NOT ENABLE_BUNDLED_PROTOBUF)
- if (NOT BUILD_SHARED_LIBS)
- set(Protobuf_USE_STATIC_LIBS On)
- endif()
-
- # The FindProtobuf CMake module shipped by upstream CMake is
- # broken for Protobuf version 22.0 and newer because it does
- # not correctly pull in the new Abseil dependencies. Protobuf
- # itself sometimes ships a CMake Package Configuration module
- # that _does_ work correctly, so use that in preference to the
- # Find module shipped with CMake.
- #
- # The code below works by first attempting to use find_package
- # in config mode, and then checking for the existence of the
- # target we actually use that gets defined by the protobuf
- # CMake Package Configuration Module to determine if that
- # worked. A bit of extra logic is required in the case of the
- # config mode working, because some systems ship compatibility
- # logic for the old FindProtobuf module while others do not.
- #
- # Upstream bug reference: https://gitlab.kitware.com/cmake/cmake/-/issues/24321
- find_package(Protobuf CONFIG)
-
- if(NOT TARGET protobuf::libprotobuf)
- message(STATUS "Could not find Protobuf using Config mode, falling back to Module mode")
- find_package(Protobuf REQUIRED)
+ if(OS_WINDOWS)
+ set(PROTOBUF_PROTOC_EXECUTABLE "$ENV{PROTOBUF_PROTOC_EXECUTABLE}")
+ if(NOT PROTOBUF_PROTOC_EXECUTABLE)
+ set(PROTOBUF_PROTOC_EXECUTABLE "/bin/protoc")
endif()
- endif()
+ set(PROTOBUF_CFLAGS_OTHER "")
+ set(PROTOBUF_INCLUDE_DIRS "")
+ set(PROTOBUF_LIBRARIES "-lprotobuf")
- if(TARGET protobuf::libprotobuf)
- if(NOT Protobuf_PROTOC_EXECUTABLE AND TARGET protobuf::protoc)
- get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
- IMPORTED_LOCATION_RELEASE)
- if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
- get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
- IMPORTED_LOCATION_RELWITHDEBINFO)
- endif()
- if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
- get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
- IMPORTED_LOCATION_MINSIZEREL)
- endif()
- if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
- get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
- IMPORTED_LOCATION_DEBUG)
+ set(ENABLE_PROTOBUF True)
+ set(HAVE_PROTOBUF True)
+ else()
+ if(NOT ENABLE_BUNDLED_PROTOBUF)
+ if (NOT BUILD_SHARED_LIBS)
+ set(Protobuf_USE_STATIC_LIBS On)
endif()
- if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
- get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
- IMPORTED_LOCATION_NOCONFIG)
+
+ # The FindProtobuf CMake module shipped by upstream CMake is
+ # broken for Protobuf version 22.0 and newer because it does
+ # not correctly pull in the new Abseil dependencies. Protobuf
+ # itself sometimes ships a CMake Package Configuration module
+ # that _does_ work correctly, so use that in preference to the
+ # Find module shipped with CMake.
+ #
+ # The code below works by first attempting to use find_package
+ # in config mode, and then checking for the existence of the
+ # target we actually use that gets defined by the protobuf
+ # CMake Package Configuration Module to determine if that
+ # worked. A bit of extra logic is required in the case of the
+ # config mode working, because some systems ship compatibility
+ # logic for the old FindProtobuf module while others do not.
+ #
+ # Upstream bug reference: https://gitlab.kitware.com/cmake/cmake/-/issues/24321
+ find_package(Protobuf CONFIG)
+
+ if(NOT TARGET protobuf::libprotobuf)
+ message(STATUS "Could not find Protobuf using Config mode, falling back to Module mode")
+ find_package(Protobuf REQUIRED)
endif()
- if(NOT Protobuf_PROTOC_EXECUTABLE)
+ endif()
+
+ if(TARGET protobuf::libprotobuf)
+ if(NOT Protobuf_PROTOC_EXECUTABLE AND TARGET protobuf::protoc)
set(Protobuf_PROTOC_EXECUTABLE protobuf::protoc)
endif()
- endif()
- # It is technically possible that this may still not
- # be set by this point, so we need to check it and
- # fail noisily if it isn't because the build won't
- # work without it.
- if(NOT Protobuf_PROTOC_EXECUTABLE)
- message(FATAL_ERROR "Could not determine the location of the protobuf compiler for the detected version of protobuf.")
- endif()
+ # It is technically possible that this may still not
+ # be set by this point, so we need to check it and
+ # fail noisily if it isn't because the build won't
+ # work without it.
+ if(NOT Protobuf_PROTOC_EXECUTABLE)
+ message(FATAL_ERROR "Could not determine the location of the protobuf compiler for the detected version of protobuf.")
+ endif()
- set(NETDATA_PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
- set(NETDATA_PROTOBUF_LIBS protobuf::libprotobuf)
- get_target_property(NETDATA_PROTOBUF_CFLAGS_OTHER
- protobuf::libprotobuf
- INTERFACE_COMPILE_DEFINITIONS)
- get_target_property(NETDATA_PROTOBUF_INCLUDE_DIRS
- protobuf::libprotobuf
- INTERFACE_INCLUDE_DIRECTORIES)
-
- if(NETDATA_PROTOBUF_CFLAGS_OTHER STREQUAL NETDATA_PROTOBUF_CFLAGS_OTHER-NOTFOUND)
- set(NETDATA_PROTOBUF_CFLAGS_OTHER "")
+ set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
+ set(PROTOBUF_LIBRARIES protobuf::libprotobuf)
endif()
- if(NETDATA_PROTOBUF_INCLUDE_DIRS STREQUAL NETDATA_PROTOBUF_INCLUDE_DIRS-NOTFOUND)
- set(NETDATA_PROTOBUF_INCLUDE_DIRS "")
- endif()
- else()
- set(NETDATA_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
- set(NETDATA_PROTOBUF_CFLAGS_OTHER ${PROTOBUF_CFLAGS_OTHER})
- set(NETDATA_PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS})
- set(NETDATA_PROTOBUF_LIBS ${PROTOBUF_LIBRARIES})
+ set(ENABLE_PROTOBUF True)
+ set(HAVE_PROTOBUF True)
endif()
-
- set(ENABLE_PROTOBUF True)
- set(HAVE_PROTOBUF True)
endmacro()
# Helper function to compile protocol definitions into C++ code.
@@ -203,9 +152,9 @@ function(netdata_protoc_generate_cpp INC_DIR OUT_DIR SRCS HDRS)
endif()
add_custom_command(OUTPUT ${GENERATED_PB_CC} ${GENERATED_PB_H}
- COMMAND ${NETDATA_PROTOBUF_PROTOC_EXECUTABLE}
+ COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS "-I$<JOIN:${_PROTOC_INCLUDE_DIRS},;-I>" --cpp_out=${OUT_DIR} ${ABS_FIL}
- DEPENDS ${ABS_FIL} ${NETDATA_PROTOBUF_PROTOC_EXECUTABLE}
+ DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
COMMAND_EXPAND_LISTS)
endforeach()
@@ -219,7 +168,12 @@ endfunction()
# Add protobuf to a specified target.
function(netdata_add_protobuf _target)
- target_compile_definitions(${_target} PRIVATE ${NETDATA_PROTOBUF_CFLAGS_OTHER})
- target_include_directories(${_target} PRIVATE ${NETDATA_PROTOBUF_INCLUDE_DIRS})
- target_link_libraries(${_target} PRIVATE ${NETDATA_PROTOBUF_LIBS})
+ if(ENABLE_BUNDLED_PROTOBUF)
+ target_include_directories(${_target} BEFORE PRIVATE ${PROTOBUF_INCLUDE_DIRS})
+ else()
+ target_include_directories(${_target} PRIVATE ${PROTOBUF_INCLUDE_DIRS})
+ endif()
+
+ target_compile_options(${_target} PRIVATE ${PROTOBUF_CFLAGS_OTHER})
+ target_link_libraries(${_target} PRIVATE ${PROTOBUF_LIBRARIES})
endfunction()
diff --git a/packaging/cmake/Modules/NetdataSentry.cmake b/packaging/cmake/Modules/NetdataSentry.cmake
new file mode 100644
index 000000000..b20aeedd5
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataSentry.cmake
@@ -0,0 +1,30 @@
+# Functions and macros for handling of Sentry
+#
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Handle bundling of Sentry.
+#
+# This pulls it in as a sub-project using FetchContent functionality.
+#
+# This needs to be a function and not a macro for variable scoping
+# reasons. All the things we care about from the sub-project are exposed
+# as targets, which are globally scoped and not function scoped.
+function(netdata_bundle_sentry)
+ include(FetchContent)
+
+ # ignore debhelper
+ set(FETCHCONTENT_FULLY_DISCONNECTED Off)
+
+ set(SENTRY_VERSION 0.6.6)
+ set(SENTRY_BACKEND "breakpad")
+ set(SENTRY_BUILD_SHARED_LIBS OFF)
+
+ FetchContent_Declare(
+ sentry
+ GIT_REPOSITORY https://github.com/getsentry/sentry-native.git
+ GIT_TAG c97bcc63fa89ae557cef9c9b6e3acb11a72ff97d # v0.6.6
+ CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
+ )
+ FetchContent_MakeAvailable(sentry)
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataUtil.cmake b/packaging/cmake/Modules/NetdataUtil.cmake
new file mode 100644
index 000000000..c6a13309f
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataUtil.cmake
@@ -0,0 +1,146 @@
+# Utility functions used by other modules.
+#
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+include_guard()
+
+# Determine the version of the host kernel.
+#
+# Only works on UNIX-like systems, stores the version in the cache
+# variable HOST_KERNEL_VERSION.
+function(netdata_detect_host_kernel_version)
+ if(DEFINED HOST_KERNEL_VERSION)
+ return()
+ endif()
+
+ message(CHECK_START "Determining host kernel version")
+
+ if(NOT CMAKE_CROSSCOMPILING)
+ include(CheckIncludeFile)
+
+ check_include_file("linux/version.h" CAN_USE_VERSION_H)
+
+ if(CAN_USE_VERSION_H)
+ message(CHECK_START "Checking version using linux/version.h")
+ file(WRITE "${CMAKE_BINARY_DIR}/kversion-test.c" "
+ #include <stdio.h>
+ #include <linux/version.h>
+
+ int main() {
+ printf(\"%i.%i.%i\", LINUX_VERSION_MAJOR, LINUX_VERSION_PATCHLEVEL, LINUX_VERSION_SUBLEVEL);
+ }
+ ")
+
+ try_run(_run_success _compile_success
+ ${CMAKE_BINARY_DIR}
+ SOURCES ${CMAKE_BINARY_DIR}/kversion-test.c
+ RUN_OUTPUT_VARIABLE _kversion_output)
+
+ if(_compile_success AND _run_success EQUAL 0)
+ message(CHECK_PASS "success")
+ set(_kversion_value "${_kversion_output}")
+ else()
+ message(CHECK_FAIL "failed")
+ endif()
+ endif()
+ endif()
+
+ if(NOT DEFINED _kversion_value)
+ message(CHECK_START "Checking version using uname")
+ execute_process(COMMAND uname -r
+ RESULT_VARIABLE _uname_result
+ OUTPUT_VARIABLE _uname_output)
+
+ if(NOT _uname_result EQUAL 0)
+ message(CHECK_FAIL "failed")
+ message(CHECK_FAIL "unknown")
+ set(HOST_KERNEL_VERSION "0.0.0" CACHE STRING "Detected host kernel version")
+ return()
+ else()
+ message(CHECK_PASS "success")
+ endif()
+
+ set(_kversion_value "${_uname_output}")
+ endif()
+
+ string(REGEX REPLACE "-.+$" "" _kversion "${_kversion_value}")
+ message(CHECK_PASS "${_kversion}")
+ set(HOST_KERNEL_VERSION "${_kversion}" CACHE STRING "Detected host kernel version")
+endfunction()
+
+# Check what libc we're using.
+#
+# Sets the specified variable to the name of the libc or "unknown"
+function(netdata_identify_libc _libc_name)
+ if(NOT DEFINED _ND_DETECTED_LIBC)
+ message(CHECK_START "Detecting libc implementation using ldd")
+
+ execute_process(COMMAND ldd --version
+ COMMAND grep -q -i -E "glibc|gnu libc"
+ RESULT_VARIABLE LDD_RESULT
+ OUTPUT_VARIABLE LDD_OUTPUT
+ ERROR_VARIABLE LDD_OUTPUT)
+
+ if(NOT LDD_RESULT)
+ set(${_libc_name} glibc PARENT_SCOPE)
+ set(_ND_DETECTED_LIBC glibc CACHE INTERNAL "")
+ message(CHECK_PASS "glibc")
+ return()
+ endif()
+
+ execute_process(COMMAND sh -c "ldd --version 2>&1 | grep -q -i 'musl'"
+ RESULT_VARIABLE LDD_RESULT
+ OUTPUT_VARIABLE LDD_OUTPUT
+ ERROR_VARIABLE LDD_OUTPUT)
+
+ if(NOT LDD_RESULT)
+ set(${_libc_name} musl PARENT_SCOPE)
+ set(_ND_DETECTED_LIBC musl CACHE INTERNAL "")
+ message(CHECK_PASS "musl")
+ return()
+ endif()
+
+ message(CHECK_FAIL "unknown")
+
+ message(CHECK_START "Looking for libc.so.6")
+ find_program(LIBC_PATH libc.so.6
+ PATHS /lib /lib64 /usr/lib /usr/lib64
+ NO_DEFAULT_PATH
+ NO_PACKAGE_ROOT_PATH
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH
+ NO_CMAKE_INSTALL_PREFIX
+ NO_CMAKE_FIND_ROOT_PATH)
+
+ if(NOT "${LIBC_PATH}" EQUAL "LIBC_PATH-NOTFOUND")
+ message(CHECK_PASS "found")
+ message(CHECK_START "Detecting libc implementation using libc.so.6")
+
+ execute_process(COMMAND "${LIBC_PATH}"
+ COMMAND head -n 1
+ COMMAND grep -q -i -E "gnu libc|gnu c library"
+ RESULT_VARIABLE LIBC_RESULT
+ OUTPUT_VARIABLE LIBC_OUTPUT
+ ERROR_VARIABLE LIBC_ERROR)
+
+ if(NOT LIBC_RESULT)
+ set(${_libc_name} glibc PARENT_SCOPE)
+ set(_ND_DETECTED_LIBC glibc CACHE INTERNAL "")
+ message(CHECK_PASS "glibc")
+ return()
+ else()
+ message(CHECK_FAIL "unknown")
+ endif()
+ else()
+ message(CHECK_FAIL "not found")
+ endif()
+
+ set(${_libc_name} unknown PARENT_SCOPE)
+ set(_ND_DETECTED_LIBC unknown CACHE INTERNAL "")
+ else()
+ set(${_libc_name} ${_ND_DETECTED_LIBC} PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataVersion.cmake b/packaging/cmake/Modules/NetdataVersion.cmake
new file mode 100644
index 000000000..b4bdd43b0
--- /dev/null
+++ b/packaging/cmake/Modules/NetdataVersion.cmake
@@ -0,0 +1,51 @@
+# Copyright (c) 2024 Netdata Inc.
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Function to provide information regarding the Netdata version.
+#
+# The high-level logic is (a) use git-describe, (b) fallback to info from
+# packaging/version. This version field are used for cmake's project,
+# cpack's packaging, and the agent's functionality.
+function(netdata_version)
+ find_package(Git)
+
+ if(GIT_EXECUTABLE)
+ execute_process(COMMAND ${GIT_EXECUTABLE} describe
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE GIT_DESCRIBE_RESULT
+ OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT)
+ if(GIT_DESCRIBE_RESULT)
+ file(STRINGS "${CMAKE_SOURCE_DIR}/packaging/version" GIT_DESCRIBE_OUTPUT)
+ message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
+ endif()
+ else()
+ file(STRINGS packaging/version GIT_DESCRIBE_OUTPUT)
+ message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
+ endif()
+
+ string(STRIP ${GIT_DESCRIBE_OUTPUT} GIT_DESCRIBE_OUTPUT)
+ set(NETDATA_VERSION_STRING "${GIT_DESCRIBE_OUTPUT}" PARENT_SCOPE)
+
+ string(REGEX MATCH "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?([0-9]+)?-?([0-9a-zA-Z]+)?" MATCHES "${GIT_DESCRIBE_OUTPUT}")
+ if(CMAKE_MATCH_COUNT EQUAL 3)
+ set(NETDATA_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
+ set(NETDATA_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
+ set(NETDATA_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
+ set(NETDATA_VERSION_TWEAK 0 PARENT_SCOPE)
+ set(NETDATA_VERSION_DESCR "N/A" PARENT_SCOPE)
+ elseif(CMAKE_MATCH_COUNT EQUAL 4)
+ set(NETDATA_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
+ set(NETDATA_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
+ set(NETDATA_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
+ set(NETDATA_VERSION_TWEAK ${CMAKE_MATCH_4} PARENT_SCOPE)
+ set(NETDATA_VERSION_DESCR "N/A" PARENT_SCOPE)
+ elseif(CMAKE_MATCH_COUNT EQUAL 5)
+ set(NETDATA_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
+ set(NETDATA_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
+ set(NETDATA_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
+ set(NETDATA_VERSION_TWEAK ${CMAKE_MATCH_4} PARENT_SCOPE)
+ set(NETDATA_VERSION_DESCR ${CMAKE_MATCH_5} PARENT_SCOPE)
+ else()
+ message(FATAL_ERROR "Wrong version regex match count ${CMAKE_MATCH_COUNT} (should be in 3, 4 or 5)")
+ endif()
+endfunction()
diff --git a/packaging/cmake/Modules/NetdataYAML.cmake b/packaging/cmake/Modules/NetdataYAML.cmake
index 73af55167..f2f9b404e 100644
--- a/packaging/cmake/Modules/NetdataYAML.cmake
+++ b/packaging/cmake/Modules/NetdataYAML.cmake
@@ -23,6 +23,7 @@ function(netdata_bundle_libyaml)
FetchContent_Declare(yaml
GIT_REPOSITORY https://github.com/yaml/libyaml
GIT_TAG 2c891fc7a770e8ba2fec34fc6b545c672beb37e6 # v0.2.5
+ CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
FetchContent_MakeAvailable_NoInstall(yaml)
@@ -44,6 +45,7 @@ macro(netdata_detect_libyaml)
if(ENABLE_BUNDLED_LIBYAML OR NOT YAML_FOUND)
netdata_bundle_libyaml()
+ set(ENABLE_BUNDLED_LIBYAML True PARENT_SCOPE)
set(NETDATA_YAML_LDFLAGS yaml)
get_target_property(NETDATA_YAML_INCLUDE_DIRS yaml INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(NETDATA_YAML_CFLAGS_OTHER yaml INTERFACE_COMPILE_DEFINITIONS)
@@ -59,7 +61,11 @@ endmacro()
# The specified target must already exist, and the netdata_detect_libyaml
# macro must have already been run at least once for this to work correctly.
function(netdata_add_libyaml_to_target _target)
- target_include_directories(${_target} PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
- target_compile_definitions(${_target} PUBLIC ${NETDATA_YAML_CFLAGS_OTHER})
+ if(ENABLE_BUNDLED_LIBYAML)
+ target_include_directories(${_target} BEFORE PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
+ else()
+ target_include_directories(${_target} PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
+ endif()
+ target_compile_options(${_target} PUBLIC ${NETDATA_YAML_CFLAGS_OTHER})
target_link_libraries(${_target} PUBLIC ${NETDATA_YAML_LDFLAGS})
endfunction()
diff --git a/packaging/cmake/Modules/Packaging.cmake b/packaging/cmake/Modules/Packaging.cmake
new file mode 100644
index 000000000..1dd2328cd
--- /dev/null
+++ b/packaging/cmake/Modules/Packaging.cmake
@@ -0,0 +1,503 @@
+#
+# CPack options
+#
+
+if(NETDATA_VERSION_DESCR STREQUAL "N/A")
+ set(CPACK_PACKAGE_VERSION ${NETDATA_VERSION_MAJOR}.${NETDATA_VERSION_MINOR}.${NETDATA_VERSION_PATCH})
+else()
+ set(CPACK_PACKAGE_VERSION ${NETDATA_VERSION_MAJOR}.${NETDATA_VERSION_MINOR}.${NETDATA_VERSION_PATCH}-${NETDATA_VERSION_TWEAK}-${NETDATA_VERSION_DESCR})
+endif()
+
+set(CPACK_THREADS 0)
+
+set(CPACK_STRIP_FILES NO)
+set(CPACK_DEBIAN_DEBUGINFO_PACKAGE NO)
+
+set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
+
+set(CPACK_PACKAGING_INSTALL_PREFIX "/")
+
+set(CPACK_PACKAGE_VENDOR "Netdata Inc.")
+
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
+set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
+
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "netdata")
+set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")
+
+# to silence lintian
+set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
+
+#
+# Debian options
+#
+
+set(CPACK_DEB_COMPONENT_INSTALL YES)
+set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS YES)
+set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Netdata Builder <bot@netdata.cloud>")
+
+#
+# netdata
+#
+
+set(CPACK_COMPONENT_NETDATA_DESCRIPTION
+ "real-time charts for system monitoring
+ Netdata is a daemon that collects data in realtime (per second)
+ and presents a web site to view and analyze them. The presentation
+ is also real-time and full of interactive charts that precisely
+ render all collected values.")
+
+set(CPACK_DEBIAN_NETDATA_PACKAGE_NAME "netdata")
+set(CPACK_DEBIAN_NETDATA_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_NETDATA_PACKAGE_PREDEPENDS "adduser, libcap2-bin")
+set(CPACK_DEBIAN_NETDATA_PACKAGE_SUGGESTS
+ "netdata-plugin-cups (= ${CPACK_PACKAGE_VERSION}), netdata-plugin-freeipmi (= ${CPACK_PACKAGE_VERSION})")
+set(CPACK_DEBIAN_NETDATA_PACKAGE_RECOMMENDS
+ "netdata-plugin-systemd-journal (= ${CPACK_PACKAGE_VERSION}), \
+netdata-plugin-logs-management (= ${CPACK_PACKAGE_VERSION}), \
+netdata-plugin-network-viewer (= ${CPACK_PACKAGE_VERSION})")
+set(CPACK_DEBIAN_NETDATA_PACKAGE_CONFLICTS
+ "netdata-core, netdata-plugins-bash, netdata-plugins-python, netdata-web")
+
+list(APPEND _main_deps "netdata-plugin-chartsd (= ${CPACK_PACKAGE_VERSION})")
+list(APPEND _main_deps "netdata-plugin-pythond (= ${CPACK_PACKAGE_VERSION})")
+
+if(ENABLE_PLUGIN_APPS)
+ list(APPEND _main_deps "netdata-plugin-apps (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+if(ENABLE_PLUGIN_GO)
+ list(APPEND _main_deps "netdata-plugin-go (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+if(ENABLE_PLUGIN_DEBUGFS)
+ list(APPEND _main_deps "netdata-plugin-debugfs (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+if(ENABLE_PLUGIN_NFACCT)
+ list(APPEND _main_deps "netdata-plugin-nfacct (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+if(ENABLE_PLUGIN_SLABINFO)
+ list(APPEND _main_deps "netdata-plugin-slabinfo (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+if(ENABLE_PLUGIN_PERF)
+ list(APPEND _main_deps "netdata-plugin-perf (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+if(ENABLE_PLUGIN_EBPF)
+ list(APPEND _main_deps "netdata-plugin-ebpf (= ${CPACK_PACKAGE_VERSION})")
+endif()
+
+list(JOIN _main_deps ", " CPACK_DEBIAN_NETDATA_PACKAGE_DEPENDS)
+
+set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/netdata/conffiles;"
+ "${PKG_FILES_PATH}/deb/netdata/preinst"
+ "${PKG_FILES_PATH}/deb/netdata/postinst"
+ "${PKG_FILES_PATH}/deb/netdata/postrm")
+
+set(CPACK_DEBIAN_NETDATA_DEBUGINFO_PACKAGE On)
+
+#
+# apps.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-APPS_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-APPS_DESCRIPTION
+ "The per-application metrics collector plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to collect per-application and
+ per-user metrics without using cgroups.")
+
+set(CPACK_DEBIAN_PLUGIN-APPS_PACKAGE_NAME "netdata-plugin-apps")
+set(CPACK_DEBIAN_PLUGIN-APPS_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-APPS_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-APPS_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+
+set(CPACK_DEBIAN_PLUGIN-APPS_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-apps/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-apps/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-APPS_DEBUGINFO_PACKAGE On)
+
+#
+# charts.d.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-CHARTSD_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-CHARTSD_DESCRIPTION
+ "The charts.d metrics collection plugin for the Netdata Agent
+ This plugin adds a selection of additional collectors written in shell
+ script to the Netdata Agent. It includes collectors for APCUPSD,
+ LibreSWAN, OpenSIPS, and Wireless access point statistics.")
+
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_NAME "netdata-plugin-chartsd")
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_PREDEPENDS "adduser")
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_DEPENDS "bash")
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_ARCHITECTURE "all")
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_SUGGESTS "apcupsd, iw, sudo")
+
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-chartsd/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-chartsd/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-CHARTSD_DEBUGINFO_PACKAGE Off)
+
+#
+# cups.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-CUPS_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-CUPS_DESCRIPTION
+ "The CUPS metrics collection plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to collect metrics from the Common UNIX Printing System.")
+
+set(CPACK_DEBIAN_PLUGIN-CUPS_PACKAGE_NAME "netdata-plugin-cups")
+set(CPACK_DEBIAN_PLUGIN-CUPS_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-CUPS_PACKAGE_PREDEPENDS "adduser")
+set(CPACK_DEBIAN_PLUGIN-CUPS_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-cups/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-cups/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-CUPS_DEBUGINFO_PACKAGE On)
+
+#
+# debugfs.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-DEBUGFS_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-DEBUGFS_DESCRIPTION
+ "The debugfs metrics collector for the Netdata Agent
+ This plugin allows the Netdata Agent to collect Linux kernel metrics
+ exposed through debugfs.")
+
+set(CPACK_DEBIAN_PLUGIN-DEBUGFS_PACKAGE_NAME "netdata-plugin-debugfs")
+set(CPACK_DEBIAN_PLUGIN-DEBUGFS_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-DEBUGFS_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-DEBUGFS_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+set(CPACK_DEBIAN_PLUGIN-DEBUGFS_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-debugfs/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-debugfs/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-DEBUGFS_DEBUGINFO_PACKAGE On)
+
+#
+# ebpf.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-EBPF_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-EBPF_DESCRIPTION
+ "The eBPF metrics collection plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to use eBPF code to collect more
+ detailed kernel-level metrics for the system.")
+
+set(CPACK_DEBIAN_PLUGIN-EBPF_PACKAGE_NAME "netdata-plugin-ebpf")
+set(CPACK_DEBIAN_PLUGIN-EBPF_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-EBPF_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-EBPF_PACKAGE_PREDEPENDS "adduser")
+set(CPACK_DEBIAN_PLUGIN-EBPF_PACKAGE_RECOMMENDS "netdata-plugin-apps (= ${CPACK_PACKAGE_VERSION}), netdata-ebpf-code-legacy (= ${CPACK_PACKAGE_VERSION})")
+
+set(CPACK_DEBIAN_PLUGIN-EBPF_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-ebpf/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-ebpf/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-EBPF_DEBUGINFO_PACKAGE On)
+
+#
+# ebpf-code-legacy
+#
+
+set(CPACK_COMPONENT_EBPF-CODE-LEGACY_DEPENDS "netdata")
+set(CPACK_COMPONENT_EBPF-CODE-LEGACY_DESCRIPTION
+ "Compiled eBPF legacy code for the Netdata eBPF plugin
+ This package provides the pre-compiled eBPF legacy code for use by
+ the Netdata eBPF plugin. This code is only needed when using the eBPF
+ plugin with kernel that do not include BTF support (mostly kernel
+ versions lower than 5.10).")
+
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_PACKAGE_NAME "netdata-ebpf-code-legacy")
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_PACKAGE_PREDEPENDS "adduser")
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_PACKAGE_RECOMMENDS "netdata-plugin-ebpf (= ${CPACK_PACKAGE_VERSION})")
+
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/ebpf-code-legacy/preinst;"
+ "${PKG_FILES_PATH}/deb/ebpf-code-legacy/postinst")
+
+set(CPACK_DEBIAN_EBPF-CODE-LEGACY_DEBUGINFO_PACKAGE Off)
+
+#
+# freeipmi.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-FREEIPMI_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-FREEIPMI_DESCRIPTION
+ "The FreeIPMI metrics collection plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to collect metrics from hardware
+ using FreeIPMI.")
+
+set(CPACK_DEBIAN_PLUGIN-FREEIPMI_PACKAGE_NAME "netdata-plugin-freeipmi")
+set(CPACK_DEBIAN_PLUGIN-FREEIPMI_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-FREEIPMI_PACKAGE_PREDEPENDS "adduser")
+
+set(CPACK_DEBIAN_PLUGIN-FREEIPMI_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-freeipmi/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-freeipmi/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-FREEIPMI_DEBUGINFO_PACKAGE On)
+
+#
+# go.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-GO_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-GO_DESCRIPTION
+ "The go.d metrics collection plugin for the Netdata Agent
+ This plugin adds a selection of additional collectors written in Go to
+ the Netdata Agent. A significant percentage of the application specific
+ collectors provided by Netdata are part of this plugin, so most users
+ will want it installed.")
+
+set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_NAME "netdata-plugin-go")
+set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_SUGGESTS "nvme-cli")
+
+set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-go/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-go/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-GO_DEBUGINFO_PACKAGE Off)
+
+#
+# logs-management.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-LOGS-MANAGEMENT_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-LOGS-MANAGEMENT_DESCRIPTION
+ "The logs-management plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to collect logs from the system
+ and parse them to extract metrics.")
+
+set(CPACK_DEBIAN_PLUGIN-LOGS-MANAGEMENT_PACKAGE_NAME "netdata-plugin-logs-management")
+set(CPACK_DEBIAN_PLUGIN-LOGS-MANAGEMENT_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-LOGS-MANAGEMENT_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+
+set(CPACK_DEBIAN_PLUGIN-LOGS-MANAGEMENT_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-logs-management/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-logs-management/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-LOGS-MANAGEMENT_DEBUGINFO_PACKAGE On)
+
+#
+# network-viewer.plugin
+#
+
+# TODO: recommends netdata-plugin-ebpf
+set(CPACK_COMPONENT_PLUGIN-NETWORK-VIEWER_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-NETWORK-VIEWER_DESCRIPTION
+ "The network viewer plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to provide network connection
+ mapping functionality for use in Netdata Cloud.")
+
+set(CPACK_DEBIAN_PLUGIN-NETWORK_VIEWER_PACKAGE_NAME "netdata-plugin-network-viewer")
+set(CPACK_DEBIAN_PLUGIN-NETWORK-VIEWER_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-NETWORK-VIEWER_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+set(CPACK_DEBIAN_PLUGIN-NETWORK-VIEWER_PACKAGE_RECOMMENDS "netdata-plugin-ebpf (= ${CPACK_PACKAGE_VERSION})")
+
+set(CPACK_DEBIAN_PLUGIN-NETWORK-VIEWER_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-network-viewer/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-network-viewer/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-NETWORK-VIEWER_DEBUGINFO_PACKAGE On)
+
+#
+# nfacct.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-NFACCT_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-NFACCT_DESCRIPTION
+ "The NFACCT metrics collection plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to collect metrics from the firewall
+ using NFACCT objects.")
+
+set(CPACK_DEBIAN_PLUGIN-NFACCT_PACKAGE_NAME "netdata-plugin-nfacct")
+set(CPACK_DEBIAN_PLUGIN-NFACCT_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-NFACCT_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-NFACCT_PACKAGE_PREDEPENDS "adduser")
+
+set(CPACK_DEBIAN_PLUGIN-NFACCT_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-nfacct/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-nfacct/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-NFACCT_DEBUGINFO_PACKAGE On)
+
+#
+# perf.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-PERF_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-PERF_DESCRIPTION
+ "The perf metrics collector for the Netdata Agent
+ This plugin allows the Netdata to collect metrics from the Linux perf
+ subsystem.")
+
+set(CPACK_DEBIAN_PLUGIN-PERF_PACKAGE_NAME "netdata-plugin-perf")
+set(CPACK_DEBIAN_PLUGIN-PERF_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-PERF_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-PERF_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+
+set(CPACK_DEBIAN_PLUGIN-PERF_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-perf/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-perf/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-PERF_DEBUGINFO_PACKAGE On)
+
+#
+# pythond.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-PYTHOND_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-PYTHOND_DESCRIPTION
+ "The python.d metrics collection plugin for the Netdata Agent
+ Many of the collectors provided by this package are also available
+ in netdata-plugin-god. In msot cases, you probably want to use those
+ versions instead of the Python versions.")
+
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_NAME "netdata-plugin-pythond")
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_PREDEPENDS "adduser")
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_SUGGESTS "sudo")
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACHAGE_DEPENDS "python3")
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_ARCHITECTURE "all")
+
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-pythond/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-pythond/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-PYTHOND_DEBUGINFO_PACKAGE Off)
+
+#
+# slabinfo.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-SLABINFO_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-SLABINFO_DESCRIPTION
+ "The slabinfo metrics collector for the Netdata Agent
+ This plugin allows the Netdata Agent to collect perfromance and
+ utilization metrics for the Linux kernel’s SLAB allocator.")
+
+set(CPACK_DEBIAN_PLUGIN-SLABINFO_PACKAGE_NAME "netdata-plugin-slabinfo")
+set(CPACK_DEBIAN_PLUGIN-SLABINFO_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-SLABINFO_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-SLABINFO_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+
+set(CPACK_DEBIAN_PLUGIN-SLABINFO_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-slabinfo/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-slabinfo/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-SLABINFO_DEBUGINFO_PACKAGE On)
+
+#
+# systemd-journal.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-SYSTEMD-JOURNAL_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-SYSTEMD-JOURNAL_DESCRIPTION
+ "The systemd-journal collector for the Netdata Agent
+ This plugin allows the Netdata Agent to present logs from the systemd
+ journal on Netdata Cloud or the local Agent dashboard.")
+
+set(CPACK_DEBIAN_PLUGIN-SYSTEMD-JOURNAL_PACKAGE_NAME "netdata-plugin-systemd-journal")
+set(CPACK_DEBIAN_PLUGIN-SYSTEMD-JOURNAL_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-SYSTEMD-JOURNAL_PACKAGE_PREDEPENDS "libcap2-bin, adduser")
+
+set(CPACK_DEBIAN_PLUGIN-SYSTEMD-JOURNAL_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-systemd-journal/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-systemd-journal/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-SYSTEMD_JOURNAL_DEBUGINFO_PACKAGE On)
+
+#
+# xenstat.plugin
+#
+
+set(CPACK_COMPONENT_PLUGIN-XENSTAT_DEPENDS "netdata")
+set(CPACK_COMPONENT_PLUGIN-XENSTAT_DESCRIPTION
+ "The xenstat plugin for the Netdata Agent
+ This plugin allows the Netdata Agent to collect metrics from the Xen
+ Hypervisor.")
+
+set(CPACK_DEBIAN_PLUGIN-XENSTAT_PACKAGE_NAME "netdata-plugin-xenstat")
+set(CPACK_DEBIAN_PLUGIN-XENSTAT_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PLUGIN-XENSTAT_PACKAGE_CONFLICTS "netdata (<< 1.40)")
+set(CPACK_DEBIAN_PLUGIN-XENSTAT_PACKAGE_PREDEPENDS "adduser")
+
+set(CPACK_DEBIAN_PLUGIN-XENSTAT_PACKAGE_CONTROL_EXTRA
+ "${PKG_FILES_PATH}/deb/plugin-xenstat/preinst;"
+ "${PKG_FILES_PATH}/deb/plugin-xenstat/postinst")
+
+set(CPACK_DEBIAN_PLUGIN-XENSTAT_DEBUGINFO_PACKAGE On)
+
+#
+# CPack components
+#
+
+list(APPEND CPACK_COMPONENTS_ALL "netdata")
+if(ENABLE_PLUGIN_APPS)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-apps")
+endif()
+list(APPEND CPACK_COMPONENTS_ALL "plugin-chartsd")
+if(ENABLE_PLUGIN_CUPS)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-cups")
+endif()
+if(ENABLE_PLUGIN_DEBUGFS)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-debugfs")
+endif()
+if(ENABLE_PLUGIN_EBPF)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-ebpf")
+endif()
+if(ENABLE_EBPF_LEGACY_PROGRAMS)
+ list(APPEND CPACK_COMPONENTS_ALL "ebpf-code-legacy")
+endif()
+if(ENABLE_PLUGIN_FREEIPMI)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-freeipmi")
+endif()
+if(ENABLE_PLUGIN_GO)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-go")
+endif()
+if(ENABLE_PLUGIN_LOGS_MANAGEMENT)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-logs-management")
+endif()
+if(ENABLE_PLUGIN_NETWORK_VIEWER)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-network-viewer")
+endif()
+if(ENABLE_PLUGIN_NFACCT)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-nfacct")
+endif()
+if(ENABLE_PLUGIN_PERF)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-perf")
+endif()
+list(APPEND CPACK_COMPONENTS_ALL "plugin-pythond")
+if(ENABLE_PLUGIN_SLABINFO)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-slabinfo")
+endif()
+if(ENABLE_PLUGIN_SYSTEMD_JOURNAL)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-systemd-journal")
+endif()
+if(ENABLE_PLUGIN_XENSTAT)
+ list(APPEND CPACK_COMPONENTS_ALL "plugin-xenstat")
+endif()
+
+include(CPack)
diff --git a/packaging/cmake/config.cmake.h.in b/packaging/cmake/config.cmake.h.in
index 276b051f9..57d032693 100644
--- a/packaging/cmake/config.cmake.h.in
+++ b/packaging/cmake/config.cmake.h.in
@@ -9,9 +9,10 @@
#cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P}
// platform
-#cmakedefine COMPILED_FOR_FREEBSD
-#cmakedefine COMPILED_FOR_LINUX
-#cmakedefine COMPILED_FOR_MACOS
+#cmakedefine OS_FREEBSD
+#cmakedefine OS_LINUX
+#cmakedefine OS_MACOS
+#cmakedefine OS_WINDOWS
// checked headers
@@ -28,6 +29,20 @@
#cmakedefine HAVE_INTTYPES_H
#cmakedefine HAVE_STDINT_H
#cmakedefine HAVE_SYS_CAPABILITY_H
+#cmakedefine HAVE_ARPA_INET_H
+#cmakedefine HAVE_NETINET_TCP_H
+#cmakedefine HAVE_SYS_IOCTL_H
+#cmakedefine HAVE_GRP_H
+#cmakedefine HAVE_PWD_H
+#cmakedefine HAVE_NET_IF_H
+#cmakedefine HAVE_POLL_H
+#cmakedefine HAVE_SYSLOG_H
+#cmakedefine HAVE_SYS_MMAN_H
+#cmakedefine HAVE_SYS_RESOURCE_H
+#cmakedefine HAVE_SYS_SOCKET_H
+#cmakedefine HAVE_SYS_WAIT_H
+#cmakedefine HAVE_SYS_UN_H
+#cmakedefine HAVE_SPAWN_H
#cmakedefine HAVE_CAPABILITY
#cmakedefine HAVE_PROTOBUF
@@ -44,8 +59,13 @@
#cmakedefine HAVE_FINITE
#cmakedefine HAVE_ISFINITE
#cmakedefine HAVE_RECVMMSG
+#cmakedefine HAVE_PTHREAD_GETTHREADID_NP
+#cmakedefine HAVE_PTHREAD_THREADID_NP
+#cmakedefine HAVE_GETTID
+#cmakedefine HAVE_WAITID
#cmakedefine HAVE_NICE
#cmakedefine HAVE_GETPRIORITY
+#cmakedefine HAVE_SETENV
#cmakedefine HAVE_DLSYM
#cmakedefine HAVE_BACKTRACE
@@ -70,8 +90,11 @@
#cmakedefine HAVE_C__GENERIC
#cmakedefine HAVE_C_MALLOPT
#cmakedefine HAVE_SETNS
+#cmakedefine HAVE_STRNDUP
+#cmakedefine SSL_HAS_PENDING
-#cmakedefine HAVE_FUNC_ATTRIBUTE_FORMAT
+#cmakedefine HAVE_FUNC_ATTRIBUTE_FORMAT_GNU_PRINTF
+#cmakedefine HAVE_FUNC_ATTRIBUTE_FORMAT_PRINTF
#cmakedefine HAVE_FUNC_ATTRIBUTE_MALLOC
#cmakedefine HAVE_FUNC_ATTRIBUTE_NOINLINE
#cmakedefine HAVE_FUNC_ATTRIBUTE_NORETURN
@@ -113,7 +136,6 @@
#cmakedefine ENABLE_SENTRY
#cmakedefine NETDATA_SENTRY_ENVIRONMENT "@NETDATA_SENTRY_ENVIRONMENT@"
-#cmakedefine NETDATA_SENTRY_RELEASE "@NETDATA_SENTRY_RELEASE@"
#cmakedefine NETDATA_SENTRY_DIST "@NETDATA_SENTRY_DIST@"
#cmakedefine NETDATA_SENTRY_DSN "@NETDATA_SENTRY_DSN@"
// enabled bundling
@@ -137,7 +159,13 @@
#cmakedefine CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
#cmakedefine NETDATA_USER "@NETDATA_USER@"
-#cmakedefine VERSION "@GIT_DESCRIBE_OUTPUT@"
+#define NETDATA_VERSION_MAJOR "@NETDATA_VERSION_MAJOR@"
+#define NETDATA_VERSION_MINOR "@NETDATA_VERSION_MINOR@"
+#define NETDATA_VERSION_PATCH "@NETDATA_VERSION_PATCH@"
+#define NETDATA_VERSION_TWEAK "@NETDATA_VERSION_TWEAK@"
+#define NETDATA_VERSION_DESCR "@NETDATA_VERSION_DESCR@"
+
+#define NETDATA_VERSION "@NETDATA_VERSION_STRING@"
#define ENABLE_JSONC 1
diff --git a/packaging/cmake/pkg-files/copyright b/packaging/cmake/pkg-files/copyright
new file mode 100644
index 000000000..085580ea1
--- /dev/null
+++ b/packaging/cmake/pkg-files/copyright
@@ -0,0 +1,10 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: Netdata
+Upstream-Contact: Costa Tsaousis <costa@tsaousis.gr>
+Source: https://github.com/netdata/netdata
+
+Files: *
+Copyright: 2014-2016, Costa Tsaousis
+License: GPL-3+
+ On Debian systems, the complete text of the GNU General Public
+ License version 3 can be found in /usr/share/common-licenses/GPL-3.
diff --git a/packaging/cmake/pkg-files/deb/ebpf-code-legacy/postinst b/packaging/cmake/pkg-files/deb/ebpf-code-legacy/postinst
new file mode 100755
index 000000000..d6fe86723
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/ebpf-code-legacy/postinst
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-ebpf-code-legacy.list | xargs -n 30 chown root:netdata
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/ebpf-code-legacy/preinst b/packaging/cmake/pkg-files/deb/ebpf-code-legacy/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/ebpf-code-legacy/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/conffiles b/packaging/cmake/pkg-files/deb/netdata/conffiles
new file mode 100644
index 000000000..1ec902547
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/netdata/conffiles
@@ -0,0 +1,5 @@
+/etc/default/netdata
+/etc/init.d/netdata
+/etc/logrotate.d/netdata
+/etc/netdata/netdata.conf
+/etc/netdata/netdata-updater.conf
diff --git a/packaging/cmake/pkg-files/deb/netdata/etc/default/netdata b/packaging/cmake/pkg-files/deb/netdata/etc/default/netdata
new file mode 100644
index 000000000..0bc847fe7
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/netdata/etc/default/netdata
@@ -0,0 +1,3 @@
+# Extra arguments to pass to netdata
+#
+EXTRA_OPTS="-P /var/run/netdata/netdata.pid"
diff --git a/packaging/cmake/pkg-files/deb/netdata/etc/init.d/netdata b/packaging/cmake/pkg-files/deb/netdata/etc/init.d/netdata
new file mode 100755
index 000000000..c2706caa5
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/netdata/etc/init.d/netdata
@@ -0,0 +1,56 @@
+#!/bin/sh
+# Start/stop the netdata daemon.
+#
+### BEGIN INIT INFO
+# Provides: netdata
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Should-Start: $network
+# Should-Stop: $network
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: Real-time charts for system monitoring
+# Description: Netdata is a daemon that collects data in realtime (per second)
+# and presents a web site to view and analyze them. The presentation
+# is also real-time and full of interactive charts that precisely
+# render all collected values.
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+DESC="netdata daemon"
+NAME=netdata
+DAEMON=/usr/sbin/netdata
+PIDFILE=/var/run/netdata/netdata.pid
+SCRIPTNAME=/etc/init.d/"$NAME"
+
+test -f $DAEMON || exit 0
+
+. /lib/lsb/init-functions
+
+[ -r /etc/default/netdata ] && . /etc/default/netdata
+
+case "$1" in
+start) log_daemon_msg "Starting real-time system monitoring" "netdata"
+ start_daemon -p $PIDFILE $DAEMON -P $PIDFILE $EXTRA_OPTS
+ log_end_msg $?
+ ;;
+stop) log_daemon_msg "Stopping real-time system monitoring" "netdata"
+ killproc -p $PIDFILE $DAEMON
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
+ log_end_msg $RETVAL
+ # wait for plugins to exit
+ sleep 1
+ ;;
+restart|force-reload) log_daemon_msg "Restarting real-time system monitoring" "netdata"
+ $0 stop
+ $0 start
+ ;;
+status)
+ status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
+ ;;
+*) log_action_msg "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}"
+ exit 2
+ ;;
+esac
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/netdata/postinst b/packaging/cmake/pkg-files/deb/netdata/postinst
new file mode 100755
index 000000000..97593c23b
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/netdata/postinst
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ if ! dpkg-statoverride --list /var/lib/netdata > /dev/null 2>&1; then
+ dpkg-statoverride --update --add netdata netdata 0755 /var/lib/netdata
+ fi
+
+ if ! dpkg-statoverride --list /var/cache/netdata > /dev/null 2>&1; then
+ dpkg-statoverride --update --add netdata netdata 0755 /var/cache/netdata
+ fi
+
+ if ! dpkg-statoverride --list /var/run/netdata > /dev/null 2>&1; then
+ dpkg-statoverride --update --add netdata netdata 0755 /var/run/netdata
+ fi
+
+ if ! dpkg-statoverride --list /var/log/netdata > /dev/null 2>&1; then
+ 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
+
+ for f in ndsudo cgroup-network local-listeners ioping.plugin; do
+ chmod 4750 "/usr/libexec/netdata/plugins.d/${f}" || true
+ done
+
+ ;;
+esac
+
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ deb-systemd-helper unmask 'netdata.service' >/dev/null || true
+
+ if deb-systemd-helper --quiet was-enabled 'netdata.service'; then
+ deb-systemd-helper enable 'netdata.service' >/dev/null || true
+ else
+ deb-systemd-helper update-state 'netdata.service' >/dev/null || true
+ fi
+
+ if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ deb-systemd-invoke restart 'netdata.service' >/dev/null || true
+ fi
+fi
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/netdata/postrm b/packaging/cmake/pkg-files/deb/netdata/postrm
new file mode 100755
index 000000000..7a636863b
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/netdata/postrm
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ remove) ;;
+
+ purge)
+ if dpkg-statoverride --list | grep -qw /var/cache/netdata; then
+ 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
+
+ if dpkg-statoverride --list | grep -qw /var/lib/netdata; then
+ dpkg-statoverride --remove /var/lib/netdata
+ fi
+
+ if dpkg-statoverride --list | grep -qw /var/run/netdata; then
+ dpkg-statoverride --remove /var/run/netdata
+ fi
+
+ if dpkg-statoverride --list | grep -qw /var/log/netdata; then
+ dpkg-statoverride --remove /var/log/netdata
+ fi
+ ;;
+
+ *) ;;
+
+esac
+
+if [ "$1" = "remove" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper mask 'netdata.service' >/dev/null || true
+ fi
+fi
+
+if [ "$1" = "purge" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper purge 'netdata.service' >/dev/null || true
+ deb-systemd-helper unmask 'netdata.service' >/dev/null || true
+ fi
+fi
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/netdata/preinst b/packaging/cmake/pkg-files/deb/netdata/preinst
new file mode 100755
index 000000000..6dcf201d6
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/netdata/preinst
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ install)
+ if ! getent group netdata > /dev/null; then
+ addgroup --quiet --system netdata
+ fi
+
+ if ! getent passwd netdata > /dev/null; then
+ adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
+ fi
+
+ for item in docker nginx varnish haproxy adm nsd proxy squid ceph nobody I2C; do
+ if getent group $item > /dev/null 2>&1; then
+ usermod -a -G $item netdata
+ fi
+ done
+ # Netdata must be able to read /etc/pve/qemu-server/* and /etc/pve/lxc/*
+ # for reading VMs/containers names, CPU and memory limits on Proxmox.
+ if [ -d "/etc/pve" ] && getent group "www-data" > /dev/null 2>&1; then
+ usermod -a -G www-data netdata
+ fi
+ ;;
+esac
diff --git a/packaging/cmake/pkg-files/deb/plugin-apps/postinst b/packaging/cmake/pkg-files/deb/plugin-apps/postinst
new file mode 100755
index 000000000..f4621e595
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-apps/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/apps.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/apps.plugin
+ if ! setcap "cap_dac_read_search=eip cap_sys_ptrace=eip" /usr/libexec/netdata/plugins.d/apps.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/apps.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-apps/preinst b/packaging/cmake/pkg-files/deb/plugin-apps/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-apps/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/plugin-chartsd/postinst b/packaging/cmake/pkg-files/deb/plugin-chartsd/postinst
new file mode 100755
index 000000000..eddb51894
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-chartsd/postinst
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-plugin-chartsd.list | xargs -n 30 chown root:netdata
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-chartsd/preinst b/packaging/cmake/pkg-files/deb/plugin-chartsd/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-chartsd/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/plugin-cups/postinst b/packaging/cmake/pkg-files/deb/plugin-cups/postinst
new file mode 100755
index 000000000..2490a4729
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-cups/postinst
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/cups.plugin
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-cups/preinst b/packaging/cmake/pkg-files/deb/plugin-cups/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-cups/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/plugin-debugfs/postinst b/packaging/cmake/pkg-files/deb/plugin-debugfs/postinst
new file mode 100755
index 000000000..e07ed60ff
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-debugfs/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/debugfs.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/debugfs.plugin
+ if ! setcap "cap_dac_read_search=eip" /usr/libexec/netdata/plugins.d/debugfs.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/debugfs.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-debugfs/preinst b/packaging/cmake/pkg-files/deb/plugin-debugfs/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-debugfs/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/plugin-ebpf/postinst b/packaging/cmake/pkg-files/deb/plugin-ebpf/postinst
new file mode 100755
index 000000000..767702282
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-ebpf/postinst
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-plugin-ebpf.list | xargs -n 30 chown root:netdata
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/ebpf.plugin
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-ebpf/preinst b/packaging/cmake/pkg-files/deb/plugin-ebpf/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-ebpf/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/plugin-freeipmi/postinst b/packaging/cmake/pkg-files/deb/plugin-freeipmi/postinst
new file mode 100755
index 000000000..956c9c0de
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-freeipmi/postinst
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/freeipmi.plugin
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/freeipmi.plugin
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-freeipmi/preinst b/packaging/cmake/pkg-files/deb/plugin-freeipmi/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-freeipmi/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/plugin-go/postinst b/packaging/cmake/pkg-files/deb/plugin-go/postinst
new file mode 100755
index 000000000..2b60067ad
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-go/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/go.d.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/go.d.plugin
+ if ! setcap "cap_dac_read_search+epi cap_net_admin=eip cap_net_raw=eip" /usr/libexec/netdata/plugins.d/go.d.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/go.d.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-go/preinst b/packaging/cmake/pkg-files/deb/plugin-go/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-go/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/plugin-logs-management/postinst b/packaging/cmake/pkg-files/deb/plugin-logs-management/postinst
new file mode 100755
index 000000000..994b2caac
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-logs-management/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-plugin-logs-management.list | xargs -n 30 chown root:netdata
+ chmod 0750 /usr/libexec/netdata/plugins.d/logs-management.plugin
+ if ! setcap "cap_dac_read_search=eip cap_syslog=eip" /usr/libexec/netdata/plugins.d/logs-management.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/logs-management.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-logs-management/preinst b/packaging/cmake/pkg-files/deb/plugin-logs-management/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-logs-management/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/plugin-network-viewer/postinst b/packaging/cmake/pkg-files/deb/plugin-network-viewer/postinst
new file mode 100755
index 000000000..a388ded91
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-network-viewer/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/network-viewer.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/network-viewer.plugin
+ if ! setcap "cap_dac_read_search,cap_sys_admin,cap_sys_ptrace=eip" /usr/libexec/netdata/plugins.d/network-viewer.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/network-viewer.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-network-viewer/preinst b/packaging/cmake/pkg-files/deb/plugin-network-viewer/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-network-viewer/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/plugin-nfacct/postinst b/packaging/cmake/pkg-files/deb/plugin-nfacct/postinst
new file mode 100755
index 000000000..d3c8e0d25
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-nfacct/postinst
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/nfacct.plugin
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/nfacct.plugin
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-nfacct/preinst b/packaging/cmake/pkg-files/deb/plugin-nfacct/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-nfacct/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/plugin-perf/postinst b/packaging/cmake/pkg-files/deb/plugin-perf/postinst
new file mode 100755
index 000000000..f39d443fc
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-perf/postinst
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/perf.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/perf.plugin
+
+ if ! setcap cap_perfmon+ep /usr/libexec/netdata/plugins.d/perf.plugin 2>/dev/null; then
+ if ! setcap cap_sys_admin+ep /usr/libexec/netdata/plugins.d/perf.plugin 2>/dev/null; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/perf.plugin
+ fi
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-perf/preinst b/packaging/cmake/pkg-files/deb/plugin-perf/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-perf/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/plugin-pythond/postinst b/packaging/cmake/pkg-files/deb/plugin-pythond/postinst
new file mode 100755
index 000000000..5a8e8c694
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-pythond/postinst
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-plugin-pythond.list | xargs -n 30 chown root:netdata
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-pythond/preinst b/packaging/cmake/pkg-files/deb/plugin-pythond/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-pythond/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/plugin-slabinfo/postinst b/packaging/cmake/pkg-files/deb/plugin-slabinfo/postinst
new file mode 100755
index 000000000..149764469
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-slabinfo/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/slabinfo.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/slabinfo.plugin
+ if ! setcap "cap_dac_read_search=eip" /usr/libexec/netdata/plugins.d/slabinfo.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/slabinfo.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-slabinfo/preinst b/packaging/cmake/pkg-files/deb/plugin-slabinfo/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-slabinfo/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/plugin-systemd-journal/postinst b/packaging/cmake/pkg-files/deb/plugin-systemd-journal/postinst
new file mode 100755
index 000000000..9a2e94fc9
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-systemd-journal/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/systemd-journal.plugin
+ chmod 0750 /usr/libexec/netdata/plugins.d/systemd-journal.plugin
+ if ! setcap "cap_dac_read_search=eip" /usr/libexec/netdata/plugins.d/systemd-journal.plugin; then
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/systemd-journal.plugin
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-systemd-journal/preinst b/packaging/cmake/pkg-files/deb/plugin-systemd-journal/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-systemd-journal/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/plugin-xenstat/postinst b/packaging/cmake/pkg-files/deb/plugin-xenstat/postinst
new file mode 100755
index 000000000..c7bb35df0
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-xenstat/postinst
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure|reconfigure)
+ chown root:netdata /usr/libexec/netdata/plugins.d/xenstat.plugin
+ chmod -f 4750 /usr/libexec/netdata/plugins.d/xenstat.plugin
+ ;;
+esac
+
+exit 0
diff --git a/packaging/cmake/pkg-files/deb/plugin-xenstat/preinst b/packaging/cmake/pkg-files/deb/plugin-xenstat/preinst
new file mode 100755
index 000000000..57615ec06
--- /dev/null
+++ b/packaging/cmake/pkg-files/deb/plugin-xenstat/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