From f09848204fa5283d21ea43e262ee41aa578e1808 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 26 Aug 2024 10:15:24 +0200 Subject: Merging upstream version 1.47.0. Signed-off-by: Daniel Baumann --- packaging/PLATFORM_SUPPORT.md | 6 +- packaging/build-package.sh | 7 +- packaging/cmake/Modules/FindGo.cmake | 35 +++- packaging/cmake/Modules/NetdataEBPFCORE.cmake | 4 +- packaging/cmake/Modules/NetdataEBPFLegacy.cmake | 8 +- .../cmake/Modules/NetdataFetchContentExtra.cmake | 27 ++- packaging/cmake/Modules/NetdataGoTools.cmake | 6 +- packaging/cmake/Modules/NetdataJSONC.cmake | 24 ++- packaging/cmake/Modules/NetdataLibBPF.cmake | 2 +- packaging/cmake/Modules/NetdataProtobuf.cmake | 40 +++-- packaging/cmake/Modules/NetdataYAML.cmake | 21 ++- packaging/cmake/Modules/Packaging.cmake | 48 ++---- .../pkg-files/deb/plugin-logs-management/postinst | 15 -- .../pkg-files/deb/plugin-logs-management/preinst | 11 -- packaging/dag/nd.py | 3 - packaging/docker/README.md | 2 + packaging/installer/dependencies/alpine.sh | 30 ++-- packaging/installer/dependencies/arch.sh | 31 ++-- packaging/installer/dependencies/centos.sh | 7 - packaging/installer/dependencies/debian.sh | 8 - packaging/installer/dependencies/fedora.sh | 14 -- packaging/installer/dependencies/freebsd.sh | 19 +-- packaging/installer/dependencies/gentoo.sh | 34 ++-- packaging/installer/dependencies/ol.sh | 7 - packaging/installer/dependencies/opensuse.sh | 7 - packaging/installer/dependencies/rockylinux.sh | 7 - packaging/installer/dependencies/ubuntu.sh | 7 - packaging/installer/functions.sh | 2 - packaging/installer/install-required-packages.sh | 82 +-------- packaging/installer/installer.nsi | 128 ++++++++++++++ packaging/installer/kickstart.sh | 69 +++++--- packaging/installer/package-windows.sh | 43 +++++ packaging/makeself/jobs/70-netdata-git.install.sh | 1 - .../makeself/jobs/90-netdata-runtime-check.sh | 2 +- packaging/repoconfig/CMakeLists.txt | 32 ++-- packaging/repoconfig/deb.changelog | 18 ++ packaging/repoconfig/netdata.list.in | 2 - packaging/repoconfig/netdata.repo.dnf | 2 - packaging/repoconfig/netdata.sources.in | 15 ++ packaging/repoconfig/rpm.changelog | 6 + packaging/runtime-check.sh | 1 - packaging/utils/bash_execute.sh | 19 --- packaging/utils/clion-msys-mingw64-environment.bat | 17 -- packaging/utils/clion-msys-msys-environment.bat | 20 --- packaging/utils/compile-on-windows.sh | 71 -------- packaging/utils/coverity-scan.sh | 33 ++-- packaging/utils/find-dll-deps.sh | 16 ++ packaging/utils/installer.nsi | 34 ---- packaging/utils/package-windows.sh | 27 --- packaging/utils/protoc.bat | 9 - packaging/utils/windows-openssh-to-msys.bat | 118 ------------- packaging/version | 2 +- packaging/windows/NetdataWhite.ico | Bin 0 -> 15134 bytes packaging/windows/bash_execute.sh | 19 +++ packaging/windows/build.ps1 | 16 ++ .../windows/clion-msys-mingw64-environment.bat | 17 ++ packaging/windows/clion-msys-msys-environment.bat | 20 +++ packaging/windows/compile-on-windows.sh | 60 +++++++ packaging/windows/fetch-msys2-installer.py | 101 +++++++++++ packaging/windows/functions.ps1 | 31 ++++ packaging/windows/install-dependencies.ps1 | 84 ++++++++++ packaging/windows/installer.nsi | 186 +++++++++++++++++++++ packaging/windows/invoke-msys2.ps1 | 16 ++ packaging/windows/msys2-dependencies.sh | 50 ++++++ packaging/windows/package-windows.sh | 51 ++++++ packaging/windows/package.ps1 | 16 ++ packaging/windows/protoc.bat | 9 + packaging/windows/win-build-dir.sh | 20 +++ packaging/windows/windows-openssh-to-msys.bat | 118 +++++++++++++ 69 files changed, 1305 insertions(+), 708 deletions(-) delete mode 100755 packaging/cmake/pkg-files/deb/plugin-logs-management/postinst delete mode 100755 packaging/cmake/pkg-files/deb/plugin-logs-management/preinst create mode 100644 packaging/installer/installer.nsi create mode 100755 packaging/installer/package-windows.sh delete mode 100644 packaging/repoconfig/netdata.list.in create mode 100644 packaging/repoconfig/netdata.sources.in delete mode 100644 packaging/utils/bash_execute.sh delete mode 100644 packaging/utils/clion-msys-mingw64-environment.bat delete mode 100644 packaging/utils/clion-msys-msys-environment.bat delete mode 100644 packaging/utils/compile-on-windows.sh create mode 100644 packaging/utils/find-dll-deps.sh delete mode 100644 packaging/utils/installer.nsi delete mode 100644 packaging/utils/package-windows.sh delete mode 100644 packaging/utils/protoc.bat delete mode 100644 packaging/utils/windows-openssh-to-msys.bat create mode 100644 packaging/windows/NetdataWhite.ico create mode 100755 packaging/windows/bash_execute.sh create mode 100644 packaging/windows/build.ps1 create mode 100644 packaging/windows/clion-msys-mingw64-environment.bat create mode 100644 packaging/windows/clion-msys-msys-environment.bat create mode 100755 packaging/windows/compile-on-windows.sh create mode 100755 packaging/windows/fetch-msys2-installer.py create mode 100644 packaging/windows/functions.ps1 create mode 100644 packaging/windows/install-dependencies.ps1 create mode 100644 packaging/windows/installer.nsi create mode 100644 packaging/windows/invoke-msys2.ps1 create mode 100755 packaging/windows/msys2-dependencies.sh create mode 100755 packaging/windows/package-windows.sh create mode 100644 packaging/windows/package.ps1 create mode 100644 packaging/windows/protoc.bat create mode 100644 packaging/windows/win-build-dir.sh create mode 100644 packaging/windows/windows-openssh-to-msys.bat (limited to 'packaging') diff --git a/packaging/PLATFORM_SUPPORT.md b/packaging/PLATFORM_SUPPORT.md index c0e66f290..ad1cd4168 100644 --- a/packaging/PLATFORM_SUPPORT.md +++ b/packaging/PLATFORM_SUPPORT.md @@ -67,7 +67,6 @@ to work on these platforms with minimal user effort. | Docker | 19.03 or newer | x86\_64, i386, ARMv7, AArch64, POWER8+ | See our [Docker documentation](/packaging/docker/README.md) for more info on using Netdata on Docker | | Debian | 12.x | x86\_64, i386, ARMv7, AArch64 | | | Debian | 11.x | x86\_64, i386, ARMv7, AArch64 | | -| Debian | 10.x | x86\_64, i386, ARMv7, AArch64 | | | Fedora | 40 | x86\_64, AArch64 | | | Fedora | 39 | x86\_64, AArch64 | | | openSUSE | Leap 15.5 | x86\_64, AArch64 | | @@ -78,7 +77,6 @@ to work on these platforms with minimal user effort. | Red Hat Enterprise Linux | 8.x | x86\_64, AArch64 | | | Red Hat Enterprise Linux | 7.x | x86\_64 | | | Ubuntu | 24.04 | x86\_64, AArch64, ARMv7 | | -| Ubuntu | 23.10 | x86\_64, AArch64, ARMv7 | | | Ubuntu | 22.04 | x86\_64, ARMv7, AArch64 | | | Ubuntu | 20.04 | x86\_64, ARMv7, AArch64 | | @@ -157,14 +155,14 @@ This is a list of platforms that we have supported in the recent past but no lon | Alpine Linux | 3.16 | EOL as of 2024-05-23 | | Alpine Linux | 3.15 | EOL as of 2023-11-01 | | Alpine Linux | 3.14 | EOL as of 2023-05-01 | -| Debian | 9.x | EOL as of 2022-06-30 | +| Debian | 10.x | EOL as of 2024-07-01 | | Fedora | 38 | EOL as of 2024-05-14 | | Fedora | 37 | EOL as of 2023-12-05 | | openSUSE | Leap 15.4 | EOL as of 2023-12-07 | | openSUSE | Leap 15.3 | EOL as of 2022-12-01 | +| Ubuntu | 23.10 | EOL as of 2024-07-01 | | Ubuntu | 23.04 | EOL as of 2024-01-20 | | Ubuntu | 22.10 | EOL as of 2023-07-20 | -| Ubuntu | 21.10 | EOL as of 2022-07-31 | | Ubuntu | 18.04 | EOL as of 2023-04-02 | ## Static builds diff --git a/packaging/build-package.sh b/packaging/build-package.sh index ea50f4438..453e167f4 100755 --- a/packaging/build-package.sh +++ b/packaging/build-package.sh @@ -18,7 +18,7 @@ SCRIPT_SOURCE="$( )" SOURCE_DIR="$(dirname "$(dirname "${SCRIPT_SOURCE}")")" -CMAKE_ARGS="-S ${SOURCE_DIR} -B ${BUILD_DIR} -G Ninja" +CMAKE_ARGS="-S ${SOURCE_DIR} -B ${BUILD_DIR}" add_cmake_option() { CMAKE_ARGS="${CMAKE_ARGS} -D${1}=${2}" @@ -38,7 +38,6 @@ add_cmake_option ENABLE_PLUGIN_DEBUGFS On add_cmake_option ENABLE_PLUGIN_FREEIPMI On add_cmake_option ENABLE_PLUGIN_GO On add_cmake_option ENABLE_PLUGIN_LOCAL_LISTENERS On -add_cmake_option ENABLE_PLUGIN_LOGS_MANAGEMENT Off add_cmake_option ENABLE_PLUGIN_NFACCT On add_cmake_option ENABLE_PLUGIN_PERF On add_cmake_option ENABLE_PLUGIN_SLABINFO On @@ -89,8 +88,8 @@ else fi # shellcheck disable=SC2086 -cmake ${CMAKE_ARGS} -cmake --build "${BUILD_DIR}" --parallel "$(nproc)" +cmake ${CMAKE_ARGS} -G Ninja +cmake --build "${BUILD_DIR}" --parallel "$(nproc)" -- -k 1 if [ "${ENABLE_SENTRY}" = "true" ] && [ "${UPLOAD_SENTRY}" = "true" ]; then sentry-cli debug-files upload -o netdata-inc -p netdata-agent --force-foreground --log-level=debug --wait --include-sources build/netdata diff --git a/packaging/cmake/Modules/FindGo.cmake b/packaging/cmake/Modules/FindGo.cmake index 454a0051e..69e23fda6 100644 --- a/packaging/cmake/Modules/FindGo.cmake +++ b/packaging/cmake/Modules/FindGo.cmake @@ -15,8 +15,22 @@ if(GO_FOUND) return() endif() -# Two passes are needed here so that we prefer a copy in `/usr/local/go/bin` over a system copy. -find_program(GO_EXECUTABLE go PATHS /usr/local/go/bin DOC "Go toolchain" NO_DEFAULT_PATH) +# The complexity below is needed to account for the complex rules we use for finding the Go install. +# +# If GOROOT is set, we honor that. Otherwise, we check known third-party install paths for the platform in question +# and fall back to looking in PATH. For the specific case of MSYS2, we prefer a Windows install over an MSYS2 install. +if(DEFINED $ENV{GOROOT}) + find_program(GO_EXECUTABLE go PATHS "$ENV{GOROOT}/bin" DOC "Go toolchain" NO_DEFAULT_PATH) + set(GO_ROOT $ENV{GOROOT}) +elseif(OS_WINDOWS) + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_program(GO_EXECUTABLE go PATHS C:/go/bin "C:/Program Files/go/bin" DOC "Go toolchain" NO_DEFAULT_PATH) + else() + find_program(GO_EXECUTABLE go PATHS /c/go/bin "/c/Program Files/go/bin" /mingw64/lib/go/bin /ucrt64/lib/go/bin /clang64/lib/go/bin DOC "Go toolchain" NO_DEFAULT_PATH) + endif() +else() + find_program(GO_EXECUTABLE go PATHS /usr/local/go/bin DOC "Go toolchain" NO_DEFAULT_PATH) +endif() find_program(GO_EXECUTABLE go DOC "Go toolchain") if (GO_EXECUTABLE) @@ -28,12 +42,27 @@ if (GO_EXECUTABLE) if (RESULT EQUAL 0) string(REGEX MATCH "go([0-9]+\\.[0-9]+(\\.[0-9]+)?)" GO_VERSION_STRING "${GO_VERSION_STRING}") string(REGEX MATCH "([0-9]+\\.[0-9]+(\\.[0-9]+)?)" GO_VERSION_STRING "${GO_VERSION_STRING}") + else() + unset(GO_VERSION_STRING) + endif() + + if(NOT DEFINED GO_ROOT) + execute_process( + COMMAND ${GO_EXECUTABLE} env GOROOT + OUTPUT_VARIABLE GO_ROOT + RESULT_VARIABLE RESULT + ) + if(RESULT EQUAL 0) + string(REGEX REPLACE "\n$" "" GO_ROOT "${GO_ROOT}") + else() + unset(GO_ROOT) + endif() endif() endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Go - REQUIRED_VARS GO_EXECUTABLE + REQUIRED_VARS GO_EXECUTABLE GO_ROOT VERSION_VAR GO_VERSION_STRING ) diff --git a/packaging/cmake/Modules/NetdataEBPFCORE.cmake b/packaging/cmake/Modules/NetdataEBPFCORE.cmake index 936124dee..f4c918bfe 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.3/netdata-ebpf-co-re-glibc-v1.4.3.tar.xz - URL_HASH SHA256=52a8cf65b4659d173ec3d9fb69315ba48c1f091d1882968748b37a8f7bf9f92d + 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 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 7658a0e94..12dfce486 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 73cfe6ceb0098447c2a016d8f9674ad8a80ba6dd61cfdd8646710a0dc5c52d9f) + set(_hash 1c0c8f1177514e9e21a23c28841406595e57b7cfacd93746ff2d6b25987b94a6) set(_libc "static") elseif(_libc STREQUAL "glibc") - set(_hash e9b89ff215c56f04249a2169bee15cdae6e61ef913468add258719e8afe6eac2) + set(_hash e365a76a2bb25190f1d91e4dea2cfc5ff5db63b5238fbfbc89f72755cf85a12c) elseif(_libc STREQUAL "musl") - set(_hash 1574e3bbdcac7dae534d783fa6fc6452268240d7477aefd87fadc4e7f705d48e) + set(_hash ec14dcdfa29d4fba1cea6763740b9d37683515bde88a1a29b6e7c70ce01a604d) 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 https://github.com/netdata/kernel-collector/releases/download/v1.4.5.1/netdata-kernel-collector-${_libc}-v1.4.5.1.tar.xz URL_HASH SHA256=${_hash} SOURCE_DIR "${ebpf-legacy_SOURCE_DIR}" CONFIGURE_COMMAND "" diff --git a/packaging/cmake/Modules/NetdataFetchContentExtra.cmake b/packaging/cmake/Modules/NetdataFetchContentExtra.cmake index cc70448de..e82fe413b 100644 --- a/packaging/cmake/Modules/NetdataFetchContentExtra.cmake +++ b/packaging/cmake/Modules/NetdataFetchContentExtra.cmake @@ -18,11 +18,15 @@ macro(FetchContent_MakeAvailable_NoInstall name) include(FetchContent) - FetchContent_GetProperties(${name}) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + FetchContent_MakeAvailable(${name}) + else() + FetchContent_GetProperties(${name}) - if(NOT ${name}_POPULATED) - FetchContent_Populate(${name}) - add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL) + if(NOT ${name}_POPULATED) + FetchContent_Populate(${name}) + add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() endif() endmacro() @@ -34,8 +38,17 @@ endmacro() # # This needs to be explicitly included for any sub-project that needs # to be built for the target system. +# +# This also needs to _NOT_ have any generator expressions, as they are not +# supported for the required usage of this variable in CMake 3.30 or newer. set(NETDATA_PROPAGATE_TOOLCHAIN_ARGS "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - $<$:-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET} - $<$:-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}") + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") + +if(DEFINED CMAKE_C_COMPILER_TARGET) + set(NETDATA_PROPAGATE_TOOLCHAIN_ARGS "${NETDATA_PROPAGATE_TOOLCHAIN_ARGS} -DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}") +endif() + +if(DEFINED CMAKE_CXX_COMPILER_TARGET) + set(NETDATA_PROPAGATE_TOOLCHAIN_ARGS "${NETDATA_PROPAGATE_TOOLCHAIN_ARGS} -DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}") +endif() diff --git a/packaging/cmake/Modules/NetdataGoTools.cmake b/packaging/cmake/Modules/NetdataGoTools.cmake index 6526c8d7b..c8b8b9c01 100644 --- a/packaging/cmake/Modules/NetdataGoTools.cmake +++ b/packaging/cmake/Modules/NetdataGoTools.cmake @@ -5,9 +5,9 @@ # SPDX-License-Identifier: GPL if(CMAKE_BUILD_TYPE STREQUAL Debug) - set(GO_LDFLAGS "-X github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo.Version=${NETDATA_VERSION_STRING}") + set(GO_LDFLAGS "-X github.com/netdata/netdata/go/plugins/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_STRING}") + set(GO_LDFLAGS "-w -s -X github.com/netdata/netdata/go/plugins/pkg/buildinfo.Version=${NETDATA_VERSION_STRING}") endif() # add_go_target: Add a new target that needs to be built using the Go toolchain. @@ -33,7 +33,7 @@ macro(add_go_target target output build_src build_dir) add_custom_command( OUTPUT ${output} - COMMAND "${CMAKE_COMMAND}" -E env CGO_ENABLED=0 "${GO_EXECUTABLE}" build -buildvcs=false -ldflags "${GO_LDFLAGS}" -o "${CMAKE_BINARY_DIR}/${output}" "./${build_dir}" + COMMAND "${CMAKE_COMMAND}" -E env GOROOT=${GO_ROOT} CGO_ENABLED=0 GOPROXY=https://proxy.golang.org,direct "${GO_EXECUTABLE}" build -buildvcs=false -ldflags "${GO_LDFLAGS}" -o "${CMAKE_BINARY_DIR}/${output}" "./${build_dir}" DEPENDS ${${target}_DEPS} COMMENT "Building Go component ${output}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/${build_src}" diff --git a/packaging/cmake/Modules/NetdataJSONC.cmake b/packaging/cmake/Modules/NetdataJSONC.cmake index 9bbb424e1..89ec70265 100644 --- a/packaging/cmake/Modules/NetdataJSONC.cmake +++ b/packaging/cmake/Modules/NetdataJSONC.cmake @@ -37,11 +37,23 @@ function(netdata_bundle_jsonc) 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} - ) + set(repo https://github.com/json-c/json-c) + set(tag b4c371fa0cbc4dcbaccc359ce9e957a22988fb34) # json-c-0.17-20230812 + + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + FetchContent_Declare(json-c + GIT_REPOSITORY ${repo} + GIT_TAG ${tag} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + EXCLUDE_FROM_ALL + ) + else() + FetchContent_Declare(json-c + GIT_REPOSITORY ${repo} + GIT_TAG ${tag} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + ) + endif() FetchContent_MakeAvailable_NoInstall(json-c) @@ -63,7 +75,7 @@ macro(netdata_detect_jsonc) endif() if(NOT JSONC_FOUND) - set(ENABLE_BUNDLED_JSONC True PARENT_SCOPE) + set(ENABLE_BUNDLED_JSONC True) netdata_bundle_jsonc() set(NETDATA_JSONC_LDFLAGS json-c) set(NETDATA_JSONC_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/include) diff --git a/packaging/cmake/Modules/NetdataLibBPF.cmake b/packaging/cmake/Modules/NetdataLibBPF.cmake index 17a26a10f..9c3bf6d2f 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 3d78a726c618560ad7fb03ceaf0fd03e8b2656b4) # v1.4.3p_netdata + set(_libbpf_tag 6923eb970e22682eaedff79f5be4f9934b99cf50) # v1.4.5p_netdata endif() if(DEFINED BUILD_SHARED_LIBS) diff --git a/packaging/cmake/Modules/NetdataProtobuf.cmake b/packaging/cmake/Modules/NetdataProtobuf.cmake index c142d6566..62448440e 100644 --- a/packaging/cmake/Modules/NetdataProtobuf.cmake +++ b/packaging/cmake/Modules/NetdataProtobuf.cmake @@ -29,13 +29,23 @@ function(netdata_bundle_protobuf) set(ABSL_PROPAGATE_CXX_STD On) set(ABSL_ENABLE_INSTALL Off) set(BUILD_SHARED_LIBS Off) + set(absl_repo https://github.com/abseil/abseil-cpp) 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} - ) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + FetchContent_Declare(absl + GIT_REPOSITORY ${absl_repo} + GIT_TAG ${ABSL_TAG} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + EXCLUDE_FROM_ALL + ) + else() + FetchContent_Declare(absl + GIT_REPOSITORY ${absl_repo} + GIT_TAG ${ABSL_TAG} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + ) + endif() FetchContent_MakeAvailable_NoInstall(absl) message(STATUS "Finished preparing bundled Abseil") endif() @@ -44,13 +54,23 @@ function(netdata_bundle_protobuf) set(protobuf_BUILD_LIBPROTOC Off) set(protobuf_BUILD_TESTS Off) set(protobuf_BUILD_SHARED_LIBS Off) + set(protobuf_repo https://github.com/protocolbuffers/protobuf) message(STATUS "Preparing bundled Protobuf") - FetchContent_Declare(protobuf - GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git - GIT_TAG ${PROTOBUF_TAG} - CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} - ) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + FetchContent_Declare(protobuf + GIT_REPOSITORY ${protobuf_repo} + GIT_TAG ${PROTOBUF_TAG} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + EXCLUDE_FROM_ALL + ) + else() + FetchContent_Declare(protobuf + GIT_REPOSITORY ${protobuf_repo} + GIT_TAG ${PROTOBUF_TAG} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + ) + endif() FetchContent_MakeAvailable_NoInstall(protobuf) message(STATUS "Finished preparing bundled Protobuf.") diff --git a/packaging/cmake/Modules/NetdataYAML.cmake b/packaging/cmake/Modules/NetdataYAML.cmake index f2f9b404e..9fc713254 100644 --- a/packaging/cmake/Modules/NetdataYAML.cmake +++ b/packaging/cmake/Modules/NetdataYAML.cmake @@ -19,12 +19,23 @@ function(netdata_bundle_libyaml) endif() set(FETCHCONTENT_FULLY_DISCONNECTED Off) + set(repo https://github.com/yaml/libyaml) + set(tag 2c891fc7a770e8ba2fec34fc6b545c672beb37e6) # v0.2.5 - FetchContent_Declare(yaml - GIT_REPOSITORY https://github.com/yaml/libyaml - GIT_TAG 2c891fc7a770e8ba2fec34fc6b545c672beb37e6 # v0.2.5 - CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} - ) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + FetchContent_Declare(yaml + GIT_REPOSITORY ${repo} + GIT_TAG ${tag} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + EXCLUDE_FROM_ALL + ) + else() + FetchContent_Declare(yaml + GIT_REPOSITORY ${repo} + GIT_TAG ${tag} + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} + ) + endif() FetchContent_MakeAvailable_NoInstall(yaml) endfunction() diff --git a/packaging/cmake/Modules/Packaging.cmake b/packaging/cmake/Modules/Packaging.cmake index 1dd2328cd..663dbe27c 100644 --- a/packaging/cmake/Modules/Packaging.cmake +++ b/packaging/cmake/Modules/Packaging.cmake @@ -56,43 +56,42 @@ 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})") + "netdata-plugin-cups, netdata-plugin-freeipmi") 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})") + "netdata-plugin-systemd-journal, \ +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 (= ${CPACK_PACKAGE_VERSION})") -list(APPEND _main_deps "netdata-plugin-pythond (= ${CPACK_PACKAGE_VERSION})") +list(APPEND _main_deps "netdata-plugin-chartsd") +list(APPEND _main_deps "netdata-plugin-pythond") if(ENABLE_PLUGIN_APPS) - list(APPEND _main_deps "netdata-plugin-apps (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-apps") endif() if(ENABLE_PLUGIN_GO) - list(APPEND _main_deps "netdata-plugin-go (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-go") endif() if(ENABLE_PLUGIN_DEBUGFS) - list(APPEND _main_deps "netdata-plugin-debugfs (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-debugfs") endif() if(ENABLE_PLUGIN_NFACCT) - list(APPEND _main_deps "netdata-plugin-nfacct (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-nfacct") endif() if(ENABLE_PLUGIN_SLABINFO) - list(APPEND _main_deps "netdata-plugin-slabinfo (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-slabinfo") endif() if(ENABLE_PLUGIN_PERF) - list(APPEND _main_deps "netdata-plugin-perf (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-perf") endif() if(ENABLE_PLUGIN_EBPF) - list(APPEND _main_deps "netdata-plugin-ebpf (= ${CPACK_PACKAGE_VERSION})") + list(APPEND _main_deps "netdata-plugin-ebpf") endif() list(JOIN _main_deps ", " CPACK_DEBIAN_NETDATA_PACKAGE_DEPENDS) @@ -279,26 +278,6 @@ set(CPACK_DEBIAN_PLUGIN-GO_PACKAGE_CONTROL_EXTRA 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 # @@ -477,9 +456,6 @@ 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() diff --git a/packaging/cmake/pkg-files/deb/plugin-logs-management/postinst b/packaging/cmake/pkg-files/deb/plugin-logs-management/postinst deleted file mode 100755 index 994b2caac..000000000 --- a/packaging/cmake/pkg-files/deb/plugin-logs-management/postinst +++ /dev/null @@ -1,15 +0,0 @@ -#!/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 deleted file mode 100755 index 57615ec06..000000000 --- a/packaging/cmake/pkg-files/deb/plugin-logs-management/preinst +++ /dev/null @@ -1,11 +0,0 @@ -#!/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/dag/nd.py b/packaging/dag/nd.py index d59adf30a..c5dda2c8d 100644 --- a/packaging/dag/nd.py +++ b/packaging/dag/nd.py @@ -258,9 +258,6 @@ class NetdataInstaller: if FeatureFlags.ExtendedBPF not in self.features: args.append("--disable-ebpf") - if FeatureFlags.LogsManagement not in self.features: - args.append("--disable-logsmanagement") - if FeatureFlags.MachineLearning not in self.features: args.append("--disable-ml") diff --git a/packaging/docker/README.md b/packaging/docker/README.md index 204e17ad1..6deb0cfa9 100644 --- a/packaging/docker/README.md +++ b/packaging/docker/README.md @@ -378,6 +378,8 @@ to Caddyfile. ### With Docker socket proxy +> **Note**: Using Netdata with a Docker socket proxy might have some features not working as expected. It hasn't been fully tested by the Netdata team. + Deploy a Docker socket proxy that accepts and filters out requests using something like [HAProxy](/docs/netdata-agent/configuration/running-the-netdata-agent-behind-a-reverse-proxy/Running-behind-haproxy.md) or [CetusGuard](https://github.com/hectorm/cetusguard) so that it restricts connections to read-only access to diff --git a/packaging/installer/dependencies/alpine.sh b/packaging/installer/dependencies/alpine.sh index 88d63c8a7..77a6fc828 100755 --- a/packaging/installer/dependencies/alpine.sh +++ b/packaging/installer/dependencies/alpine.sh @@ -9,33 +9,27 @@ DONT_WAIT=0 package_tree=" alpine-sdk - coreutils - git - gcc - g++ - automake - autoconf cmake - make - libatomic - libtool - pkgconfig - tar + coreutils curl + elfutils-dev + g++ + gcc + git gzip + json-c-dev + libatomic + libmnl-dev libuv-dev lz4-dev + make openssl-dev - elfutils-dev + pkgconfig python3 - zlib-dev + tar util-linux-dev - libmnl-dev - json-c-dev - musl-fts-dev - bison - flex yaml-dev + zlib-dev " usage() { diff --git a/packaging/installer/dependencies/arch.sh b/packaging/installer/dependencies/arch.sh index 30be834be..7b0c9c54f 100755 --- a/packaging/installer/dependencies/arch.sh +++ b/packaging/installer/dependencies/arch.sh @@ -8,32 +8,25 @@ NON_INTERACTIVE=0 DONT_WAIT=0 declare -a package_tree=( - gcc - make - autoconf - autoconf-archive - autogen - automake - libtool + binutils cmake - zlib - util-linux - libmnl + curl + gcc + git + gzip json-c - libyaml + libelf + libmnl libuv + libyaml lz4 + make openssl - libelf - git pkgconfig - tar - curl - gzip python3 - binutils - bison - flex + tar + util-linux + zlib ) usage() { diff --git a/packaging/installer/dependencies/centos.sh b/packaging/installer/dependencies/centos.sh index 532a0a71e..b647b2304 100755 --- a/packaging/installer/dependencies/centos.sh +++ b/packaging/installer/dependencies/centos.sh @@ -5,15 +5,9 @@ set -e declare -a package_tree=( - autoconf - autoconf-archive - automake - bison cmake - cmake3 curl elfutils-libelf-devel - flex findutils gcc gcc-c++ @@ -22,7 +16,6 @@ declare -a package_tree=( json-c-devel libatomic libmnl-devel - libtool libuuid-devel libuv-devel libyaml-devel diff --git a/packaging/installer/dependencies/debian.sh b/packaging/installer/dependencies/debian.sh index 692a71191..099963afe 100755 --- a/packaging/installer/dependencies/debian.sh +++ b/packaging/installer/dependencies/debian.sh @@ -8,14 +8,8 @@ NON_INTERACTIVE=0 DONT_WAIT=0 package_tree=" - autoconf - autoconf-archive - autogen - automake - bison cmake curl - flex g++ gcc git @@ -27,12 +21,10 @@ package_tree=" libmnl-dev libssl-dev libsystemd-dev - libtool libuv1-dev libyaml-dev make pkg-config - python python3 tar uuid-dev diff --git a/packaging/installer/dependencies/fedora.sh b/packaging/installer/dependencies/fedora.sh index fc30b6113..151746377 100755 --- a/packaging/installer/dependencies/fedora.sh +++ b/packaging/installer/dependencies/fedora.sh @@ -17,23 +17,11 @@ os_version() { fi } -if [[ $(os_version) -gt 24 ]]; then - ulogd_pkg= -else - ulogd_pkg=ulogd -fi - declare -a package_tree=( - autoconf - autoconf-archive - autogen - automake - bison cmake curl elfutils-libelf-devel findutils - flex gcc gcc-c++ git @@ -41,7 +29,6 @@ declare -a package_tree=( json-c-devel libatomic libmnl-devel - libtool libuuid-devel libuv-devel libyaml-devel @@ -53,7 +40,6 @@ declare -a package_tree=( systemd-devel tar zlib-devel - "${ulogd_pkg}" ) usage() { diff --git a/packaging/installer/dependencies/freebsd.sh b/packaging/installer/dependencies/freebsd.sh index eadbcfa98..91fd2959c 100755 --- a/packaging/installer/dependencies/freebsd.sh +++ b/packaging/installer/dependencies/freebsd.sh @@ -8,26 +8,19 @@ NON_INTERACTIVE=0 DONT_WAIT=0 package_tree=" - git - autoconf - autoconf-archive - autogen - automake - libtool - pkgconf cmake curl - gzip - lzlib e2fsprogs-libuuid + git + gzip json-c - libyaml - libuv liblz4 + libuv + libyaml + lzlib openssl + pkgconf python3 - bison - flex " prompt() { diff --git a/packaging/installer/dependencies/gentoo.sh b/packaging/installer/dependencies/gentoo.sh index 9cf7f281a..58e805a2d 100755 --- a/packaging/installer/dependencies/gentoo.sh +++ b/packaging/installer/dependencies/gentoo.sh @@ -8,32 +8,26 @@ NON_INTERACTIVE=0 DONT_WAIT=0 package_tree=" + app-alternatives/gzip + app-alternatives/tar + app-arch/lz4 + dev-lang/python + dev-libs/json-c + dev-libs/libuv + dev-libs/libyaml + dev-libs/openssl + dev-util/cmake dev-vcs/git + net-libs/libmnl + net-misc/curl sys-apps/findutils + sys-apps/util-linux sys-devel/gcc sys-devel/make - sys-devel/autoconf - sys-devel/autoconf-archive - sys-devel/autogen - sys-devel/automake - virtual/pkgconfig - dev-util/cmake - app-arch/tar - net-misc/curl - app-arch/gzip - sys-apps/util-linux - net-libs/libmnl - dev-libs/json-c - dev-libs/libyaml - dev-libs/libuv - app-arch/lz4 - dev-libs/openssl virtual/libelf - dev-lang/python - dev-libs/libuv - sys-devel/bison - sys-devel/flex + virtual/pkgconfig " + usage() { cat << EOF OPTIONS: diff --git a/packaging/installer/dependencies/ol.sh b/packaging/installer/dependencies/ol.sh index 2dc10cee5..fca904a9b 100755 --- a/packaging/installer/dependencies/ol.sh +++ b/packaging/installer/dependencies/ol.sh @@ -8,15 +8,9 @@ NON_INTERACTIVE=0 DONT_WAIT=0 declare -a package_tree=( - autoconf - autoconf-archive - autogen - automake - bison cmake curl elfutils-libelf-devel - flex gcc gcc-c++ git @@ -24,7 +18,6 @@ declare -a package_tree=( json-c-devel libatomic libmnl-devel - libtool libuuid-devel libuv-devel libyaml-devel diff --git a/packaging/installer/dependencies/opensuse.sh b/packaging/installer/dependencies/opensuse.sh index ecf1268fc..4fba64095 100755 --- a/packaging/installer/dependencies/opensuse.sh +++ b/packaging/installer/dependencies/opensuse.sh @@ -10,14 +10,8 @@ NON_INTERACTIVE=0 DONT_WAIT=0 declare -a package_tree=( - autoconf - autoconf-archive - autogen - automake - bison cmake curl - flex gcc gcc-c++ git @@ -28,7 +22,6 @@ declare -a package_tree=( liblz4-devel libmnl-devel libopenssl-devel - libtool libuuid-devel libuv-devel libyaml-devel diff --git a/packaging/installer/dependencies/rockylinux.sh b/packaging/installer/dependencies/rockylinux.sh index cc8d45204..921fd29bf 100755 --- a/packaging/installer/dependencies/rockylinux.sh +++ b/packaging/installer/dependencies/rockylinux.sh @@ -8,16 +8,10 @@ NON_INTERACTIVE=0 DONT_WAIT=0 declare -a package_tree=( - autoconf - autoconf-archive - autogen - automake - bison cmake curl elfutils-libelf-devel findutils - flex gcc gcc-c++ git @@ -25,7 +19,6 @@ declare -a package_tree=( json-c-devel libatomic libmnl-devel - libtool libuuid-devel libuv-devel libyaml-devel diff --git a/packaging/installer/dependencies/ubuntu.sh b/packaging/installer/dependencies/ubuntu.sh index e223ca384..c6e5a0b36 100755 --- a/packaging/installer/dependencies/ubuntu.sh +++ b/packaging/installer/dependencies/ubuntu.sh @@ -8,14 +8,8 @@ NON_INTERACTIVE=0 DONT_WAIT=0 package_tree=" - autoconf - autoconf-archive - autogen - automake - bison cmake curl - flex g++ gcc git @@ -27,7 +21,6 @@ package_tree=" libmnl-dev libssl-dev libsystemd-dev - libtool libuv1-dev libyaml-dev make diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh index 6143eedb4..c339ac87c 100644 --- a/packaging/installer/functions.sh +++ b/packaging/installer/functions.sh @@ -340,8 +340,6 @@ prepare_cmake_options() { enable_feature PLUGIN_LOCAL_LISTENERS "${IS_LINUX}" enable_feature PLUGIN_NETWORK_VIEWER "${IS_LINUX}" enable_feature PLUGIN_EBPF "${ENABLE_EBPF:-0}" - enable_feature PLUGIN_LOGS_MANAGEMENT "${ENABLE_LOGS_MANAGEMENT:-0}" - enable_feature LOGS_MANAGEMENT_TESTS "${ENABLE_LOGS_MANAGEMENT_TESTS:-0}" enable_feature ACLK "${ENABLE_CLOUD:-1}" enable_feature CLOUD "${ENABLE_CLOUD:-1}" diff --git a/packaging/installer/install-required-packages.sh b/packaging/installer/install-required-packages.sh index 96bc4aee7..e97902026 100755 --- a/packaging/installer/install-required-packages.sh +++ b/packaging/installer/install-required-packages.sh @@ -632,74 +632,12 @@ declare -A pkg_coreutils=( ['default']="NOTREQUIRED" ) -declare -A pkg_autoconf=( - ['gentoo']="sys-devel/autoconf" - ['clearlinux']="c-basic" - ['default']="autoconf" -) - -# required to compile netdata with --enable-sse -# https://github.com/firehol/netdata/pull/450 -declare -A pkg_autoconf_archive=( - ['gentoo']="sys-devel/autoconf-archive" - ['clearlinux']="c-basic" - ['alpine']="WARNING|" - ['default']="autoconf-archive" - - # exceptions - ['centos-6']="WARNING|" - ['rhel-6']="WARNING|" - ['rhel-7']="WARNING|" -) - -declare -A pkg_autogen=( - ['gentoo']="sys-devel/autogen" - ['clearlinux']="c-basic" - ['alpine']="WARNING|" - ['default']="autogen" - - # exceptions - ['centos-6']="WARNING|" - ['rhel-6']="WARNING|" - ['centos-9']="NOTREQUIRED|" - ['rhel-9']="NOTREQUIRED|" -) - -declare -A pkg_automake=( - ['gentoo']="sys-devel/automake" - ['clearlinux']="c-basic" - ['default']="automake" -) - -# Required to build libwebsockets and libmosquitto on some systems. declare -A pkg_cmake=( ['gentoo']="dev-util/cmake" ['clearlinux']="c-basic" ['default']="cmake" ) -# bison and flex are required by Fluent-Bit -declare -A pkg_bison=( - ['default']="bison" -) - -declare -A pkg_flex=( - ['default']="flex" -) - -# fts-dev is required by Fluent-Bit on Alpine -declare -A pkg_fts_dev=( - ['default']="NOTREQUIRED" - ['alpine']="musl-fts-dev" - ['alpine-3.16.9']="fts-dev" -) - -# cmake3 is required by Fluent-Bit on CentOS 7 -declare -A pkg_cmake3=( - ['default']="NOTREQUIRED" - ['centos-7']="cmake3" -) - declare -A pkg_json_c_dev=( ['alpine']="json-c-dev" ['arch']="json-c" @@ -772,13 +710,13 @@ declare -A pkg_curl=( ) declare -A pkg_gzip=( - ['gentoo']="app-arch/gzip" + ['gentoo']="app-alternatives/gzip" ['macos']="NOTREQUIRED" ['default']="gzip" ) declare -A pkg_tar=( - ['gentoo']="app-arch/tar" + ['gentoo']="app-alternatives/tar" ['clearlinux']="os-core-update" ['macos']="NOTREQUIRED" ['freebsd']="NOTREQUIRED" @@ -1249,14 +1187,9 @@ packages() { require_cmd gcc-multilib || suitable_package gcc require_cmd g++ || require_cmd clang++ || suitable_package gxx - require_cmd make || suitable_package make - require_cmd autoconf || suitable_package autoconf - suitable_package autoconf-archive - require_cmd autogen || suitable_package autogen - require_cmd automake || suitable_package automake require_cmd pkg-config || suitable_package pkg-config require_cmd cmake || suitable_package cmake - require_cmd cmake3 || suitable_package cmake3 + require_cmd make || suitable_package make # ------------------------------------------------------------------------- # debugging tools for development @@ -1279,8 +1212,6 @@ packages() { require_cmd tar || suitable_package tar require_cmd curl || suitable_package curl require_cmd gzip || suitable_package gzip - require_cmd bison || suitable_package bison - require_cmd flex || suitable_package flex fi # ------------------------------------------------------------------------- @@ -1312,7 +1243,6 @@ packages() { suitable_package libuuid-dev suitable_package libmnl-dev suitable_package json-c-dev - suitable_package fts-dev suitable_package libyaml-dev suitable_package libsystemd-dev suitable_package pcre2 @@ -1348,9 +1278,6 @@ packages() { if [ "${PACKAGES_NETDATA_PYTHON}" -ne 0 ]; then require_cmd python || suitable_package python - - # suitable_package python-requests - # suitable_package python-pip fi # ------------------------------------------------------------------------- @@ -1358,9 +1285,6 @@ packages() { if [ "${PACKAGES_NETDATA_PYTHON3}" -ne 0 ]; then require_cmd python3 || suitable_package python3 - - # suitable_package python3-requests - # suitable_package python3-pip fi # ------------------------------------------------------------------------- diff --git a/packaging/installer/installer.nsi b/packaging/installer/installer.nsi new file mode 100644 index 000000000..c14ccb599 --- /dev/null +++ b/packaging/installer/installer.nsi @@ -0,0 +1,128 @@ +!include "MUI2.nsh" +!include "nsDialogs.nsh" +!include "FileFunc.nsh" + +Name "Netdata" +Outfile "netdata-installer.exe" +InstallDir "$PROGRAMFILES\Netdata" +RequestExecutionLevel admin + +!define MUI_ICON "NetdataWhite.ico" +!define MUI_UNICON "NetdataWhite.ico" + +!define ND_UININSTALL_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata" + +!define MUI_ABORTWARNING +!define MUI_UNABORTWARNING + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt" +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +Function .onInit + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata' + pop $0 + ${If} $0 == 0 + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata' + pop $0 + ${EndIf} +FunctionEnd + +Function NetdataUninstallRegistry + ClearErrors + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "DisplayName" "Netdata - Real-time system monitoring." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "DisplayIcon" "$INSTDIR\Uninstall.exe,0" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "UninstallString" "$INSTDIR\Uninstall.exe" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "RegOwner" "Netdata Inc." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "RegCompany" "Netdata Inc." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "Publisher" "Netdata Inc." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "HelpLink" "https://learn.netdata.cloud/" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "URLInfoAbout" "https://www.netdata.cloud/" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "DisplayVersion" "${CURRVERSION}" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "VersionMajor" "${MAJORVERSION}" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "VersionMinor" "${MINORVERSION}" + + IfErrors 0 +2 + MessageBox MB_ICONEXCLAMATION|MB_OK "Unable to create an entry in the Control Panel!" IDOK end + + ClearErrors + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD HKLM "${ND_UININSTALL_REG}" "EstimatedSize" "$0" + + IfErrors 0 +2 + MessageBox MB_ICONEXCLAMATION|MB_OK "Cannot estimate the installation size." IDOK end + end: +FunctionEnd + +Section "Install Netdata" + SetOutPath $INSTDIR + SetCompress off + + File /r "C:\msys64\opt\netdata\*.*" + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe create Netdata binPath= "$INSTDIR\usr\bin\netdata.exe" start= delayed-auto' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to create Netdata service." + ${EndIf} + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe description Netdata "Real-time system monitoring service"' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to add Netdata service description." + ${EndIf} + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to start Netdata service." + ${EndIf} + + WriteUninstaller "$INSTDIR\Uninstall.exe" + + Call NetdataUninstallRegistry +SectionEnd + +Section "Uninstall" + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to stop Netdata service." + ${EndIf} + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to delete Netdata service." + ${EndIf} + + RMDir /r "$INSTDIR" + + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata" +SectionEnd + diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index dde738c28..72b82be26 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: GPL-3.0-or-later # -# Next unused error code: F051A +# Next unused error code: F051B # ====================================================================== # Constants @@ -21,8 +21,8 @@ KICKSTART_SOURCE="$( )" DEFAULT_PLUGIN_PACKAGES="" PATH="${PATH}:/usr/local/bin:/usr/local/sbin" -REPOCONFIG_DEB_VERSION="2-2" -REPOCONFIG_RPM_VERSION="2-2" +REPOCONFIG_DEB_VERSION="3-2" +REPOCONFIG_RPM_VERSION="3-2" START_TIME="$(date +%s)" STATIC_INSTALL_ARCHES="x86_64 armv7l armv6l aarch64 ppc64le" @@ -378,12 +378,14 @@ trap 'trap_handler 15 0' TERM # Utility functions canonical_path() { + OLDPWD="$(pwd)" cd "$(dirname "${1}")" || exit 1 case "$(basename "${1}")" in ..) dirname "$(pwd -P)" ;; .) pwd -P ;; *) echo "$(pwd -P)/$(basename "${1}")" ;; esac + cd "${OLDPWD}" || exit 1 } setup_terminal() { @@ -453,7 +455,7 @@ deferred_warnings() { fatal() { deferred_warnings - printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${1}" + printf >&2 "%b\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${1}" printf >&2 "%s\n" "For community support, you can connect with us on:" support_list telemetry_event "INSTALL_FAILED" "${1}" "${2}" @@ -741,8 +743,6 @@ get_redirect() { } safe_sha256sum() { - # Within the context of the installer, we only use -c option that is common between the two commands - # We will have to reconsider if we start using non-common options if command -v shasum > /dev/null 2>&1; then shasum -a 256 "$@" elif command -v sha256sum > /dev/null 2>&1; then @@ -752,6 +752,17 @@ safe_sha256sum() { fi } +report_bad_sha256sum() { + file="${1}" + sums="${2}" + + actual="$(safe_sha256sum "${file}" | awk '{ print $1 }')" + expected="$(grep "${file}" "${sums}" | awk '{ print $1 }')" + + printf "Expected: %s\n" "${expected}" + printf "Actual: %s\n" "${actual}" +} + get_system_info() { SYSARCH="$(uname -m)" @@ -1371,7 +1382,7 @@ set_auto_updates() { if [ "${DRY_RUN}" -eq 1 ]; then progress "Would have attempted to enable automatic updates." # This first case is for catching using a new kickstart script with an old build. It can be safely removed after v1.34.0 is released. - elif ! run_as_root grep -q '\-\-enable-auto-updates' "${updater}"; then + elif ! run_as_root grep -q '\--enable-auto-updates' "${updater}"; then echo elif ! run_as_root "${updater}" --enable-auto-updates "${NETDATA_AUTO_UPDATE_TYPE}"; then warning "Failed to enable auto updates. Netdata will still work, but you will need to update manually." @@ -1794,11 +1805,11 @@ try_static_install() { return 2 fi - if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/${netdata_agent}"; then + if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "./${netdata_agent}"; then fatal "Unable to download static build archive for ${SYSARCH}. ${BADNET_MSG}." F0208 fi - if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then + if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "./sha256sum.txt"; then fatal "Unable to fetch checksums to verify static build archive. ${BADNET_MSG}." F0206 fi @@ -1806,8 +1817,9 @@ try_static_install() { progress "Would validate SHA256 checksum of downloaded static build archive." else if [ -z "${INSTALL_VERSION}" ]; then - if ! grep "${netdata_agent}" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then - fatal "Static binary checksum validation failed. ${BADCACHE_MSG}." F0207 + if ! grep "${netdata_agent}" ./sha256sum.txt | safe_sha256sum -c - > /dev/null 2>&1; then + bad_sums_report="$(report_bad_sha256sum "${netdata_agent}" "./sha256sum.txt")" + fatal "Static binary checksum validation failed.\n${bad_sums_report}\n${BADCACHE_MSG}." F0207 fi fi fi @@ -1824,7 +1836,7 @@ try_static_install() { progress "Installing netdata" # shellcheck disable=SC2086 - if ! run_as_root ${env_cmd} /bin/sh "${tmpdir}/${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then + if ! run_as_root ${env_cmd} /bin/sh "./${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then warning "Failed to install static build of Netdata on ${SYSARCH}." run rm -rf /opt/netdata return 2 @@ -1936,6 +1948,7 @@ build_and_install() { run_script ./netdata-installer.sh ${opts} case $? in + 0) ;; 1) if [ -n "${EXIT_REASON}" ]; then fatal "netdata-installer.sh failed to run: ${EXIT_REASON}" "${EXIT_CODE}" @@ -1944,6 +1957,7 @@ build_and_install() { fi ;; 2) fatal "Insufficient RAM to install netdata." F0008 ;; + *) fatal "netdata-installer.sh failed to run: Encountered an unhandled error in the installer code." F051A ;; esac } @@ -1963,14 +1977,14 @@ try_build_install() { set_source_archive_urls "${SELECTED_RELEASE_CHANNEL}" if [ -n "${INSTALL_VERSION}" ]; then - if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz"; then + if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "./netdata-v${INSTALL_VERSION}.tar.gz"; then fatal "Failed to download source tarball for local build. ${BADNET_MSG}." F000B fi - elif ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"; then + elif ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "./netdata-latest.tar.gz"; then fatal "Failed to download source tarball for local build. ${BADNET_MSG}." F000B fi - if ! download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then + if ! download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "./sha256sum.txt"; then fatal "Failed to download checksums for source tarball verification. ${BADNET_MSG}." F000C fi @@ -1979,18 +1993,19 @@ try_build_install() { else if [ -z "${INSTALL_VERSION}" ]; then # shellcheck disable=SC2086 - if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then - fatal "Tarball checksum validation failed. ${BADCACHE_MSG}." F0005 + if ! grep netdata-latest.tar.gz "./sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then + bad_sums_report="$(report_bad_sha256sum netdata-latest.tar.gz "./sha256sum.txt")" + fatal "Tarball checksum validation failed.\n${bad_sums_report}\n${BADCACHE_MSG}." F0005 fi fi fi if [ -n "${INSTALL_VERSION}" ]; then - run tar -xf "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz" -C "${tmpdir}" - rm -rf "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz" > /dev/null 2>&1 + run tar -xf "./netdata-v${INSTALL_VERSION}.tar.gz" -C "${tmpdir}" + rm -rf "./netdata-v${INSTALL_VERSION}.tar.gz" > /dev/null 2>&1 else - run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}" - rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1 + run tar -xf "./netdata-latest.tar.gz" -C "${tmpdir}" + rm -rf "./netdata-latest.tar.gz" > /dev/null 2>&1 fi if [ "${DRY_RUN}" -ne 1 ]; then @@ -2073,8 +2088,16 @@ prepare_offline_install_source() { if [ "${DRY_RUN}" -ne 1 ]; then progress "Verifying checksums." - if ! grep -e "$(find . -name '*.gz.run')" sha256sums.txt | safe_sha256sum -c -; then - fatal "Checksums for offline install files are incorrect. ${BADCACHE_MSG}." F0507 + + failed_files="" + for file in $(find . -name '*.gz.run'); do + if ! grep -e "${file}" sha256sums.txt | safe_sha256sum -c -; then + failed_files="${failed_files}\n${file}\n$(report_bad_sha256sums "${file}" sha256sums.txt)" + fi + done + + if [ -n "${failed_files}" ]; then + fatal "Checksums for offline install files are incorrect.\n${failed_files}\n${BADCACHE_MSG}." F0507 fi else progress "Would verify SHA256 checksums of downloaded installation files." diff --git a/packaging/installer/package-windows.sh b/packaging/installer/package-windows.sh new file mode 100755 index 000000000..7b1c57e46 --- /dev/null +++ b/packaging/installer/package-windows.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +repo_root="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")" + +if [ -n "${BUILD_DIR}" ]; then + build="${BUILD_DIR}" +elif [ -n "${OSTYPE}" ]; then + if [ -n "${MSYSTEM}" ]; then + build="${repo_root}/build-${OSTYPE}-${MSYSTEM}" + else + build="${repo_root}/build-${OSTYPE}" + fi +elif [ "$USER" = "vk" ]; then + build="${repo_root}/build" +else + build="${repo_root}/build" +fi + +set -exu -o pipefail + +${GITHUB_ACTIONS+echo "::group::Installing"} +cmake --install "${build}" +${GITHUB_ACTIONS+echo "::endgroup::"} + +if [ ! -f "/msys2-installer.exe" ]; then + ${GITHUB_ACTIONS+echo "::group::Fetching MSYS2 installer"} + "${repo_root}/packaging/windows/fetch-msys2-installer.py" /msys2-installer.exe + ${GITHUB_ACTIONS+echo "::endgroup::"} +fi + +${GITHUB_ACTIONS+echo "::group::Packaging"} +NDVERSION=$"$(grep 'CMAKE_PROJECT_VERSION:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)" +NDMAJORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MAJOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)" +NDMINORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MINOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)" + +if [ -f "/gpl-3.0.txt" ]; then + ${GITHUB_ACTIONS+echo "::group::Fetching GPL3 License"} + curl -o /gpl-3.0.txt "https://www.gnu.org/licenses/gpl-3.0.txt" + ${GITHUB_ACTIONS+echo "::endgroup::"} +fi + +/mingw64/bin/makensis.exe -DCURRVERSION="${NDVERSION}" -DMAJORVERSION="${NDMAJORVERSION}" -DMINORVERSION="${NDMINORVERSION}" "${repo_root}/packaging/windows/installer.nsi" +${GITHUB_ACTIONS+echo "::endgroup::"} diff --git a/packaging/makeself/jobs/70-netdata-git.install.sh b/packaging/makeself/jobs/70-netdata-git.install.sh index 13144bfcd..59074ec59 100755 --- a/packaging/makeself/jobs/70-netdata-git.install.sh +++ b/packaging/makeself/jobs/70-netdata-git.install.sh @@ -36,7 +36,6 @@ run ./netdata-installer.sh \ --use-system-protobuf \ --dont-scrub-cflags-even-though-it-may-break-things \ --one-time-build \ - --disable-logsmanagement \ --enable-lto \ ${EXTRA_INSTALL_FLAGS:+${EXTRA_INSTALL_FLAGS}} \ diff --git a/packaging/makeself/jobs/90-netdata-runtime-check.sh b/packaging/makeself/jobs/90-netdata-runtime-check.sh index 86f4883d7..38ebc4c87 100755 --- a/packaging/makeself/jobs/90-netdata-runtime-check.sh +++ b/packaging/makeself/jobs/90-netdata-runtime-check.sh @@ -11,7 +11,7 @@ dump_log() { trap dump_log EXIT export NETDATA_LIBEXEC_PREFIX="${NETDATA_INSTALL_PATH}/usr/libexec/netdata" -export NETDATA_SKIP_LIBEXEC_PARTS="logs-management|freeipmi|xenstat|cups" +export NETDATA_SKIP_LIBEXEC_PARTS="freeipmi|xenstat|cups" if [ "$(uname -m)" != "x86_64" ]; then export NETDATA_SKIP_LIBEXEC_PARTS="${NETDATA_SKIP_LIBEXEC_PARTS}|ebpf" diff --git a/packaging/repoconfig/CMakeLists.txt b/packaging/repoconfig/CMakeLists.txt index 65813460a..415ad8807 100644 --- a/packaging/repoconfig/CMakeLists.txt +++ b/packaging/repoconfig/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later -cmake_minimum_required(VERSION 3.13.0...3.28) +cmake_minimum_required(VERSION 3.16.0...3.30) list(APPEND RHEL_DISTROS centos centos-stream rocky almalinux cloudlinux) list(APPEND SUSE_DISTROS opensuse-leap opensuse-tumbleweed) @@ -10,7 +10,7 @@ list(APPEND DEB_DISTROS debian ubuntu) set(DEB_GPG_KEY_SOURCE "https://repo.netdata.cloud/netdatabot.gpg.key") set(PACKAGE_VERSION 3) -set(PACKAGE_RELEASE 1) +set(PACKAGE_RELEASE 4) set(CPACK_THREADS 0) set(CPACK_STRIP_FILES NO) @@ -117,10 +117,10 @@ if(${DISTRO} IN_LIST DEB_DISTROS) set(DIST_NAME ${DISTRO}) message(STATUS "Generating stable repository configuration for ${DISTRO} ${SUITE}") set(VARIANT stable) - configure_file(netdata.list.in netdata.list @ONLY) + configure_file(netdata.sources.in netdata.sources @ONLY) message(STATUS "Generating edge repository configuration for ${DISTRO} ${SUITE}") set(VARIANT edge) - configure_file(netdata.list.in netdata-edge.list @ONLY) + configure_file(netdata.sources.in netdata-edge.sources @ONLY) message(STATUS "Preparing changelogs") set(PKG_NAME netdata-repo) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/netdata-repo) @@ -129,10 +129,10 @@ if(${DISTRO} IN_LIST DEB_DISTROS) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/netdata-repo-edge) configure_file(deb.changelog netdata-repo-edge/changelog @ONLY) - install(FILES ${CMAKE_BINARY_DIR}/netdata.list + install(FILES ${CMAKE_BINARY_DIR}/netdata.sources DESTINATION etc/apt/sources.list.d COMPONENT netdata-repo) - install(FILES ${CMAKE_BINARY_DIR}/netdata-edge.list + install(FILES ${CMAKE_BINARY_DIR}/netdata-edge.sources DESTINATION etc/apt/sources.list.d COMPONENT netdata-repo-edge) @@ -150,24 +150,14 @@ if(${DISTRO} IN_LIST DEB_DISTROS) DEPENDS ${CMAKE_BINARY_DIR}/netdata.gpg) install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg - DESTINATION etc/apt/trusted.gpg.d + DESTINATION usr/share/keyrings RENAME netdata-archive-keyring.gpg PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT netdata-repo) - install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg - DESTINATION etc/apt/trusted.gpg.d - RENAME netdata-repoconfig-archive-keyring.gpg - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ - COMPONENT netdata-repo) install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg - DESTINATION etc/apt/trusted.gpg.d - RENAME netdata-edge-archive-keyring.gpg - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ - COMPONENT netdata-repo-edge) - install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg - DESTINATION etc/apt/trusted.gpg.d - RENAME netdata-repoconfig-archive-keyring.gpg + DESTINATION usr/share/keyrings + RENAME netdata-archive-keyring.gpg PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT netdata-repo-edge) @@ -247,10 +237,10 @@ elseif(${DISTRO} IN_LIST RPM_DISTROS) set(CPACK_RPM_PACKAGE_VERSION "${PACKAGE_VERSION}") set(CPACK_RPM_PACKAGE_RELEASE "${PACKAGE_RELEASE}") set(CPACK_RPM_PACKAGE_CHANGELOG "${CMAKE_SOURCE_DIR}/rpm.changelog") - set(CPACK_RPM_NETDATA-REPO_FILE_NAME "netdata-repo-${PACKAGE_VERSION}-${PACKAGE_RELEASE}.rpm") + set(CPACK_RPM_NETDATA-REPO_FILE_NAME "netdata-repo-${PACKAGE_VERSION}-${PACKAGE_RELEASE}.noarch.rpm") set(CPACK_RPM_NETDATA-REPO_PACKAGE_NAME "netdata-repo") set(CPACK_RPM_NETDATA-REPO_PACAKGE_CONFLICTS "netdata-repo-edge") - set(CPACK_RPM_NETDATA-REPO-EDGE_FILE_NAME "netdata-repo-edge-${PACKAGE_VERSION}-${PACKAGE_RELEASE}.rpm") + set(CPACK_RPM_NETDATA-REPO-EDGE_FILE_NAME "netdata-repo-edge-${PACKAGE_VERSION}-${PACKAGE_RELEASE}.noarch.rpm") set(CPACK_RPM_NETDATA-REPO-EDGE_PACKAGE_NAME "netdata-repo-edge") set(CPACK_RPM_NETDATA-REPO-EDGE_PACKAGE_CONFLICTS "netdata-repo") else() diff --git a/packaging/repoconfig/deb.changelog b/packaging/repoconfig/deb.changelog index 9d0f3ba75..6d1dca883 100644 --- a/packaging/repoconfig/deb.changelog +++ b/packaging/repoconfig/deb.changelog @@ -1,3 +1,21 @@ +@PKG_NAME@ (3-4) unstable; urgency=medium + + * Convert sources to DEB822 format + + -- Netdata Builder Mon, 19 Aug 2024 07:49:00 -0400 + +@PKG_NAME@ (3-3) unstable; urgency=medium + + * Version bump to keep in sync with RPM repo packages + + -- Netdata Builder Fri, 9 Aug 2024 09:37:00 -0400 + +@PKG_NAME@ (3-2) unstable; urgency=medium + + * Version bump to keep in sync with RPM repo packages + + -- Netdata Builder Mon, 24 Jun 2024 07:54:00 -0400 + @PKG_NAME@ (3-1) unstable; urgency=medium * Migrate to CPack for package builds diff --git a/packaging/repoconfig/netdata.list.in b/packaging/repoconfig/netdata.list.in deleted file mode 100644 index b35ede441..000000000 --- a/packaging/repoconfig/netdata.list.in +++ /dev/null @@ -1,2 +0,0 @@ -deb http://repo.netdata.cloud/repos/@VARIANT@/@DIST_NAME@/ @SUITE@/ -deb http://repo.netdata.cloud/repos/repoconfig/@DIST_NAME@/ @SUITE@/ diff --git a/packaging/repoconfig/netdata.repo.dnf b/packaging/repoconfig/netdata.repo.dnf index a8ab94a03..3a64a2a58 100644 --- a/packaging/repoconfig/netdata.repo.dnf +++ b/packaging/repoconfig/netdata.repo.dnf @@ -6,7 +6,6 @@ gpgcheck=1 gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key enabled=1 sslverify=1 -sslcacert=/etc/pki/tls/certs/ca-bundle.crt priority=50 [netdata-repoconfig] @@ -17,5 +16,4 @@ gpgcheck=1 gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key enabled=1 sslverify=1 -sslcacert=/etc/pki/tls/certs/ca-bundle.crt priority=50 diff --git a/packaging/repoconfig/netdata.sources.in b/packaging/repoconfig/netdata.sources.in new file mode 100644 index 000000000..926b2c453 --- /dev/null +++ b/packaging/repoconfig/netdata.sources.in @@ -0,0 +1,15 @@ +X-Repolib-Name: Netdata @VARIANT@ repository +Types: deb +URIs: http://repo.netdata.cloud/repos/@VARIANT@/@DIST_NAME@/ +Suites: @SUITE@/ +Signed-By: /usr/share/keyrings/netdata-archive-keyring.gpg +By-Hash: No +Enabled: Yes + +X-Repolib-Name: Netdata repository configuration repository +Types: deb +URIs: http://repo.netdata.cloud/repos/repoconfig/@DIST_NAME@/ +Suites: @SUITE@/ +Signed-By: /usr/share/keyrings/netdata-archive-keyring.gpg +By-Hash: No +Enabled: Yes diff --git a/packaging/repoconfig/rpm.changelog b/packaging/repoconfig/rpm.changelog index 5ae4aea05..dab81a2cf 100644 --- a/packaging/repoconfig/rpm.changelog +++ b/packaging/repoconfig/rpm.changelog @@ -1,3 +1,9 @@ +* Mon Aug 19 2024 Austin Hemmelgarn 3-3 +- Use system certificate config for Yum/DNF repos. +* Mon Jun 24 2024 Austin Hemmelgarn 3-2 +- Fix package file names. * Fri Jun 14 2024 Austin Hemmelgarn 3-1 - Migrate package build infrastructure to CPack. * Wed Apr 10 2024 Paul Szymanski 2-3 diff --git a/packaging/runtime-check.sh b/packaging/runtime-check.sh index d297a6e22..969600f00 100755 --- a/packaging/runtime-check.sh +++ b/packaging/runtime-check.sh @@ -60,7 +60,6 @@ plugins.d/freeipmi.plugin plugins.d/go.d.plugin plugins.d/ioping.plugin plugins.d/local-listeners -plugins.d/logs-management.plugin plugins.d/ndsudo plugins.d/network-viewer.plugin plugins.d/nfacct.plugin diff --git a/packaging/utils/bash_execute.sh b/packaging/utils/bash_execute.sh deleted file mode 100644 index 4092db966..000000000 --- a/packaging/utils/bash_execute.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/bash - -convert_path() { - local ARG="$1" - ARG="${ARG//C:\\//c/}" - ARG="${ARG//c:\\//c/}" - ARG="${ARG//C:\///c/}" - ARG="${ARG//c:\///c/}" - - echo "$ARG" -} - -declare params=() -for x in "${@}" -do - params+=("$(convert_path "${x}")") -done - -"${params[@]}" diff --git a/packaging/utils/clion-msys-mingw64-environment.bat b/packaging/utils/clion-msys-mingw64-environment.bat deleted file mode 100644 index 19035d8eb..000000000 --- a/packaging/utils/clion-msys-mingw64-environment.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -:: In Clion Toolchains -:: 1. Add a MinGW profile -:: 2. Set Toolset to C:\msys64\mingw64 -:: 3. Add environment and set the full path to this file, like: -:: C:\msys64\home\costa\src\netdata-ktsaou.git\packaging\utils\clion-mingw64-environment.bat -:: 4. Let everything else to Bundled and auto-detected -:: -set "batch_dir=%~dp0" -set "batch_dir=%batch_dir:\=/%" -set MSYSTEM=MINGW64 -set GOROOT=C:\msys64\mingw64 -set PATH="%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin;C:\msys64\bin" -::set PKG_CONFIG_EXECUTABLE=C:\msys64\mingw64\bin\pkg-config.exe -::set CMAKE_C_COMPILER=C:\msys64\mingw64\bin\gcc.exe -::set CMAKE_CC_COMPILER=C:\msys64\mingw64\bin\g++.exe -set PROTOBUF_PROTOC_EXECUTABLE=C:/msys64/mingw64/bin/protoc.exe diff --git a/packaging/utils/clion-msys-msys-environment.bat b/packaging/utils/clion-msys-msys-environment.bat deleted file mode 100644 index 9f0c095d3..000000000 --- a/packaging/utils/clion-msys-msys-environment.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -:: In Clion Toolchains -:: 1. Add a MinGW profile -:: 2. Set Toolset to C:\msys64\mingw64 -:: 3. Add environment and set the full path to this file, like: -:: C:\msys64\home\costa\src\netdata-ktsaou.git\packaging\utils\clion-mingw64-environment.bat -:: 4. Let everything else to Bundled and auto-detected -:: -set "batch_dir=%~dp0" -set "batch_dir=%batch_dir:\=/%" -set MSYSTEM=MSYS - -:: go exists only mingw64 / ucrt64 / etc, not under msys profile -set GOROOT=C:\msys64\mingw64 - -set PATH="%PATH%;C:\msys64\usr\bin;C:\msys64\bin;C:\msys64\mingw64\bin" -::set PKG_CONFIG_EXECUTABLE=C:\msys64\mingw64\bin\pkg-config.exe -::set CMAKE_C_COMPILER=C:\msys64\mingw64\bin\gcc.exe -::set CMAKE_CC_COMPILER=C:\msys64\mingw64\bin\g++.exe -set PROTOBUF_PROTOC_EXECUTABLE=%batch_dir%/protoc.bat diff --git a/packaging/utils/compile-on-windows.sh b/packaging/utils/compile-on-windows.sh deleted file mode 100644 index aa44771b8..000000000 --- a/packaging/utils/compile-on-windows.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -# On MSYS2, install these dependencies to build netdata: -install_dependencies() { - pacman -S \ - git cmake ninja base-devel msys2-devel \ - libyaml-devel libzstd-devel libutil-linux libutil-linux-devel \ - mingw-w64-x86_64-toolchain mingw-w64-ucrt-x86_64-toolchain \ - mingw64/mingw-w64-x86_64-mold ucrt64/mingw-w64-ucrt-x86_64-mold \ - msys/gdb ucrt64/mingw-w64-ucrt-x86_64-gdb mingw64/mingw-w64-x86_64-gdb \ - msys/zlib-devel mingw64/mingw-w64-x86_64-zlib ucrt64/mingw-w64-ucrt-x86_64-zlib \ - msys/libuv-devel ucrt64/mingw-w64-ucrt-x86_64-libuv mingw64/mingw-w64-x86_64-libuv \ - liblz4-devel mingw64/mingw-w64-x86_64-lz4 ucrt64/mingw-w64-ucrt-x86_64-lz4 \ - openssl-devel mingw64/mingw-w64-x86_64-openssl ucrt64/mingw-w64-ucrt-x86_64-openssl \ - protobuf-devel mingw64/mingw-w64-x86_64-protobuf ucrt64/mingw-w64-ucrt-x86_64-protobuf \ - msys/pcre2-devel mingw64/mingw-w64-x86_64-pcre2 ucrt64/mingw-w64-ucrt-x86_64-pcre2 \ - msys/brotli-devel mingw64/mingw-w64-x86_64-brotli ucrt64/mingw-w64-ucrt-x86_64-brotli \ - msys/ccache ucrt64/mingw-w64-ucrt-x86_64-ccache mingw64/mingw-w64-x86_64-ccache \ - mingw64/mingw-w64-x86_64-go ucrt64/mingw-w64-ucrt-x86_64-go -} - -if [ "${1}" = "install" ] -then - install_dependencies || exit 1 - exit 0 -fi - -export PATH="/usr/local/bin:${PATH}" - -WT_ROOT="$(pwd)" -BUILD_TYPE="Debug" -NULL="" - -if [ -z "${MSYSTEM}" ]; then - build="${WT_ROOT}/build-${OSTYPE}" -else - build="${WT_ROOT}/build-${OSTYPE}-${MSYSTEM}" -fi - -if [ "$USER" = "vk" ]; then - build="${WT_ROOT}/build" -fi - -set -exu -o pipefail - -if [ -d "${build}" ] -then - rm -rf "${build}" -fi - -/usr/bin/cmake -S "${WT_ROOT}" -B "${build}" \ - -G Ninja \ - -DCMAKE_INSTALL_PREFIX="/opt/netdata" \ - -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ - -DCMAKE_C_FLAGS="-O0 -ggdb -Wall -Wextra -Wno-char-subscripts -Wa,-mbig-obj -pipe -DNETDATA_INTERNAL_CHECKS=1 -D_FILE_OFFSET_BITS=64 -D__USE_MINGW_ANSI_STDIO=1" \ - -DNETDATA_USER="${USER}" \ - -DDEFAULT_FEATURE_STATE=Off \ - -DENABLE_H2O=Off \ - -DENABLE_LOGS_MANAGEMENT_TESTS=Off \ - -DENABLE_ACLK=On \ - -DENABLE_CLOUD=On \ - -DENABLE_ML=On \ - -DENABLE_BUNDLED_JSONC=On \ - -DENABLE_BUNDLED_PROTOBUF=Off \ - ${NULL} - -ninja -v -C "${build}" || ninja -v -C "${build}" -j 1 - -echo -echo "Compile with:" -echo "ninja -v -C \"${build}\" || ninja -v -C \"${build}\" -j 1" diff --git a/packaging/utils/coverity-scan.sh b/packaging/utils/coverity-scan.sh index b69fea561..ebb82102d 100755 --- a/packaging/utils/coverity-scan.sh +++ b/packaging/utils/coverity-scan.sh @@ -27,9 +27,6 @@ # this includes the token, so the default is not to print it. # COVERITY_SUBMIT_DEBUG=1 # -# Override the standard coverity build version we know is supported -# COVERITY_BUILD_VERSION="cov-analysis-linux64-2019.03" -# # All these variables can also be exported before running this script. # # If the first parameter of this script is "install", @@ -37,10 +34,12 @@ set -e -INSTALL_DIR="/opt" +if [ "$(uname -s)" != "Linux" ] || [ "$(uname -m)" != "x86_64" ]; then + echo "This script can only be used on a 64-bit x86 Linux system." + exit 1 +fi -# the version of coverity to use -COVERITY_BUILD_VERSION="${COVERITY_BUILD_VERSION:-cov-analysis-linux64-2023.6.2}" +INSTALL_DIR="/opt" SCRIPT_SOURCE="$( self=${0} @@ -158,24 +157,21 @@ scanit() { } installit() { - ORIGINAL_DIR="${PWD}" TMP_DIR="$(mktemp -d /tmp/netdata-coverity-scan-XXXXX)" progress "Downloading coverity in ${TMP_DIR}..." - cd "${TMP_DIR}" + (cd "${TMP_DIR}" && debugrun curl --remote-name --remote-header-name --show-error --location --data "token=${token}&project=${repo}" https://scan.coverity.com/download/linux64) - debugrun curl --remote-name --remote-header-name --show-error --location --data "token=${token}&project=${repo}" https://scan.coverity.com/download/linux64 + COVERITY_ARCHIVE="$(find "${TMP_DIR}" -maxdepth 1 -mindepth 1 -name 'cov-analysis-linux64-*.tar.gz')" - if [ -f "${COVERITY_BUILD_VERSION}.tar.gz" ]; then + if [ -n "${COVERITY_ARCHIVE}" ] && [ -f "${COVERITY_ARCHIVE}" ]; then progress "Installing coverity..." - cd "${INSTALL_DIR}" - - run sudo tar -z -x -f "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz" || exit 1 - rm "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz" + run sudo tar -z -x -f "${COVERITY_ARCHIVE}" -C "${INSTALL_DIR}" + rm -f "${COVERITY_ARCHIVE}" COVERITY_PATH=$(find "${INSTALL_DIR}" -maxdepth 1 -name 'cov*linux*') - export PATH=${PATH}:${COVERITY_PATH}/bin/ - elif find . -name "*.tar.gz" > /dev/null 2>&1; then - ls ./*.tar.gz - fatal "Downloaded coverity tool tarball does not appear to be the version we were expecting, exiting." + export PATH="${PATH}:${COVERITY_PATH}/bin/" + elif find "${TMP_DIR}" -name "*.tar.gz" > /dev/null 2>&1; then + ls "${TMP_DIR}"/*.tar.gz + fatal "Downloaded coverity tool tarball does not appear to be the file-name we were expecting, exiting." else fatal "Failed to download coverity tool tarball!" fi @@ -187,7 +183,6 @@ installit() { fi progress "Coverity scan tools are installed." - cd "$ORIGINAL_DIR" # Clean temp directory [ -n "${TMP_DIR}" ] && rm -rf "${TMP_DIR}" diff --git a/packaging/utils/find-dll-deps.sh b/packaging/utils/find-dll-deps.sh new file mode 100644 index 000000000..9f4fe3847 --- /dev/null +++ b/packaging/utils/find-dll-deps.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +if [ "$#" -lt 1 ]; then + echo "Usage: $0 ... " + exit 1 +fi + +results=() + +for arg in "$@"; do + while IFS= read -r line; do + results+=("$line") + done < <(ldd "$arg" | grep /usr/bin | awk '{ print $3 }') +done + +printf "%s\n" "${results[@]}" | sort | uniq diff --git a/packaging/utils/installer.nsi b/packaging/utils/installer.nsi deleted file mode 100644 index b78f52ffe..000000000 --- a/packaging/utils/installer.nsi +++ /dev/null @@ -1,34 +0,0 @@ -Outfile "netdata-installer.exe" -InstallDir "C:\netdata" - -RequestExecutionLevel admin - -Section - SetOutPath $INSTDIR - WriteUninstaller $INSTDIR\uninstaller.exe -SectionEnd - -Section "Install MSYS2 environment" - SetOutPath $TEMP - - SetCompress off - File "C:\msys64\msys2-installer.exe" - nsExec::ExecToLog 'cmd.exe /C "$TEMP\msys2-installer.exe" in --confirm-command --accept-messages --root $INSTDIR' - - Delete "$TEMP\msys2-installer.exe" -SectionEnd - -Section "Install MSYS2 packages" - ExecWait '"$INSTDIR\usr\bin\bash.exe" -lc "pacman -S --noconfirm msys/libuv msys/protobuf"' -SectionEnd - -Section "Install Netdata" - SetOutPath $INSTDIR\opt\netdata - - SetCompress off - File /r "C:\msys64\opt\netdata\*.*" -SectionEnd - -Section "Uninstall" - nsExec::ExecToLog 'cmd.exe /C "$INSTDIR\uninstall.exe" pr --confirm-command' -SectionEnd diff --git a/packaging/utils/package-windows.sh b/packaging/utils/package-windows.sh deleted file mode 100644 index b6996b9ec..000000000 --- a/packaging/utils/package-windows.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -export PATH="/usr/local/bin:${PATH}" - -WT_ROOT="$(pwd)" -NULL="" - -if [ -z "${MSYSTEM}" ]; then - build="${WT_ROOT}/build-${OSTYPE}" -else - build="${WT_ROOT}/build-${OSTYPE}-${MSYSTEM}" -fi - -if [ "$USER" = "vk" ]; then - build="${WT_ROOT}/build" -fi - -set -exu -o pipefail - -ninja -v -C "${build}" install - -if [ ! -f "/msys2-installer.exe" ]; then - wget -O /msys2-installer.exe \ - "https://github.com/msys2/msys2-installer/releases/download/2024-05-07/msys2-x86_64-20240507.exe" -fi - -makensis "${WT_ROOT}/packaging/utils/installer.nsi" diff --git a/packaging/utils/protoc.bat b/packaging/utils/protoc.bat deleted file mode 100644 index fe7a76f27..000000000 --- a/packaging/utils/protoc.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -:: -:: The problem with /usr/bin/protoc is that it accepts colon separated (:) paths at its parameters. -:: This makes C:/ being parsed as 2 paths: C and /, which of course both fail. -:: To overcome this problem, we use bash_execute.sh, which replaces all occurences of C: with /c. -:: -set "batch_dir=%~dp0" -set "batch_dir=%batch_dir:\=/%" -C:\msys64\usr\bin\bash.exe %batch_dir%/bash_execute.sh protoc %* diff --git a/packaging/utils/windows-openssh-to-msys.bat b/packaging/utils/windows-openssh-to-msys.bat deleted file mode 100644 index 829cb4845..000000000 --- a/packaging/utils/windows-openssh-to-msys.bat +++ /dev/null @@ -1,118 +0,0 @@ -@echo off -:: -:: This script will: -:: -:: 1. install the windows OpenSSH server (either via dsim or download it) -:: 2. activate the windows OpenSSH service -:: 3. open OpenSSH TCP port at windows firewall -:: 4. create a small batch file to start an MSYS session -:: 5. Set the default OpenSSH startup script to start the MSYS session -:: -:: Problems: -:: On older windows versions, terminal emulation is broken. -:: So, on windows 10 or windows server before 2019, the ssh session -:: will not have proper terminal emulation and will be not be able to -:: be used for editing files. -:: For more info check: -:: https://github.com/PowerShell/Win32-OpenSSH/issues/1260 -:: - -:: Check if OpenSSH Server is already installed -sc query sshd >nul 2>&1 -if %errorlevel% neq 0 ( - echo "OpenSSH Server not found. Attempting to install via dism..." - goto :install_openssh_dism -) else ( - echo "OpenSSH Server is already installed." - goto :configure_openssh -) - -:: Install OpenSSH using dism -:install_openssh_dism -dism /online /Enable-Feature /FeatureName:OpenSSH-Client /All >nul 2>&1 -dism /online /Enable-Feature /FeatureName:OpenSSH-Server /All >nul 2>&1 - -:: Check if dism succeeded in installing OpenSSH -sc query sshd >nul 2>&1 -if %errorlevel% neq 0 ( - echo "OpenSSH installation via dism failed or is unavailable." - goto :install_openssh_manual -) else ( - echo "OpenSSH installed successfully using dism." - goto :configure_openssh -) - -:: Function to Install OpenSSH manually if dism fails -:install_openssh_manual -echo "Installing OpenSSH manually..." - -:: Download the latest OpenSSH release -set DOWNLOAD_URL=https://github.com/PowerShell/Win32-OpenSSH/releases/download/v9.5.0.0p1-Beta/OpenSSH-Win64.zip -set DOWNLOAD_FILE=%temp%\OpenSSH-Win64.zip -set INSTALL_DIR=C:\Program Files\OpenSSH-Win64 - -:: Create the installation directory if it doesn't exist -if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" - -:: Attempt to download OpenSSH using Invoke-WebRequest and TLS configuration -powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { Invoke-WebRequest -Uri '%DOWNLOAD_URL%' -OutFile '%DOWNLOAD_FILE%' -UseBasicParsing; exit 0 } catch { exit 1 }" -if %errorlevel% neq 0 ( - echo "Invoke-WebRequest download failed. Attempting to download using curl..." - curl -L -o "%DOWNLOAD_FILE%" "%DOWNLOAD_URL%" - if %errorlevel% neq 0 ( - echo "Failed to download OpenSSH using curl. Exiting..." - exit /b 1 - ) -) - -:: Unzip directly to INSTALL_DIR (flatten the folder structure) -powershell -Command "Expand-Archive -Path '%DOWNLOAD_FILE%' -DestinationPath '%INSTALL_DIR%' -Force" -if %errorlevel% neq 0 ( - echo "Failed to unzip OpenSSH package." - exit /b 1 -) - -:: Move inner contents to INSTALL_DIR if nested OpenSSH-Win64 folder exists -if exist "%INSTALL_DIR%\OpenSSH-Win64" ( - xcopy "%INSTALL_DIR%\OpenSSH-Win64\*" "%INSTALL_DIR%\" /s /e /y - rmdir "%INSTALL_DIR%\OpenSSH-Win64" /s /q -) - -:: Add the OpenSSH binaries to the system PATH -setx /M PATH "%INSTALL_DIR%;%PATH%" - -:: Register OpenSSH utilities as services using PowerShell -powershell -ExecutionPolicy Bypass -Command "& '%INSTALL_DIR%\install-sshd.ps1'" - -:: Verify if manual installation succeeded -sc query sshd >nul 2>&1 -if %errorlevel% neq 0 ( - echo "Manual OpenSSH installation failed. Exiting..." - exit /b 1 -) else ( - echo "OpenSSH installed successfully manually." - goto :configure_openssh -) - -:configure_openssh -:: Ensure OpenSSH Server service is set to start automatically and start the service -sc config sshd start= auto -net start sshd - -:: Create msys2.bat file with specific content -set MSYS2_PATH=C:\msys64 -if not exist "%MSYS2_PATH%" ( - echo "Error: %MSYS2_PATH% does not exist." - exit /b 1 -) - -echo @%MSYS2_PATH%\msys2_shell.cmd -defterm -here -no-start -msys > %MSYS2_PATH%\msys2.bat - -:: Run PowerShell command to set default shell -powershell -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name 'DefaultShell' -Value '%MSYS2_PATH%\msys2.bat' -PropertyType String -Force" - -:: Open the Windows Firewall for sshd (using PowerShell) -powershell -Command "New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd) Incoming' -Description 'Allow incoming SSH traffic via OpenSSH server' -Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow" - -echo "OpenSSH has been successfully configured with MSYS2 as the default shell, and the firewall has been opened for sshd." -pause diff --git a/packaging/version b/packaging/version index d60e77ca4..7a536ce12 100644 --- a/packaging/version +++ b/packaging/version @@ -1 +1 @@ -v1.46.3 +v1.47.0 diff --git a/packaging/windows/NetdataWhite.ico b/packaging/windows/NetdataWhite.ico new file mode 100644 index 000000000..857b88062 Binary files /dev/null and b/packaging/windows/NetdataWhite.ico differ diff --git a/packaging/windows/bash_execute.sh b/packaging/windows/bash_execute.sh new file mode 100755 index 000000000..4092db966 --- /dev/null +++ b/packaging/windows/bash_execute.sh @@ -0,0 +1,19 @@ +#!/usr/bin/bash + +convert_path() { + local ARG="$1" + ARG="${ARG//C:\\//c/}" + ARG="${ARG//c:\\//c/}" + ARG="${ARG//C:\///c/}" + ARG="${ARG//c:\///c/}" + + echo "$ARG" +} + +declare params=() +for x in "${@}" +do + params+=("$(convert_path "${x}")") +done + +"${params[@]}" diff --git a/packaging/windows/build.ps1 b/packaging/windows/build.ps1 new file mode 100644 index 000000000..f656ed568 --- /dev/null +++ b/packaging/windows/build.ps1 @@ -0,0 +1,16 @@ +# Run the build + +#Requires -Version 4.0 + +$ErrorActionPreference = "Stop" + +. "$PSScriptRoot\functions.ps1" + +$msysbash = Get-MSYS2Bash "$msysprefix" +$env:CHERE_INVOKING = 'yes' + +& $msysbash -l "$PSScriptRoot\compile-on-windows.sh" + +if ($LastExitcode -ne 0) { + exit 1 +} diff --git a/packaging/windows/clion-msys-mingw64-environment.bat b/packaging/windows/clion-msys-mingw64-environment.bat new file mode 100644 index 000000000..19035d8eb --- /dev/null +++ b/packaging/windows/clion-msys-mingw64-environment.bat @@ -0,0 +1,17 @@ +@echo off +:: In Clion Toolchains +:: 1. Add a MinGW profile +:: 2. Set Toolset to C:\msys64\mingw64 +:: 3. Add environment and set the full path to this file, like: +:: C:\msys64\home\costa\src\netdata-ktsaou.git\packaging\utils\clion-mingw64-environment.bat +:: 4. Let everything else to Bundled and auto-detected +:: +set "batch_dir=%~dp0" +set "batch_dir=%batch_dir:\=/%" +set MSYSTEM=MINGW64 +set GOROOT=C:\msys64\mingw64 +set PATH="%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin;C:\msys64\bin" +::set PKG_CONFIG_EXECUTABLE=C:\msys64\mingw64\bin\pkg-config.exe +::set CMAKE_C_COMPILER=C:\msys64\mingw64\bin\gcc.exe +::set CMAKE_CC_COMPILER=C:\msys64\mingw64\bin\g++.exe +set PROTOBUF_PROTOC_EXECUTABLE=C:/msys64/mingw64/bin/protoc.exe diff --git a/packaging/windows/clion-msys-msys-environment.bat b/packaging/windows/clion-msys-msys-environment.bat new file mode 100644 index 000000000..9f0c095d3 --- /dev/null +++ b/packaging/windows/clion-msys-msys-environment.bat @@ -0,0 +1,20 @@ +@echo off +:: In Clion Toolchains +:: 1. Add a MinGW profile +:: 2. Set Toolset to C:\msys64\mingw64 +:: 3. Add environment and set the full path to this file, like: +:: C:\msys64\home\costa\src\netdata-ktsaou.git\packaging\utils\clion-mingw64-environment.bat +:: 4. Let everything else to Bundled and auto-detected +:: +set "batch_dir=%~dp0" +set "batch_dir=%batch_dir:\=/%" +set MSYSTEM=MSYS + +:: go exists only mingw64 / ucrt64 / etc, not under msys profile +set GOROOT=C:\msys64\mingw64 + +set PATH="%PATH%;C:\msys64\usr\bin;C:\msys64\bin;C:\msys64\mingw64\bin" +::set PKG_CONFIG_EXECUTABLE=C:\msys64\mingw64\bin\pkg-config.exe +::set CMAKE_C_COMPILER=C:\msys64\mingw64\bin\gcc.exe +::set CMAKE_CC_COMPILER=C:\msys64\mingw64\bin\g++.exe +set PROTOBUF_PROTOC_EXECUTABLE=%batch_dir%/protoc.bat diff --git a/packaging/windows/compile-on-windows.sh b/packaging/windows/compile-on-windows.sh new file mode 100755 index 000000000..ceb4f5502 --- /dev/null +++ b/packaging/windows/compile-on-windows.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +REPO_ROOT="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")" +CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}" + +# shellcheck source=./win-build-dir.sh +. "${REPO_ROOT}/packaging/windows/win-build-dir.sh" + +set -exu -o pipefail + +if [ -d "${build}" ]; then + rm -rf "${build}" +fi + +generator="Unix Makefiles" +build_args="-j $(nproc)" + +if command -v ninja >/dev/null 2>&1; then + generator="Ninja" + build_args="-k 1" +fi + +COMMON_CFLAGS="-Wa,-mbig-obj -pipe -D_FILE_OFFSET_BITS=64 -D__USE_MINGW_ANSI_STDIO=1" + +if [ "${CMAKE_BUILD_TYPE}" = "Debug" ]; then + BUILD_CFLAGS="-fstack-protector-all -O0 -ggdb -Wall -Wextra -Wno-char-subscripts -DNETDATA_INTERNAL_CHECKS=1 ${COMMON_CFLAGS} ${CFLAGS:-}" +else + BUILD_CFLAGS="-O2 ${COMMON_CFLAGS} ${CFLAGS:-}" +fi + +${GITHUB_ACTIONS+echo "::group::Configuring"} +# shellcheck disable=SC2086 +CFLAGS="${BUILD_CFLAGS}" /usr/bin/cmake \ + -S "${REPO_ROOT}" \ + -B "${build}" \ + -G "${generator}" \ + -DCMAKE_INSTALL_PREFIX="/opt/netdata" \ + -DBUILD_FOR_PACKAGING=On \ + -DNETDATA_USER="${USER}" \ + -DENABLE_ACLK=On \ + -DENABLE_CLOUD=On \ + -DENABLE_H2O=Off \ + -DENABLE_ML=On \ + -DENABLE_PLUGIN_GO=On \ + -DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=Off \ + -DENABLE_BUNDLED_JSONC=On \ + -DENABLE_BUNDLED_PROTOBUF=Off \ + ${EXTRA_CMAKE_OPTIONS:-} +${GITHUB_ACTIONS+echo "::endgroup::"} + +${GITHUB_ACTIONS+echo "::group::Building"} +# shellcheck disable=SC2086 +cmake --build "${build}" -- ${build_args} +${GITHUB_ACTIONS+echo "::endgroup::"} + +if [ -t 1 ]; then + echo + echo "Compile with:" + echo "cmake --build \"${build}\"" +fi diff --git a/packaging/windows/fetch-msys2-installer.py b/packaging/windows/fetch-msys2-installer.py new file mode 100755 index 000000000..e30e7205c --- /dev/null +++ b/packaging/windows/fetch-msys2-installer.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python + +'''Fetch the MSYS2 installer.''' + +from __future__ import annotations + +import hashlib +import json +import shutil +import sys + +from pathlib import Path +from tempfile import TemporaryDirectory +from typing import Final +from urllib.request import Request, urlopen + +REPO: Final = 'msys2/msys2-installer' + + +def get_latest_release() -> tuple[str, str]: + '''Get the latest release for the repo.''' + REQUEST: Final = Request( + url=f'https://api.github.com/repos/{REPO}/releases', + headers={ + 'Accept': 'application/vnd.github+json', + 'X-GitHub-API-Version': '2022-11-28', + }, + method='GET', + ) + + print('>>> Fetching release list') + + with urlopen(REQUEST, timeout=15) as response: + if response.status != 200: + print(f'!!! Failed to fetch release list, status={response.status}') + sys.exit(1) + + data = json.load(response) + + data = list(filter(lambda x: x['name'] != 'Nightly Installer Build', data)) + + name = data[0]['name'] + version = data[0]['tag_name'].replace('-', '') + + return name, version + + +def fetch_release_asset(tmpdir: Path, name: str, file: str) -> Path: + '''Fetch a specific release asset.''' + REQUEST: Final = Request( + url=f'https://github.com/{REPO}/releases/download/{name}/{file}', + method='GET', + ) + TARGET: Final = tmpdir / file + + print(f'>>> Downloading {file}') + + with urlopen(REQUEST, timeout=15) as response: + if response.status != 200: + print(f'!!! Failed to fetch {file}, status={response.status}') + sys.exit(1) + + TARGET.write_bytes(response.read()) + + return TARGET + + +def main() -> None: + '''Core program logic.''' + if len(sys.argv) != 2: + print(f'{__file__} must be run with exactly one argument.') + + target = Path(sys.argv[1]) + tmp_target = target.with_name(f'.{target.name}.tmp') + + name, version = get_latest_release() + + with TemporaryDirectory() as tmpdir: + tmppath = Path(tmpdir) + + installer = fetch_release_asset(tmppath, name, f'msys2-base-x86_64-{version}.tar.zst') + checksums = fetch_release_asset(tmppath, name, f'msys2-base-x86_64-{version}.tar.zst.sha256') + + print('>>> Verifying SHA256 checksum') + expected_checksum = checksums.read_text().partition(' ')[0].casefold() + actual_checksum = hashlib.sha256(installer.read_bytes()).hexdigest().casefold() + + if expected_checksum != actual_checksum: + print('!!! Checksum mismatch') + print(f'!!! Expected: {expected_checksum}') + print(f'!!! Actual: {actual_checksum}') + sys.exit(1) + + print(f'>>> Copying to {target}') + + shutil.copy(installer, tmp_target) + tmp_target.replace(target) + + +if __name__ == '__main__': + main() diff --git a/packaging/windows/functions.ps1 b/packaging/windows/functions.ps1 new file mode 100644 index 000000000..a5f032daa --- /dev/null +++ b/packaging/windows/functions.ps1 @@ -0,0 +1,31 @@ +# Functions used by the PowerShell scripts in this directory. + +#Requires -Version 4.0 + +function Get-MSYS2Prefix { + if (-Not ($msysprefix)) { + if (Test-Path -Path C:\msys64\usr\bin\bash.exe) { + return "C:\msys64" + } elseif ($env:ChocolateyToolsLocation) { + if (Test-Path -Path "$env:ChocolateyToolsLocation\msys64\usr\bin\bash.exe") { + Write-Host "Found MSYS2 installed via Chocolatey" + Write-Host "This will work for building Netdata, but not for packaging it" + return "$env:ChocolateyToolsLocation\msys64" + } + } + } + + return "" +} + +function Get-MSYS2Bash { + $msysprefix = $args[0] + + if (-Not ($msysprefix)) { + $msysprefix = Get-MSYS2Prefix + } + + Write-Host "Using MSYS2 from $msysprefix" + + return "$msysprefix\usr\bin\bash.exe" +} diff --git a/packaging/windows/install-dependencies.ps1 b/packaging/windows/install-dependencies.ps1 new file mode 100644 index 000000000..66ec73160 --- /dev/null +++ b/packaging/windows/install-dependencies.ps1 @@ -0,0 +1,84 @@ +# Set up Windows build dependencies. +# +# This script first sees if msys is installed. If so, it just uses it. If not, it tries to bootstrap it with chocolatey or winget. + +#Requires -Version 4.0 + +$ErrorActionPreference = "Stop" + +. "$PSScriptRoot\functions.ps1" + +$msysprefix = Get-MSYS2Prefix + +function Check-FileHash { + $file_path = $args[0] + + Write-Host "Checking SHA256 hash of $file_path" + + $actual_hash = (Get-FileHash -Algorithm SHA256 -Path $file_path).Hash.toLower() + $expected_hash = (Get-Content "$file_path.sha256").split()[0] + + if ($actual_hash -ne $expected_hash) { + Write-Host "SHA256 hash mismatch!" + Write-Host "Expected: $expected_hash" + Write-Host "Actual: $actual_hash" + exit 1 + } +} + +function Install-MSYS2 { + $repo = 'msys2/msys2-installer' + $uri = "https://api.github.com/repos/$repo/releases" + $headers = @{ + 'Accept' = 'application/vnd.github+json' + 'X-GitHub-API-Version' = '2022-11-28' + } + $installer_path = "$env:TEMP\msys2-base.exe" + + if ($env:PROCESSOR_ARCHITECTURE -ne "AMD64") { + Write-Host "We can only install MSYS2 for 64-bit x86 systems, but you appear to have a different processor architecture ($env:PROCESSOR_ARCHITECTURE)." + Write-Host "You will need to install MSYS2 yourself instead." + exit 1 + } + + Write-Host "Determining latest release" + $release_list = Invoke-RestMethod -Uri $uri -Headers $headers -TimeoutSec 30 + + $release = $release_list[0] + $release_name = $release.name + $version = $release.tag_name.Replace('-', '') + $installer_url = "https://github.com/$repo/releases/download/$release_name/msys2-x86_64-$version.exe" + + Write-Host "Fetching $installer_url" + Invoke-WebRequest $installer_url -OutFile $installer_path + Write-Host "Fetching $installer_url.sha256" + Invoke-WebRequest "$installer_url.sha256" -OutFile "$installer_path.sha256" + + Write-Host "Checking file hash" + Check-FileHash $installer_path + + Write-Host "Installing" + & $installer_path in --confirm-command --accept-messages --root C:/msys64 + + return "C:\msys64" +} + +if (-Not ($msysprefix)) { + Write-Host "Could not find MSYS2, attempting to install it" + $msysprefix = Install-MSYS2 +} + +$msysbash = Get-MSYS2Bash "$msysprefix" +$env:CHERE_INVOKING = 'yes' + +& $msysbash -l "$PSScriptRoot\msys2-dependencies.sh" + +if ($LastExitcode -ne 0) { + Write-Host "First update attempt failed. This is expected if the msys-runtime package needed updated, trying again." + + & $msysbash -l "$PSScriptRoot\msys2-dependencies.sh" + + if ($LastExitcode -ne 0) { + exit 1 + } +} diff --git a/packaging/windows/installer.nsi b/packaging/windows/installer.nsi new file mode 100644 index 000000000..88d160a1d --- /dev/null +++ b/packaging/windows/installer.nsi @@ -0,0 +1,186 @@ +!include "MUI2.nsh" +!include "nsDialogs.nsh" +!include "FileFunc.nsh" + +Name "Netdata" +Outfile "netdata-installer.exe" +InstallDir "$PROGRAMFILES\Netdata" +RequestExecutionLevel admin + +!define MUI_ICON "NetdataWhite.ico" +!define MUI_UNICON "NetdataWhite.ico" + +!define ND_UININSTALL_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata" + +!define MUI_ABORTWARNING +!define MUI_UNABORTWARNING + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "C:\msys64\cloud.txt" +!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt" +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +Page Custom NetdataConfigPage NetdataConfigLeave +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +var hStartMsys +var startMsys + +var hCloudToken +var cloudToken +var hCloudRoom +var cloudRoom + +Function .onInit + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata' + pop $0 + ${If} $0 == 0 + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata' + pop $0 + ${EndIf} + + StrCpy $startMsys ${BST_UNCHECKED} +FunctionEnd + +Function NetdataConfigPage + !insertmacro MUI_HEADER_TEXT "Netdata configuration" "Claim your agent on Netdata Cloud" + + nsDialogs::Create 1018 + Pop $0 + ${If} $0 == error + Abort + ${EndIf} + + ${NSD_CreateLabel} 0 0 100% 12u "Enter your Token and Cloud Room." + ${NSD_CreateLabel} 0 15% 100% 12u "Optionally, you can open a terminal to execute additional commands." + + ${NSD_CreateLabel} 0 35% 20% 10% "Token" + Pop $0 + ${NSD_CreateText} 21% 35% 79% 10% "" + Pop $hCloudToken + + ${NSD_CreateLabel} 0 55% 20% 10% "Room" + Pop $0 + ${NSD_CreateText} 21% 55% 79% 10% "" + Pop $hCloudRoom + + ${NSD_CreateCheckbox} 0 70% 100% 10u "Open terminal" + Pop $hStartMsys + nsDialogs::Show +FunctionEnd + +Function NetdataConfigLeave + ${NSD_GetText} $hCloudToken $cloudToken + ${NSD_GetText} $hCloudRoom $cloudRoom + ${NSD_GetState} $hStartMsys $startMsys + + StrLen $0 $cloudToken + StrLen $1 $cloudRoom + ${If} $0 == 125 + ${AndIf} $0 == 36 + # We should start our new claiming software here + MessageBox MB_OK "$cloudToken | $cloudRoom | $startMsys" + ${EndIf} + + ${If} $startMsys == 1 + nsExec::ExecToLog '$INSTDIR\msys2.exe' + pop $0 + ${EndIf} +FunctionEnd + +Function NetdataUninstallRegistry + ClearErrors + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "DisplayName" "Netdata - Real-time system monitoring." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "DisplayIcon" "$INSTDIR\Uninstall.exe,0" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "UninstallString" "$INSTDIR\Uninstall.exe" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "RegOwner" "Netdata Inc." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "RegCompany" "Netdata Inc." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "Publisher" "Netdata Inc." + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "HelpLink" "https://learn.netdata.cloud/" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "URLInfoAbout" "https://www.netdata.cloud/" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "DisplayVersion" "${CURRVERSION}" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "VersionMajor" "${MAJORVERSION}" + WriteRegStr HKLM "${ND_UININSTALL_REG}" \ + "VersionMinor" "${MINORVERSION}" + + IfErrors 0 +2 + MessageBox MB_ICONEXCLAMATION|MB_OK "Unable to create an entry in the Control Panel!" IDOK end + + ClearErrors + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD HKLM "${ND_UININSTALL_REG}" "EstimatedSize" "$0" + + IfErrors 0 +2 + MessageBox MB_ICONEXCLAMATION|MB_OK "Cannot estimate the installation size." IDOK end + end: +FunctionEnd + +Section "Install Netdata" + SetOutPath $INSTDIR + SetCompress off + + File /r "C:\msys64\opt\netdata\*.*" + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe create Netdata binPath= "$INSTDIR\usr\bin\netdata.exe" start= delayed-auto' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to create Netdata service." + ${EndIf} + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe description Netdata "Real-time system monitoring service"' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to add Netdata service description." + ${EndIf} + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to start Netdata service." + ${EndIf} + + WriteUninstaller "$INSTDIR\Uninstall.exe" + + Call NetdataUninstallRegistry +SectionEnd + +Section "Uninstall" + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to stop Netdata service." + ${EndIf} + + ClearErrors + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata' + pop $0 + ${If} $0 != 0 + DetailPrint "Warning: Failed to delete Netdata service." + ${EndIf} + + RMDir /r "$INSTDIR" + + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata" +SectionEnd + diff --git a/packaging/windows/invoke-msys2.ps1 b/packaging/windows/invoke-msys2.ps1 new file mode 100644 index 000000000..bffa7f90b --- /dev/null +++ b/packaging/windows/invoke-msys2.ps1 @@ -0,0 +1,16 @@ +# Invoke the specified script using MSYS2 + +#Requires -Version 4.0 + +$ErrorActionPreference = "Stop" + +. "$PSScriptRoot\functions.ps1" + +$msysbash = Get-MSYS2Bash "$msysprefix" +$env:CHERE_INVOKING = 'yes' + +& $msysbash -l $args[0] + +if ($LastExitcode -ne 0) { + exit 1 +} diff --git a/packaging/windows/msys2-dependencies.sh b/packaging/windows/msys2-dependencies.sh new file mode 100755 index 000000000..95a1952df --- /dev/null +++ b/packaging/windows/msys2-dependencies.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Install the dependencies we need to build Netdata on MSYS2 + +. /etc/profile + +set -euo pipefail + +${GITHUB_ACTIONS+echo "::group::Updating MSYS2"} +pacman -Syuu --noconfirm +${GITHUB_ACTIONS+echo "::endgroup::"} + +${GITHUB_ACTIONS+echo "::group::Installing dependencies"} +pacman -S --noconfirm --needed \ + base-devel \ + cmake \ + git \ + liblz4-devel \ + libutil-linux \ + libutil-linux-devel \ + libyaml-devel \ + libzstd-devel \ + mingw64/mingw-w64-x86_64-brotli \ + mingw64/mingw-w64-x86_64-go \ + mingw64/mingw-w64-x86_64-libuv \ + mingw64/mingw-w64-x86_64-lz4 \ + mingw64/mingw-w64-x86_64-nsis \ + mingw64/mingw-w64-x86_64-openssl \ + mingw64/mingw-w64-x86_64-pcre2 \ + mingw64/mingw-w64-x86_64-protobuf \ + mingw64/mingw-w64-x86_64-zlib \ + mingw-w64-ucrt-x86_64-toolchain \ + mingw-w64-x86_64-toolchain \ + msys2-devel \ + msys/brotli-devel \ + msys/libuv-devel \ + msys/pcre2-devel \ + msys/zlib-devel \ + openssl-devel \ + protobuf-devel \ + python \ + ucrt64/mingw-w64-ucrt-x86_64-brotli \ + ucrt64/mingw-w64-ucrt-x86_64-go \ + ucrt64/mingw-w64-ucrt-x86_64-libuv \ + ucrt64/mingw-w64-ucrt-x86_64-lz4 \ + ucrt64/mingw-w64-ucrt-x86_64-openssl \ + ucrt64/mingw-w64-ucrt-x86_64-pcre2 \ + ucrt64/mingw-w64-ucrt-x86_64-protobuf \ + ucrt64/mingw-w64-ucrt-x86_64-zlib +${GITHUB_ACTIONS+echo "::endgroup::"} diff --git a/packaging/windows/package-windows.sh b/packaging/windows/package-windows.sh new file mode 100755 index 000000000..03f72a692 --- /dev/null +++ b/packaging/windows/package-windows.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +repo_root="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")" + +if [ -n "${BUILD_DIR}" ]; then + build="${BUILD_DIR}" +elif [ -n "${OSTYPE}" ]; then + if [ -n "${MSYSTEM}" ]; then + build="${repo_root}/build-${OSTYPE}-${MSYSTEM}" + else + build="${repo_root}/build-${OSTYPE}" + fi +elif [ "$USER" = "vk" ]; then + build="${repo_root}/build" +else + build="${repo_root}/build" +fi + +set -exu -o pipefail + +${GITHUB_ACTIONS+echo "::group::Installing"} +cmake --install "${build}" +${GITHUB_ACTIONS+echo "::endgroup::"} + +if [ ! -f "/msys2-latest.tar.zst" ]; then + ${GITHUB_ACTIONS+echo "::group::Fetching MSYS2 files"} + "${repo_root}/packaging/windows/fetch-msys2-installer.py" /msys2-latest.tar.zst + ${GITHUB_ACTIONS+echo "::endgroup::"} +fi + +${GITHUB_ACTIONS+echo "::group::Licenses"} +if [ ! -f "/gpl-3.0.txt" ]; then + curl -o /gpl-3.0.txt "https://www.gnu.org/licenses/gpl-3.0.txt" +fi + +if [ ! -f "/cloud.txt" ]; then + curl -o /cloud.txt "https://raw.githubusercontent.com/netdata/netdata/master/src/web/gui/v2/LICENSE.md" +fi +${GITHUB_ACTIONS+echo "::endgroup::"} + +${GITHUB_ACTIONS+echo "::group::Packaging"} +tar -xf /msys2-latest.tar.zst -C /opt/netdata/ || exit 1 +cp -R /opt/netdata/msys64/* /opt/netdata/ || exit 1 +rm -rf /opt/netdata/msys64/ +NDVERSION=$"$(grep 'CMAKE_PROJECT_VERSION:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)" +NDMAJORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MAJOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)" +NDMINORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MINOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)" + +/mingw64/bin/makensis.exe -DCURRVERSION="${NDVERSION}" -DMAJORVERSION="${NDMAJORVERSION}" -DMINORVERSION="${NDMINORVERSION}" "${repo_root}/packaging/windows/installer.nsi" +${GITHUB_ACTIONS+echo "::endgroup::"} + diff --git a/packaging/windows/package.ps1 b/packaging/windows/package.ps1 new file mode 100644 index 000000000..828e105f1 --- /dev/null +++ b/packaging/windows/package.ps1 @@ -0,0 +1,16 @@ +# Package the build + +#Requires -Version 4.0 + +$ErrorActionPreference = "Stop" + +. "$PSScriptRoot\functions.ps1" + +$msysbash = Get-MSYS2Bash "$msysprefix" +$env:CHERE_INVOKING = 'yes' + +& $msysbash -l "$PSScriptRoot\package-windows.sh" + +if ($LastExitcode -ne 0) { + exit 1 +} diff --git a/packaging/windows/protoc.bat b/packaging/windows/protoc.bat new file mode 100644 index 000000000..fe7a76f27 --- /dev/null +++ b/packaging/windows/protoc.bat @@ -0,0 +1,9 @@ +@echo off +:: +:: The problem with /usr/bin/protoc is that it accepts colon separated (:) paths at its parameters. +:: This makes C:/ being parsed as 2 paths: C and /, which of course both fail. +:: To overcome this problem, we use bash_execute.sh, which replaces all occurences of C: with /c. +:: +set "batch_dir=%~dp0" +set "batch_dir=%batch_dir:\=/%" +C:\msys64\usr\bin\bash.exe %batch_dir%/bash_execute.sh protoc %* diff --git a/packaging/windows/win-build-dir.sh b/packaging/windows/win-build-dir.sh new file mode 100644 index 000000000..09dd6b977 --- /dev/null +++ b/packaging/windows/win-build-dir.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ -n "${BUILD_DIR}" ]; then + if (echo "${BUILD_DIR}" | grep -q -E "^[A-Z]:\\\\"); then + build="$(echo "${BUILD_DIR}" | sed -e 's/\\/\//g' -e 's/^\([A-Z]\):\//\/\1\//' -)" + else + build="${BUILD_DIR}" + fi +elif [ -n "${OSTYPE}" ]; then + if [ -n "${MSYSTEM}" ]; then + build="${REPO_ROOT}/build-${OSTYPE}-${MSYSTEM}" + else + build="${REPO_ROOT}/build-${OSTYPE}" + fi +elif [ "$USER" = "vk" ]; then + build="${REPO_ROOT}/build" +else + # shellcheck disable=SC2034 + build="${REPO_ROOT}/build" +fi diff --git a/packaging/windows/windows-openssh-to-msys.bat b/packaging/windows/windows-openssh-to-msys.bat new file mode 100644 index 000000000..829cb4845 --- /dev/null +++ b/packaging/windows/windows-openssh-to-msys.bat @@ -0,0 +1,118 @@ +@echo off +:: +:: This script will: +:: +:: 1. install the windows OpenSSH server (either via dsim or download it) +:: 2. activate the windows OpenSSH service +:: 3. open OpenSSH TCP port at windows firewall +:: 4. create a small batch file to start an MSYS session +:: 5. Set the default OpenSSH startup script to start the MSYS session +:: +:: Problems: +:: On older windows versions, terminal emulation is broken. +:: So, on windows 10 or windows server before 2019, the ssh session +:: will not have proper terminal emulation and will be not be able to +:: be used for editing files. +:: For more info check: +:: https://github.com/PowerShell/Win32-OpenSSH/issues/1260 +:: + +:: Check if OpenSSH Server is already installed +sc query sshd >nul 2>&1 +if %errorlevel% neq 0 ( + echo "OpenSSH Server not found. Attempting to install via dism..." + goto :install_openssh_dism +) else ( + echo "OpenSSH Server is already installed." + goto :configure_openssh +) + +:: Install OpenSSH using dism +:install_openssh_dism +dism /online /Enable-Feature /FeatureName:OpenSSH-Client /All >nul 2>&1 +dism /online /Enable-Feature /FeatureName:OpenSSH-Server /All >nul 2>&1 + +:: Check if dism succeeded in installing OpenSSH +sc query sshd >nul 2>&1 +if %errorlevel% neq 0 ( + echo "OpenSSH installation via dism failed or is unavailable." + goto :install_openssh_manual +) else ( + echo "OpenSSH installed successfully using dism." + goto :configure_openssh +) + +:: Function to Install OpenSSH manually if dism fails +:install_openssh_manual +echo "Installing OpenSSH manually..." + +:: Download the latest OpenSSH release +set DOWNLOAD_URL=https://github.com/PowerShell/Win32-OpenSSH/releases/download/v9.5.0.0p1-Beta/OpenSSH-Win64.zip +set DOWNLOAD_FILE=%temp%\OpenSSH-Win64.zip +set INSTALL_DIR=C:\Program Files\OpenSSH-Win64 + +:: Create the installation directory if it doesn't exist +if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" + +:: Attempt to download OpenSSH using Invoke-WebRequest and TLS configuration +powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { Invoke-WebRequest -Uri '%DOWNLOAD_URL%' -OutFile '%DOWNLOAD_FILE%' -UseBasicParsing; exit 0 } catch { exit 1 }" +if %errorlevel% neq 0 ( + echo "Invoke-WebRequest download failed. Attempting to download using curl..." + curl -L -o "%DOWNLOAD_FILE%" "%DOWNLOAD_URL%" + if %errorlevel% neq 0 ( + echo "Failed to download OpenSSH using curl. Exiting..." + exit /b 1 + ) +) + +:: Unzip directly to INSTALL_DIR (flatten the folder structure) +powershell -Command "Expand-Archive -Path '%DOWNLOAD_FILE%' -DestinationPath '%INSTALL_DIR%' -Force" +if %errorlevel% neq 0 ( + echo "Failed to unzip OpenSSH package." + exit /b 1 +) + +:: Move inner contents to INSTALL_DIR if nested OpenSSH-Win64 folder exists +if exist "%INSTALL_DIR%\OpenSSH-Win64" ( + xcopy "%INSTALL_DIR%\OpenSSH-Win64\*" "%INSTALL_DIR%\" /s /e /y + rmdir "%INSTALL_DIR%\OpenSSH-Win64" /s /q +) + +:: Add the OpenSSH binaries to the system PATH +setx /M PATH "%INSTALL_DIR%;%PATH%" + +:: Register OpenSSH utilities as services using PowerShell +powershell -ExecutionPolicy Bypass -Command "& '%INSTALL_DIR%\install-sshd.ps1'" + +:: Verify if manual installation succeeded +sc query sshd >nul 2>&1 +if %errorlevel% neq 0 ( + echo "Manual OpenSSH installation failed. Exiting..." + exit /b 1 +) else ( + echo "OpenSSH installed successfully manually." + goto :configure_openssh +) + +:configure_openssh +:: Ensure OpenSSH Server service is set to start automatically and start the service +sc config sshd start= auto +net start sshd + +:: Create msys2.bat file with specific content +set MSYS2_PATH=C:\msys64 +if not exist "%MSYS2_PATH%" ( + echo "Error: %MSYS2_PATH% does not exist." + exit /b 1 +) + +echo @%MSYS2_PATH%\msys2_shell.cmd -defterm -here -no-start -msys > %MSYS2_PATH%\msys2.bat + +:: Run PowerShell command to set default shell +powershell -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name 'DefaultShell' -Value '%MSYS2_PATH%\msys2.bat' -PropertyType String -Force" + +:: Open the Windows Firewall for sshd (using PowerShell) +powershell -Command "New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd) Incoming' -Description 'Allow incoming SSH traffic via OpenSSH server' -Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow" + +echo "OpenSSH has been successfully configured with MSYS2 as the default shell, and the firewall has been opened for sshd." +pause -- cgit v1.2.3