@cryptotaxi247 / netdata-1 / commits / 2db8a882e

Large-scale cleanup of static build infrastructure. (#19852)

* Centralize cache path handling. * Add better debugging support for static build infrastructure. * Centralize handling of git repository fetching for static builds. * Centralize build directory handling in the static build. And quit using a sub-directory of packaging/makeself from the source tree for it. * Remove version numbers from static build jobs. * Better organize static build jobs. 0x numbers for non-build prep-work 1x numbers for libraries that potentially impact multiple other things we vendor. 2x numbers for libraries that are direct dependencies of Netdata 3x numbers for combined libraries and tooling used by Netdata 4x numbers for general tooling used by Netdata 5x numbers for tooling used by single specific components 6x numbers for non-build prep-work for the Netdata build 7x numbers for the actual build of Netdata 8x numbers for post-build checks 9x numbers for the actual packaging * Clean up variable handling in Netdata build job. * Split post-build handling steps to their own jobs. This will make it easier to see what is actually going on in the build process. * Clean up CI messages. * Split archive creation sub-steps into indivudal jobs. * Disable shell tracing for archive creation job. It’s not needed in 99.9% of cases, and should only be enabled locally if it is needed. * Assorted fixes for code restructuring. * Tidy up paths for runtime check. * Fix CI handling of artifacts.

Austin S. Hemmelgarn committed Mar 25, 2025 at 07:00 UTC 2db8a882e886941483b72aa7c37b20a6f3ee20cb
24 files changed +335 -286
.github/scripts/build-static.sh
-6
@@ -22,12 +22,6 @@ build_static() {
22
23 prepare_assets() {
24 cp packaging/version artifacts/latest-version.txt
25 -
26 - cd artifacts || exit 1
27 - ln -s "${BASENAME}.gz.run" "netdata-${BUILDARCH}-latest.gz.run"
28 - if [ "${BUILDARCH}" = "x86_64" ]; then
29 - ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
30 - fi
25 }
26
27 steps="prepare_build build_static"
packaging/makeself/build-static.sh
+1
@@ -85,6 +85,7 @@ fi
85 if [ -t 1 ]; then
86 run ${docker} run --rm -e BUILDARCH="${BUILDARCH}" -a stdin -a stdout -a stderr -i -t -v "$(pwd)":/netdata:rw \
87 --platform "${platform}" ${EXTRA_INSTALL_FLAGS:+-e EXTRA_INSTALL_FLAGS="${EXTRA_INSTALL_FLAGS}"} \
88 + ${DEBUG_BUILD_INFRA:+-e DEBUG_BUILD_INFRA=1} \
89 ${QEMU_CPU:+-e QEMU_CPU="${QEMU_CPU}"} \
90 -e TUNING_FLAGS="${TUNING_FLAGS}" \
91 ${GOAMD64:+-e GOAMD64="${GOAMD64}"} ${GOARM:+-e GOARM="${GOARM}"} \
packaging/makeself/build.sh
+10 -20
@@ -23,15 +23,7 @@ done
23
24 # -----------------------------------------------------------------------------
25
26 -# First run install-alpine-packages.sh under alpine linux to install
27 -# the required packages. build-x86_64-static.sh will do this for you
28 -# using docker.
29 -
30 -mkdir -p /usr/src
31 -cp -va /netdata /usr/src/netdata
32 -chown -R root:root /usr/src/netdata
33 -
34 -cd /usr/src/netdata/packaging/makeself || exit 1
26 +cd /netdata/packaging/makeself || exit 1
27
28 cat >&2 << EOF
29 This program will create a self-extracting shell package containing
@@ -42,21 +34,19 @@ It can be used to have netdata running in no-time, or in cases the
34 target Linux system cannot compile netdata.
35 EOF
36
45 -if [ ! -d tmp ]; then
46 - mkdir tmp || exit 1
47 -else
48 - rm -rf tmp/*
49 -fi
50 -
37 if [ -z "${GITHUB_ACTIONS}" ]; then
38 export GITHUB_ACTIONS=false
39 fi
40
41 +mkdir -p /netdata/artifacts
42 +chown "$(stat -c '%u:%g' /netdata)" /netdata/artifacts/
43 +
44 if ! ./run-all-jobs.sh "$@"; then
45 printf >&2 "Build failed."
57 - exit 1
58 -fi
46
60 -mkdir -p /netdata/artifacts
61 -cp -va /usr/src/netdata/artifacts/* /netdata/artifacts/
62 -chown -R "$(stat -c '%u:%g' /netdata)" /netdata/artifacts/
47 + if [ -n "${DEBUG_BUILD_INFRA}" ]; then
48 + exec /bin/bash
49 + else
50 + exit 1
51 + fi
52 +fi
packaging/makeself/functions.sh
+70 -22
@@ -40,64 +40,112 @@ set -euo pipefail
40
41 # -----------------------------------------------------------------------------
42
43 +cache_path() {
44 + local key="${1}"
45 + echo "${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/${key}"
46 +}
47 +
48 +build_path() {
49 + local dir="${1}"
50 + local prefix="/build"
51 +
52 + mkdir -p "${prefix}"
53 +
54 + echo "${prefix}/${dir}"
55 +}
56 +
57 fetch() {
58 local dir="${1}" url="${2}" sha256="${3}" key="${4}"
59 local tar
60 tar="$(basename "${2}")"
47 - local cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/${key}"
61 + local cache
62 + cache="$(cache_path "${key}")"
63 + local path
64 + path="$(build_path "${dir}")"
65
49 - if [ -d "${NETDATA_MAKESELF_PATH}/tmp/${dir}" ]; then
50 - rm -rf "${NETDATA_MAKESELF_PATH}/tmp/${dir}"
66 + if [ -d "${path}" ]; then
67 + rm -rf "${path}"
68 fi
69
70 if [ -d "${cache}/${dir}" ]; then
71 echo "Found cached copy of build directory for ${key}, using it."
55 - cp -a "${cache}/${dir}" "${NETDATA_MAKESELF_PATH}/tmp/"
72 + cp -a "${cache}/${dir}" "${path}"
73 CACHE_HIT=1
74 else
75 echo "No cached copy of build directory for ${key} found, fetching sources instead."
76
60 - if [ ! -f "${NETDATA_MAKESELF_PATH}/tmp/${tar}" ]; then
61 - run wget -O "${NETDATA_MAKESELF_PATH}/tmp/${tar}" "${url}"
77 + if [ ! -f "/tmp/${tar}" ]; then
78 + run wget -O "/tmp/${tar}" "${url}"
79 fi
80
81 # Check SHA256 of gzip'd tar file (apparently alpine's sha256sum requires
82 # two empty spaces between the checksum and the file's path)
83 set +e
67 - echo "${sha256} ${NETDATA_MAKESELF_PATH}/tmp/${tar}" | sha256sum --c --status
84 + echo "${sha256} /tmp/${tar}" | sha256sum --c --status
85 local rc=$?
86 if [ ${rc} -ne 0 ]; then
87 echo >&2 "SHA256 verification of tar file ${tar} failed (rc=${rc})"
71 - echo >&2 "expected: ${sha256}, got $(sha256sum "${NETDATA_MAKESELF_PATH}/tmp/${tar}")"
88 + echo >&2 "expected: ${sha256}, got $(sha256sum "/tmp/${tar}")"
89 exit 1
90 fi
91
92 set -e
76 - cd "${NETDATA_MAKESELF_PATH}/tmp"
77 - run tar -axpf "${tar}"
78 - cd -
93 + run tar -axpf "/tmp/${tar}" -C "/build"
94
95 CACHE_HIT=0
96 fi
97
83 - run cd "${NETDATA_MAKESELF_PATH}/tmp/${dir}"
98 + run cd "${path}"
99 }
100
86 -store_cache() {
87 - key="${1}"
88 - src="${2}"
101 +fetch_git() {
102 + local dir="${1}" url="${2}" tag="${3}" key="${4}" fetch_via_checkout="${5:-""}"
103 + local cache
104 + cache="$(cache_path "${key}")"
105 + local path
106 + path="$(build_path "${dir}")"
107
90 - cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/${key}"
108 + if [ -d "${path}" ]; then
109 + rm -rf "${path}"
110 + fi
111
92 - if [ "${CACHE_HIT:-0}" -eq 0 ]; then
93 - if [ -d "${cache}" ]; then
94 - rm -rf "${cache}"
95 - fi
112 + if [ -d "${cache}/${dir}" ]; then
113 + echo "Found cached copy of build directory for ${key}, using it."
114 + cp -a "${cache}/${dir}" "${path}"
115 + CACHE_HIT=1
116 + else
117 + echo "No cached copy of build directory for ${key} found, fetching sources instead."
118 + if [ -n "${fetch_via_checkout}" ]; then
119 + run git clone "${url}" "${path}"
120 + cd "${path}" && run git checkout "${tag}"
121 + else
122 + run git clone --branch "${tag}" --single-branch --depth 1 "${url}" "${path}"
123 + fi
124 + CACHE_HIT=0
125 + fi
126
97 - mkdir -p "${cache}"
127 + run cd "${path}"
128 +}
129
99 - cp -a "${src}" "${cache}"
130 +store_cache() {
131 + local key="${1}"
132 + local dir="${2}"
133 + local src
134 + src="$(build_path "${dir}")"
135 +
136 + local cache
137 + cache="$(cache_path "${key}")"
138 +
139 + if [ "${CACHE_HIT:-0}" -eq 0 ]; then
140 + if [ -d "${cache}" ]; then
141 + rm -rf "${cache}"
142 fi
143 +
144 + mkdir -p "${cache}"
145 +
146 + cp -a "${src}" "${cache}"
147 + chown -R "$(stat -c '%u:%g' "${NETDATA_SOURCE_PATH}")" "${cache}"
148 + fi
149 }
150
151 # -----------------------------------------------------------------------------
packaging/makeself/jobs/00-prepare-destination.install.sh renamed
+1 -1
@@ -5,7 +5,7 @@
5 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6
7 # shellcheck disable=SC2015
8 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Preparing build environment" || true
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Preparing install path" || true
9
10 [ -d "${NETDATA_INSTALL_PATH}.old" ] && run rm -rf "${NETDATA_INSTALL_PATH}.old"
11 [ -d "${NETDATA_INSTALL_PATH}" ] && run mv -f "${NETDATA_INSTALL_PATH}" "${NETDATA_INSTALL_PATH}.old"
packaging/makeself/jobs/10-libucontext.install.sh renamed
+4 -17
@@ -19,23 +19,10 @@ export CFLAGS="${TUNING_FLAGS} -pipe"
19 export CXXFLAGS="${CFLAGS}"
20 export LDFLAGS=""
21
22 -if [ -d "${NETDATA_MAKESELF_PATH}/tmp/libucontext" ]; then
23 - rm -rf "${NETDATA_MAKESELF_PATH}/tmp/libucontext"
24 -fi
25 -
26 -cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/libucontext"
27 -
28 -if [ -d "${cache}" ]; then
29 - echo "Found cached copy of build directory for libucontext, using it."
30 - cp -a "${cache}/libucontext" "${NETDATA_MAKESELF_PATH}/tmp/"
31 - CACHE_HIT=1
32 -else
33 - echo "No cached copy of build directory for libucontext found, fetching sources instead."
34 - run git clone --branch "${LIBUCONTEXT_VERSION}" --single-branch --depth 1 "${LIBUCONTEXT_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/libucontext"
35 - CACHE_HIT=0
36 -fi
22 +cache_key="libucontext"
23 +build_dir="${LIBUCONTEXT_VERSION}"
24
38 -cd "${NETDATA_MAKESELF_PATH}/tmp/libucontext" || exit 1
25 +fetch_git "${build_dir}" "${LIBUCONTEXT_SOURCE}" "${LIBUCONTEXT_VERSION}" "${cache_key}"
26
27 case "${BUILDARCH}" in
28 armv6l|armv7l) arch=arm ;;
@@ -49,7 +36,7 @@ fi
36
37 run make ARCH="${arch}" EXPORT_UNPREFIXED="yes" DESTDIR="/libucontext-static" -j "$(nproc)" install
38
52 -store_cache libucontext "${NETDATA_MAKESELF_PATH}/tmp/libucontext"
39 +store_cache "${cache_key}" "${build_dir}"
40
41 # shellcheck disable=SC2015
42 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/11-openssl.install.sh renamed
+4 -21
@@ -13,27 +13,10 @@ export CXXFLAGS="${CFLAGS}"
13 export LDFLAGS="-static"
14 export PKG_CONFIG="pkg-config --static"
15
16 -if [ -d "${NETDATA_MAKESELF_PATH}/tmp/openssl" ]; then
17 - rm -rf "${NETDATA_MAKESELF_PATH}/tmp/openssl"
18 -fi
19 -
20 -if [ -d "${NETDATA_MAKESELF_PATH}/tmp/openssl" ]; then
21 - rm -rf "${NETDATA_MAKESELF_PATH}/tmp/openssl"
22 -fi
23 -
24 -cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/openssl"
25 -
26 -if [ -d "${cache}" ]; then
27 - echo "Found cached copy of build directory for openssl, using it."
28 - cp -a "${cache}/openssl" "${NETDATA_MAKESELF_PATH}/tmp/"
29 - CACHE_HIT=1
30 -else
31 - echo "No cached copy of build directory for openssl found, fetching sources instead."
32 - run git clone --branch "${OPENSSL_VERSION}" --single-branch --depth 1 "${OPENSSL_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/openssl"
33 - CACHE_HIT=0
34 -fi
16 +cache_key="openssl"
17 +build_dir="${OPENSSL_VERSION}"
18
36 -cd "${NETDATA_MAKESELF_PATH}/tmp/openssl" || exit 1
19 +fetch_git "${build_dir}" "${OPENSSL_SOURCE}" "${OPENSSL_VERSION}" "${cache_key}"
20
21 if [ "${CACHE_HIT:-0}" -eq 0 ]; then
22 COMMON_CONFIG="-static threads no-tests --prefix=/openssl-static --openssldir=/opt/netdata/etc/ssl"
@@ -57,7 +40,7 @@ if [ -d "/openssl-static/lib" ]; then
40 cd - || exit 1
41 fi
42
60 -store_cache openssl "${NETDATA_MAKESELF_PATH}/tmp/openssl"
43 +store_cache "${cache_key}" "${build_dir}"
44
45 perl configdata.pm --dump
46
packaging/makeself/jobs/20-libnetfilter_acct.install.sh renamed
+6 -5
@@ -10,7 +10,7 @@
10 . "$(dirname "${0}")/../bundled-packages.version" || exit 1
11
12 # shellcheck disable=SC2015
13 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::building libnetfilter_acct" || true
13 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building libnetfilter_acct" || true
14
15 export CFLAGS="${TUNING_FLAGS} -static -I/usr/include/libmnl -pipe"
16 export CXXFLAGS="${CFLAGS}"
@@ -18,9 +18,11 @@ export LDFLAGS="-static -L/usr/lib -lmnl"
18 export PKG_CONFIG="pkg-config --static"
19 export PKG_CONFIG_PATH="/usr/lib/pkgconfig"
20
21 -fetch "libnetfilter_acct-${LIBNETFILTER_ACT_VERSION}" "${LIBNETFILTER_ACT_SOURCE}/libnetfilter_acct-${LIBNETFILTER_ACT_VERSION}.tar.bz2" \
22 - "${LIBNETFILTER_ACT_ARTIFACT_SHA256}" libnetfilter_acct
21 +cache_key="libnetfilter_acct"
22 +build_dir="libnetfilter_acct-${LIBNETFILTER_ACT_VERSION}"
23
24 +fetch "${build_dir}" "${LIBNETFILTER_ACT_SOURCE}/libnetfilter_acct-${LIBNETFILTER_ACT_VERSION}.tar.bz2" \
25 + "${LIBNETFILTER_ACT_ARTIFACT_SHA256}" "${cache_key}"
26
27 if [ "${CACHE_HIT:-0}" -eq 0 ]; then
28 run ./configure \
@@ -33,8 +35,7 @@ fi
35
36 run make install
37
36 -store_cache libnetfilter_acct "${NETDATA_MAKESELF_PATH}/tmp/libnetfilter_acct-${LIBNETFILTER_ACT_VERSION}"
37 -
38 +store_cache "${cache_key}" "${build_dir}"
39
40 # shellcheck disable=SC2015
41 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/20-libunwind.install.sh
+4 -18
@@ -19,24 +19,10 @@ export CXXFLAGS="${CFLAGS}"
19 export LDFLAGS="-static -L/libucontext-static/usr/lib/ -lucontext"
20 export PKG_CONFIG="pkg-config --static"
21
22 -if [ -d "${NETDATA_MAKESELF_PATH}/tmp/libunwind" ]; then
23 - rm -rf "${NETDATA_MAKESELF_PATH}/tmp/libunwind"
24 -fi
25 -
26 -cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/libunwind"
27 -
28 -if [ -d "${cache}" ]; then
29 - echo "Found cached copy of build directory for libunwind, using it."
30 - cp -a "${cache}/libunwind" "${NETDATA_MAKESELF_PATH}/tmp/"
31 - CACHE_HIT=1
32 -else
33 - echo "No cached copy of build directory for libunwind found, fetching sources instead."
34 - run git clone "${LIBUNWIND_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/libunwind"
35 - cd "${NETDATA_MAKESELF_PATH}/tmp/libunwind" && run git checkout "${LIBUNWIND_VERSION}"
36 - CACHE_HIT=0
37 -fi
22 +cache_key="libunwind"
23 +build_dir="libunwind-${LIBUNWIND_VERSION}"
24
39 -cd "${NETDATA_MAKESELF_PATH}/tmp/libunwind" || exit 1
25 +fetch_git "${build_dir}" "${LIBUNWIND_SOURCE}" "${LIBUNWIND_VERSION}" "${cache_key}" fetch-via-checkout
26
27 if [ "${CACHE_HIT:-0}" -eq 0 ]; then
28 run autoreconf -ivf
@@ -56,7 +42,7 @@ fi
42
43 run make -j "$(nproc)" install
44
59 -store_cache libunwind "${NETDATA_MAKESELF_PATH}/tmp/libunwind"
45 +store_cache "${cache_key}" "${build_dir}"
46
47 # shellcheck disable=SC2015
48 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/30-curl.install.sh renamed
+5 -18
@@ -7,25 +7,12 @@
7 . "$(dirname "${0}")/../bundled-packages.version"
8
9 # shellcheck disable=SC2015
10 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building cURL" || true
10 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building curl" || true
11
12 -if [ -d "${NETDATA_MAKESELF_PATH}/tmp/curl" ]; then
13 - rm -rf "${NETDATA_MAKESELF_PATH}/tmp/curl"
14 -fi
15 -
16 -cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/curl"
17 -
18 -if [ -d "${cache}" ]; then
19 - echo "Found cached copy of build directory for curl, using it."
20 - cp -a "${cache}/curl" "${NETDATA_MAKESELF_PATH}/tmp/"
21 - CACHE_HIT=1
22 -else
23 - echo "No cached copy of build directory for curl found, fetching sources instead."
24 - run git clone --branch "${CURL_VERSION}" --single-branch --depth 1 "${CURL_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/curl"
25 - CACHE_HIT=0
26 -fi
12 +cache_key="curl"
13 +build_dir="${CURL_VERSION}"
14
28 -cd "${NETDATA_MAKESELF_PATH}/tmp/curl" || exit 1
15 +fetch_git "${build_dir}" "${CURL_SOURCE}" "${CURL_VERSION}" "${cache_key}"
16
17 export CFLAGS="${TUNING_FLAGS} -I/openssl-static/include -pipe"
18 export CXXFLAGS="${CFLAGS}"
@@ -70,7 +57,7 @@ fi
57
58 run make install
59
73 -store_cache curl "${NETDATA_MAKESELF_PATH}/tmp/curl"
60 +store_cache "${cache_key}" "${build_dir}"
61
62 cp /curl-local/bin/curl "${NETDATA_INSTALL_PATH}"/bin/curl
63 if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then
packaging/makeself/jobs/40-bash.install.sh renamed
+7 -4
@@ -7,10 +7,13 @@
7 . "$(dirname "${0}")/../bundled-packages.version"
8
9 # shellcheck disable=SC2015
10 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::building bash" || true
10 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building bash" || true
11
12 -fetch "bash-${BASH_VERSION}" "${BASH_ARTIFACT_SOURCE}/bash-${BASH_VERSION}.tar.gz" \
13 - "${BASH_ARTIFACT_SHA256}" bash
12 +cache_key="bash"
13 +build_dir="bash-${BASH_VERSION}"
14 +
15 +fetch "${build_dir}" "${BASH_ARTIFACT_SOURCE}/bash-${BASH_VERSION}.tar.gz" \
16 + "${BASH_ARTIFACT_SHA256}" "${cache_key}"
17
18 export CFLAGS="${TUNING_FLAGS} -pipe"
19 export CXXFLAGS="${CFLAGS}"
@@ -40,7 +43,7 @@ fi
43
44 run make install
45
43 -store_cache bash "${NETDATA_MAKESELF_PATH}/tmp/bash-${BASH_VERSION}"
46 +store_cache "${cache_key}" "${build_dir}"
47
48 if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then
49 run strip "${NETDATA_INSTALL_PATH}"/bin/bash
packaging/makeself/jobs/50-ioping.install.sh renamed
+6 -3
@@ -9,8 +9,11 @@
9 # shellcheck disable=SC2015
10 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building ioping" || true
11
12 -fetch "ioping-${IOPING_VERSION}" "${IOPING_SOURCE}/archive/refs/tags/v${IOPING_VERSION}.tar.gz" \
13 - "${IOPING_ARTIFACT_SHA256}" ioping
12 +cache_key="ioping"
13 +build_dir="ioping-${IOPING_VERSION}"
14 +
15 +fetch "${build_dir}" "${IOPING_SOURCE}/archive/refs/tags/v${IOPING_VERSION}.tar.gz" \
16 + "${IOPING_ARTIFACT_SHA256}" "${cache_key}"
17
18 export CFLAGS="${TUNING_FLAGS} -static -pipe"
19 export CXXFLAGS="${CFLAGS}"
@@ -23,7 +26,7 @@ fi
26 run mkdir -p "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/
27 run install -o root -g root -m 4750 ioping "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/
28
26 -store_cache ioping "${NETDATA_MAKESELF_PATH}/tmp/ioping-${IOPING_VERSION}"
29 +store_cache "${cache_key}" "${build_dir}"
30
31 if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then
32 run strip "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/ioping
packaging/makeself/jobs/70-netdata-git.install.sh
+2 -25
@@ -23,9 +23,8 @@ export EBPF_LIBC="static"
23 export PKG_CONFIG="pkg-config --static"
24 export PKG_CONFIG_PATH="/libunwind-static/lib/pkgconfig:/openssl-static/lib64/pkgconfig:/libnetfilter-acct-static/lib/pkgconfig:/usr/lib/pkgconfig:/curl-local/lib/pkgconfig"
25
26 -# Set correct CMake flags for building against non-System OpenSSL
27 -# See: https://github.com/warmcat/libwebsockets/blob/master/READMEs/README.build.md
28 -export CMAKE_FLAGS="-DOPENSSL_ROOT_DIR=/openssl-static -DOPENSSL_LIBRARIES=/openssl-static/lib64 -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static -DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include -DLWS_OPENSSL_LIBRARIES=/openssl-static/lib64/libssl.a;/openssl-static/lib64/libcrypto.a"
26 +NETDATA_BUILD_DIR="$(build_path netdata)"
27 +export NETDATA_BUILD_DIR
28
29 case "${BUILDARCH}" in
30 armv7l|armv6l) export NETDATA_CMAKE_OPTIONS="-DENABLE_LIBBACKTRACE=OFF -DENABLE_LIBUNWIND=ON" ;;
@@ -42,25 +41,3 @@ run ./netdata-installer.sh \
41 --one-time-build \
42 --enable-lto \
43 ${EXTRA_INSTALL_FLAGS:+${EXTRA_INSTALL_FLAGS}} \
45 -
46 -# shellcheck disable=SC2015
47 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Finishing netdata install" || true
48 -
49 -# Properly mark the install type
50 -cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF
51 - INSTALL_TYPE='manual-static'
52 - PREBUILT_ARCH='${BUILDARCH}'
53 - EOF
54 -
55 -# Remove the netdata.conf file from the tree. It has hard-coded sensible defaults builtin.
56 -run rm -f "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
57 -
58 -# Ensure the netdata binary is in fact statically linked
59 -if run readelf -l "${NETDATA_INSTALL_PATH}"/bin/netdata | grep 'INTERP'; then
60 - printf >&2 "Ooops. %s is not a statically linked binary!\n" "${NETDATA_INSTALL_PATH}"/bin/netdata
61 - ldd "${NETDATA_INSTALL_PATH}"/bin/netdata
62 - exit 1
63 -fi
64 -
65 -# shellcheck disable=SC2015
66 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/71-install-type.sh new
+17
@@ -0,0 +1,17 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=./packaging/makeself/functions.sh
5 +. "${NETDATA_MAKESELF_PATH}"/functions.sh "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Setting correct install type information in install path" || true
9 +
10 +# Properly mark the install type
11 +cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF
12 + INSTALL_TYPE='manual-static'
13 + PREBUILT_ARCH='${BUILDARCH}'
14 + EOF
15 +
16 +# shellcheck disable=SC2015
17 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/72-conf-fixup.sh new
+14
@@ -0,0 +1,14 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=./packaging/makeself/functions.sh
5 +. "${NETDATA_MAKESELF_PATH}"/functions.sh "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Fixing up agent configuration files" || true
9 +
10 +# Remove the netdata.conf file from the tree. It has hard-coded sensible defaults builtin.
11 +run rm -f "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
12 +
13 +# shellcheck disable=SC2015
14 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/80-netdata-static-check.sh new
+18
@@ -0,0 +1,18 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=./packaging/makeself/functions.sh
5 +. "${NETDATA_MAKESELF_PATH}"/functions.sh "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Confirming that Netdata is statically linked" || true
9 +
10 +# Ensure the netdata binary is in fact statically linked
11 +if run readelf -l "${NETDATA_INSTALL_PATH}/bin/netdata" | grep 'INTERP'; then
12 + printf >&2 "Ooops. %s is not a statically linked binary!\n" "${NETDATA_INSTALL_PATH}/bin/netdata"
13 + ldd "${NETDATA_INSTALL_PATH}/bin/netdata"
14 + exit 1
15 +fi
16 +
17 +# shellcheck disable=SC2015
18 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/81-netdata-runtime-check.sh renamed
+6
@@ -4,6 +4,9 @@
4 # shellcheck source=./packaging/makeself/functions.sh
5 . "${NETDATA_MAKESELF_PATH}"/functions.sh "${@}" || exit 1
6
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Performing basic runtime checks" || true
9 +
10 dump_log() {
11 cat ./netdata.log
12 }
@@ -22,3 +25,6 @@ fi
25 "${NETDATA_SOURCE_PATH}/packaging/runtime-check.sh" || exit 1
26
27 trap - EXIT
28 +
29 +# shellcheck disable=SC2015
30 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/90-prepare-archive-source.sh new
+62
@@ -0,0 +1,62 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=packaging/makeself/functions.sh
5 +. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Preparing installation paths for archive creation" || true
9 +
10 +run cd "${NETDATA_SOURCE_PATH}" || exit 1
11 +
12 +# -----------------------------------------------------------------------------
13 +# copy the files needed by makeself installation
14 +
15 +run mkdir -p "${NETDATA_INSTALL_PATH}/system"
16 +
17 +run cp \
18 + packaging/makeself/post-installer.sh \
19 + packaging/makeself/install-or-update.sh \
20 + packaging/installer/functions.sh \
21 + "${NETDATA_INSTALL_PATH}/system/"
22 +
23 +# -----------------------------------------------------------------------------
24 +# create a wrapper to start our netdata with a modified path
25 +
26 +run mkdir -p "${NETDATA_INSTALL_PATH}/bin/srv"
27 +
28 +run mv "${NETDATA_INSTALL_PATH}/bin/netdata" \
29 + "${NETDATA_INSTALL_PATH}/bin/srv/netdata" || exit 1
30 +
31 +cat > "${NETDATA_INSTALL_PATH}/bin/netdata" << EOF
32 +#!${NETDATA_INSTALL_PATH}/bin/bash
33 +export NETDATA_BASH_LOADABLES="DISABLE"
34 +export PATH="${NETDATA_INSTALL_PATH}/bin:\${PATH}"
35 +exec "${NETDATA_INSTALL_PATH}/bin/srv/netdata" "\${@}"
36 +EOF
37 +run chmod 755 "${NETDATA_INSTALL_PATH}/bin/netdata"
38 +
39 +# -----------------------------------------------------------------------------
40 +# the claiming script must be in the same directory as the netdata binary for web-based claiming to work
41 +
42 +run ln -s "${NETDATA_INSTALL_PATH}/bin/netdata-claim.sh" \
43 + "${NETDATA_INSTALL_PATH}/bin/srv/netdata-claim.sh" || exit 1
44 +
45 +# -----------------------------------------------------------------------------
46 +# remove the links to allow untaring the archive
47 +
48 +run rm "${NETDATA_INSTALL_PATH}/sbin" \
49 + "${NETDATA_INSTALL_PATH}/usr/bin" \
50 + "${NETDATA_INSTALL_PATH}/usr/sbin" \
51 + "${NETDATA_INSTALL_PATH}/usr/local"
52 +
53 +# -----------------------------------------------------------------------------
54 +# ensure required directories actually exist
55 +
56 +for dir in var/lib/netdata var/cache/netdata var/log/netdata ; do
57 + run mkdir -p "${NETDATA_INSTALL_PATH}/${dir}"
58 + run touch "${NETDATA_INSTALL_PATH}/${dir}/.keep"
59 +done
60 +
61 +# shellcheck disable=SC2015
62 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/91-copy-ca-certificates.sh new
+13
@@ -0,0 +1,13 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=packaging/makeself/functions.sh
5 +. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Copying CA certificates from build environment" || true
9 +
10 +run cp -a /etc/ssl "${NETDATA_INSTALL_PATH}/share/ssl"
11 +
12 +# shellcheck disable=SC2015
13 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/98-create-archive.sh new
+46
@@ -0,0 +1,46 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=packaging/makeself/functions.sh
5 +. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building self-extracting archive" || true
9 +
10 +run cd "${NETDATA_SOURCE_PATH}" || exit 1
11 +
12 +# -----------------------------------------------------------------------------
13 +# find the netdata version
14 +
15 +VERSION="$("${NETDATA_INSTALL_PARENT}/netdata/bin/netdata" -v | cut -f 2 -d ' ')"
16 +[ -z "${VERSION}" ] && VERSION="$(cat "${NETDATA_SOURCE_PATH}/packaging/version")"
17 +
18 +if [ "${VERSION}" == "" ]; then
19 + echo >&2 "Cannot find version number. Create makeself executable from source code with git tree structure."
20 + exit 1
21 +fi
22 +
23 +# -----------------------------------------------------------------------------
24 +# create the makeself archive
25 +
26 +run sed "s|NETDATA_VERSION|${VERSION}|g" < "${NETDATA_MAKESELF_PATH}/makeself.lsm" > "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
27 +
28 +run "${NETDATA_MAKESELF_PATH}/makeself.sh" \
29 + --gzip \
30 + --complevel 9 \
31 + --notemp \
32 + --needroot \
33 + --target "${NETDATA_INSTALL_PATH}" \
34 + --header "${NETDATA_MAKESELF_PATH}/makeself-header.sh" \
35 + --lsm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp" \
36 + --license "${NETDATA_MAKESELF_PATH}/makeself-license.txt" \
37 + --help-header "${NETDATA_MAKESELF_PATH}/makeself-help-header.txt" \
38 + "${NETDATA_INSTALL_PATH}" \
39 + "${NETDATA_INSTALL_PATH}.gz.run" \
40 + "Netdata, X-Ray Vision for your infrastructure" \
41 + ./system/post-installer.sh
42 +
43 +run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
44 +
45 +# shellcheck disable=SC2015
46 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/99-copy-archives.sh new
+35
@@ -0,0 +1,35 @@
1 +#!/usr/bin/env bash
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# shellcheck source=packaging/makeself/functions.sh
5 +. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6 +
7 +# shellcheck disable=SC2015
8 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Copying archive files" || true
9 +
10 +VERSION="$("${NETDATA_INSTALL_PARENT}/netdata/bin/netdata" -v | cut -f 2 -d ' ')"
11 +[ -z "${VERSION}" ] && VERSION="$(cat "${NETDATA_SOURCE_PATH}/packaging/version")"
12 +
13 +if [ "${VERSION}" == "" ]; then
14 + echo >&2 "Cannot find version number. Create makeself executable from source code with git tree structure."
15 + exit 1
16 +fi
17 +
18 +FILE="netdata-${BUILDARCH}-${VERSION}.gz.run"
19 +
20 +run mv "${NETDATA_INSTALL_PATH}.gz.run" "${NETDATA_SOURCE_PATH}/artifacts/${FILE}"
21 +
22 +[ -f "${NETDATA_SOURCE_PATH}/artifacts/netdata-${BUILDARCH}-latest.gz.run" ] && rm "${NETDATA_SOURCE_PATH}/artifacts/netdata-${BUILDARCH}-latest.gz.run"
23 +run cp "${NETDATA_SOURCE_PATH}/artifacts/${FILE}" "${NETDATA_SOURCE_PATH}/artifacts/netdata-${BUILDARCH}-latest.gz.run"
24 +
25 +if [ "${BUILDARCH}" = "x86_64" ]; then
26 + [ -f "${NETDATA_SOURCE_PATH}/artifacts/netdata-latest.gz.run" ] && rm "${NETDATA_SOURCE_PATH}/artifacts/netdata-latest.gz.run"
27 + run cp "${NETDATA_SOURCE_PATH}/artifacts/${FILE}" "${NETDATA_SOURCE_PATH}/artifacts/netdata-latest.gz.run"
28 + [ -f "${NETDATA_SOURCE_PATH}/artifacts/netdata-${VERSION}.gz.run" ] && rm "${NETDATA_SOURCE_PATH}/artifacts/netdata-${VERSION}.gz.run"
29 + run cp "${NETDATA_SOURCE_PATH}/artifacts/${FILE}" "${NETDATA_SOURCE_PATH}/artifacts/netdata-${VERSION}.gz.run"
30 +fi
31 +
32 +chown -R "$(stat -c '%u:%g' "${NETDATA_SOURCE_PATH}")" "${NETDATA_SOURCE_PATH}/artifacts"
33 +
34 +# shellcheck disable=SC2015
35 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/99-makeself.install.sh deleted
-122
@@ -1,122 +0,0 @@
1 -#!/usr/bin/env bash
2 -# SPDX-License-Identifier: GPL-3.0-or-later
3 -
4 -set -x
5 -
6 -# shellcheck source=packaging/makeself/functions.sh
7 -. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
8 -
9 -# shellcheck disable=SC2015
10 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building self-extracting archive" || true
11 -
12 -run cd "${NETDATA_SOURCE_PATH}" || exit 1
13 -
14 -# -----------------------------------------------------------------------------
15 -# find the netdata version
16 -
17 -VERSION="$("${NETDATA_INSTALL_PARENT}/netdata/bin/netdata" -v | cut -f 2 -d ' ')"
18 -[ -z "${VERSION}" ] && VERSION="$(cat "${NETDATA_SOURCE_PATH}/packaging/version")"
19 -
20 -if [ "${VERSION}" == "" ]; then
21 - echo >&2 "Cannot find version number. Create makeself executable from source code with git tree structure."
22 - exit 1
23 -fi
24 -
25 -# -----------------------------------------------------------------------------
26 -# copy the files needed by makeself installation
27 -
28 -run mkdir -p "${NETDATA_INSTALL_PATH}/system"
29 -
30 -run cp \
31 - packaging/makeself/post-installer.sh \
32 - packaging/makeself/install-or-update.sh \
33 - packaging/installer/functions.sh \
34 - "${NETDATA_INSTALL_PATH}/system/"
35 -
36 -# -----------------------------------------------------------------------------
37 -# create a wrapper to start our netdata with a modified path
38 -
39 -run mkdir -p "${NETDATA_INSTALL_PATH}/bin/srv"
40 -
41 -run mv "${NETDATA_INSTALL_PATH}/bin/netdata" \
42 - "${NETDATA_INSTALL_PATH}/bin/srv/netdata" || exit 1
43 -
44 -cat > "${NETDATA_INSTALL_PATH}/bin/netdata" << EOF
45 -#!${NETDATA_INSTALL_PATH}/bin/bash
46 -export NETDATA_BASH_LOADABLES="DISABLE"
47 -export PATH="${NETDATA_INSTALL_PATH}/bin:\${PATH}"
48 -exec "${NETDATA_INSTALL_PATH}/bin/srv/netdata" "\${@}"
49 -EOF
50 -run chmod 755 "${NETDATA_INSTALL_PATH}/bin/netdata"
51 -
52 -# -----------------------------------------------------------------------------
53 -# the claiming script must be in the same directory as the netdata binary for web-based claiming to work
54 -
55 -run ln -s "${NETDATA_INSTALL_PATH}/bin/netdata-claim.sh" \
56 - "${NETDATA_INSTALL_PATH}/bin/srv/netdata-claim.sh" || exit 1
57 -
58 -# -----------------------------------------------------------------------------
59 -# copy the SSL/TLS configuration and certificates from the build system
60 -
61 -run cp -a /etc/ssl "${NETDATA_INSTALL_PATH}/share/ssl"
62 -
63 -# -----------------------------------------------------------------------------
64 -# remove the links to allow untaring the archive
65 -
66 -run rm "${NETDATA_INSTALL_PATH}/sbin" \
67 - "${NETDATA_INSTALL_PATH}/usr/bin" \
68 - "${NETDATA_INSTALL_PATH}/usr/sbin" \
69 - "${NETDATA_INSTALL_PATH}/usr/local"
70 -
71 -# -----------------------------------------------------------------------------
72 -# ensure required directories actually exist
73 -
74 -for dir in var/lib/netdata var/cache/netdata var/log/netdata ; do
75 - run mkdir -p "${NETDATA_INSTALL_PATH}/${dir}"
76 - run touch "${NETDATA_INSTALL_PATH}/${dir}/.keep"
77 -done
78 -
79 -# -----------------------------------------------------------------------------
80 -# create the makeself archive
81 -
82 -run sed "s|NETDATA_VERSION|${VERSION}|g" < "${NETDATA_MAKESELF_PATH}/makeself.lsm" > "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
83 -
84 -run "${NETDATA_MAKESELF_PATH}/makeself.sh" \
85 - --gzip \
86 - --complevel 9 \
87 - --notemp \
88 - --needroot \
89 - --target "${NETDATA_INSTALL_PATH}" \
90 - --header "${NETDATA_MAKESELF_PATH}/makeself-header.sh" \
91 - --lsm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp" \
92 - --license "${NETDATA_MAKESELF_PATH}/makeself-license.txt" \
93 - --help-header "${NETDATA_MAKESELF_PATH}/makeself-help-header.txt" \
94 - "${NETDATA_INSTALL_PATH}" \
95 - "${NETDATA_INSTALL_PATH}.gz.run" \
96 - "Netdata, X-Ray Vision for your infrastructure" \
97 - ./system/post-installer.sh
98 -
99 -run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
100 -
101 -# -----------------------------------------------------------------------------
102 -# copy it to the netdata build dir
103 -
104 -FILE="netdata-${BUILDARCH}-${VERSION}.gz.run"
105 -
106 -run mkdir -p artifacts
107 -run mv "${NETDATA_INSTALL_PATH}.gz.run" "artifacts/${FILE}"
108 -
109 -[ -f "netdata-${BUILDARCH}-latest.gz.run" ] && rm "netdata-${BUILDARCH}-latest.gz.run"
110 -run cp "artifacts/${FILE}" "netdata-${BUILDARCH}-latest.gz.run"
111 -
112 -if [ "${BUILDARCH}" = "x86_64" ]; then
113 - [ -f "netdata-latest.gz.run" ] && rm "netdata-latest.gz.run"
114 - run cp "artifacts/${FILE}" "netdata-latest.gz.run"
115 - [ -f "artifacts/netdata-${VERSION}.gz.run" ] && rm "netdata-${VERSION}.gz.run"
116 - run cp "artifacts/${FILE}" "artifacts/netdata-${VERSION}.gz.run"
117 -fi
118 -
119 -# shellcheck disable=SC2015
120 -[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
121 -
122 -echo >&2 "Self-extracting installer moved to 'artifacts/${FILE}'"
packaging/makeself/run-all-jobs.sh
+1 -1
@@ -43,7 +43,7 @@ cd "${NETDATA_MAKESELF_PATH}" || exit 1
43 # shellcheck source=packaging/makeself/functions.sh
44 . ./functions.sh "${@}" || exit 1
45
46 -for x in jobs/*.install.sh; do
46 +for x in jobs/*.sh; do
47 progress "running ${x}"
48 "${x}" "${NETDATA_INSTALL_PATH}"
49 done
packaging/runtime-check.sh
+3 -3
@@ -38,11 +38,11 @@ case $? in
38 2) exit 3 ;;
39 esac
40
41 -curl -sfS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
41 +curl -sfS http://127.0.0.1:19999/api/v1/info > /tmp/response || exit 1
42
43 -cat ./response
43 +cat /tmp/response
44
45 -jq '.version' ./response || exit 1
45 +jq '.version' /tmp/response || exit 1
46
47 curl -sfS http://127.0.0.1:19999/index.html || exit 1
48 curl -sfS http://127.0.0.1:19999/v0/index.html || exit 1