summaryrefslogtreecommitdiffstats
path: root/packaging/utils
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packaging/utils/bash_execute.sh19
-rw-r--r--packaging/utils/clion-msys-mingw64-environment.bat17
-rw-r--r--packaging/utils/clion-msys-msys-environment.bat20
-rw-r--r--packaging/utils/compile-on-windows.sh71
-rwxr-xr-xpackaging/utils/coverity-scan.sh (renamed from coverity-scan.sh)55
-rw-r--r--packaging/utils/installer.nsi34
-rw-r--r--packaging/utils/package-windows.sh27
-rw-r--r--packaging/utils/protoc.bat9
-rw-r--r--packaging/utils/windows-openssh-to-msys.bat118
9 files changed, 347 insertions, 23 deletions
diff --git a/packaging/utils/bash_execute.sh b/packaging/utils/bash_execute.sh
new file mode 100644
index 000000000..4092db966
--- /dev/null
+++ b/packaging/utils/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/utils/clion-msys-mingw64-environment.bat b/packaging/utils/clion-msys-mingw64-environment.bat
new file mode 100644
index 000000000..19035d8eb
--- /dev/null
+++ b/packaging/utils/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/utils/clion-msys-msys-environment.bat b/packaging/utils/clion-msys-msys-environment.bat
new file mode 100644
index 000000000..9f0c095d3
--- /dev/null
+++ b/packaging/utils/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/utils/compile-on-windows.sh b/packaging/utils/compile-on-windows.sh
new file mode 100644
index 000000000..aa44771b8
--- /dev/null
+++ b/packaging/utils/compile-on-windows.sh
@@ -0,0 +1,71 @@
+#!/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/coverity-scan.sh b/packaging/utils/coverity-scan.sh
index 8466b21a7..b69fea561 100755
--- a/coverity-scan.sh
+++ b/packaging/utils/coverity-scan.sh
@@ -42,11 +42,31 @@ INSTALL_DIR="/opt"
# the version of coverity to use
COVERITY_BUILD_VERSION="${COVERITY_BUILD_VERSION:-cov-analysis-linux64-2023.6.2}"
-# TODO: For some reasons this does not fully load on Debian 10 (Haven't checked if it happens on other distros yet), it breaks
-source packaging/installer/functions.sh || echo "Failed to fully load the functions library"
+SCRIPT_SOURCE="$(
+ self=${0}
+ while [ -L "${self}" ]
+ do
+ cd "${self%/*}" || exit 1
+ self=$(readlink "${self}")
+ done
+ cd "${self%/*}" || exit 1
+ echo "$(pwd -P)/${self##*/}"
+)"
+REPO_ROOT="$(dirname "${SCRIPT_SOURCE}")/../.."
+
+. "${REPO_ROOT}/packaging/installer/functions.sh"
+
+JOBS=$(find_processors)
+[ -z "${JOBS}" ] && JOBS=1
+
+if command -v ninja 2>&1; then
+ ninja="$(command -v ninja)"
+fi
-cpus=$(find_processors)
-[ -z "${cpus}" ] && cpus=1
+CMAKE_OPTS="${ninja:+-G Ninja}"
+BUILD_OPTS="VERBOSE=1"
+[ -n "${ninja}" ] && BUILD_OPTS="-v"
+NETDATA_BUILD_DIR="${NETDATA_BUILD_DIR:-./build/}"
if [ -f ".coverity-scan.conf" ]; then
source ".coverity-scan.conf"
@@ -98,23 +118,27 @@ scanit() {
fatal "The command '${covbuild}' is not executable. Export variable COVERITY_BUILD_PATH or set it in .coverity-scan.conf"
fi
+ cd "${REPO_ROOT}" || exit 1
+
version="$(grep "^#define PACKAGE_VERSION" config.h | cut -d '"' -f 2)"
progress "Working on netdata version: ${version}"
progress "Cleaning up old builds..."
- run make clean || echo >&2 "Nothing to clean"
+ rm -rf "${NETDATA_BUILD_DIR}"
[ -d "cov-int" ] && rm -rf "cov-int"
[ -f netdata-coverity-analysis.tgz ] && run rm netdata-coverity-analysis.tgz
progress "Configuring netdata source..."
+ USE_SYSTEM_PROTOBUF=1
+ ENABLE_GO=0
+ prepare_cmake_options
- run autoreconf -ivf
- run ./configure ${OTHER_OPTIONS}
+ run cmake ${NETDATA_CMAKE_OPTIONS}
progress "Analyzing netdata..."
- run "${covbuild}" --dir cov-int make -j${cpus}
+ run "${covbuild}" --dir cov-int cmake --build "${NETDATA_BUILD_DIR}" --parallel ${JOBS} -- ${BUILD_OPTS}
echo >&2 "Compressing analysis..."
run tar czvf netdata-coverity-analysis.tgz cov-int
@@ -170,21 +194,6 @@ installit() {
return 0
}
-OTHER_OPTIONS="--disable-lto"
-OTHER_OPTIONS+=" --with-zlib"
-OTHER_OPTIONS+=" --with-math"
-OTHER_OPTIONS+=" --enable-lz4"
-OTHER_OPTIONS+=" --enable-openssl"
-OTHER_OPTIONS+=" --enable-jsonc"
-OTHER_OPTIONS+=" --enable-plugin-nfacct"
-OTHER_OPTIONS+=" --enable-plugin-freeipmi"
-OTHER_OPTIONS+=" --enable-plugin-cups"
-OTHER_OPTIONS+=" --enable-exporting-prometheus-remote-write"
-# TODO: enable these plugins too
-#OTHER_OPTIONS+=" --enable-plugin-xenstat"
-#OTHER_OPTIONS+=" --enable-exporting-kinesis"
-#OTHER_OPTIONS+=" --enable-exporting-mongodb"
-
FOUND_OPTS="NO"
while [ -n "${1}" ]; do
if [ "${1}" = "--with-install" ]; then
diff --git a/packaging/utils/installer.nsi b/packaging/utils/installer.nsi
new file mode 100644
index 000000000..b78f52ffe
--- /dev/null
+++ b/packaging/utils/installer.nsi
@@ -0,0 +1,34 @@
+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
new file mode 100644
index 000000000..b6996b9ec
--- /dev/null
+++ b/packaging/utils/package-windows.sh
@@ -0,0 +1,27 @@
+#!/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
new file mode 100644
index 000000000..fe7a76f27
--- /dev/null
+++ b/packaging/utils/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/utils/windows-openssh-to-msys.bat b/packaging/utils/windows-openssh-to-msys.bat
new file mode 100644
index 000000000..829cb4845
--- /dev/null
+++ b/packaging/utils/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