diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /packaging/makeself/build-static.sh | |
parent | Initial commit. (diff) | |
download | netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | packaging/makeself/build-static.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/packaging/makeself/build-static.sh b/packaging/makeself/build-static.sh new file mode 100755 index 00000000..0c46c12a --- /dev/null +++ b/packaging/makeself/build-static.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck source=./packaging/installer/functions.sh +. "$(dirname "$0")"/../installer/functions.sh || exit 1 + +BUILDARCH="${1}" + +set -e + +platform="$("$(dirname "${0}")/uname2platform.sh" "${BUILDARCH}")" + +if [ -z "${platform}" ]; then + exit 1 +fi + +if command -v docker > /dev/null 2>&1; then + docker="docker" +elif command -v podman > /dev/null 2>&1; then + docker="podman" +else + echo "Could not find a usable OCI runtime, need either Docker or Podman." + exit 1 +fi + +DOCKER_IMAGE_NAME="netdata/static-builder:v1" + +if [ "${BUILDARCH}" != "$(uname -m)" ] && [ "$(uname -m)" = 'x86_64' ] && [ -z "${SKIP_EMULATION}" ]; then + ${docker} run --rm --privileged multiarch/qemu-user-static --reset -p yes || exit 1 +fi + +if ${docker} inspect "${DOCKER_IMAGE_NAME}" > /dev/null 2>&1; then + if ${docker} image inspect "${DOCKER_IMAGE_NAME}" | grep -q 'Variant'; then + img_platform="$(${docker} image inspect "${DOCKER_IMAGE_NAME}" --format '{{.Os}}/{{.Architecture}}/{{.Variant}}')" + else + img_platform="$(${docker} image inspect "${DOCKER_IMAGE_NAME}" --format '{{.Os}}/{{.Architecture}}')" + fi + + if [ "${img_platform}" != "${platform}" ]; then + ${docker} image rm "${DOCKER_IMAGE_NAME}" || exit 1 + fi +fi + +if ! ${docker} inspect "${DOCKER_IMAGE_NAME}" > /dev/null 2>&1; then + ${docker} pull --platform "${platform}" "${DOCKER_IMAGE_NAME}" +fi + +# Run the build script inside the container +if [ -t 1 ]; then + run ${docker} run --rm -e BUILDARCH="${BUILDARCH}" -a stdin -a stdout -a stderr -i -t -v "$(pwd)":/netdata:rw \ + "${DOCKER_IMAGE_NAME}" \ + /bin/sh /netdata/packaging/makeself/build.sh "${@}" +else + run ${docker} run --rm -e BUILDARCH="${BUILDARCH}" -v "$(pwd)":/netdata:rw \ + -e GITHUB_ACTIONS="${GITHUB_ACTIONS}" "${DOCKER_IMAGE_NAME}" \ + /bin/sh /netdata/packaging/makeself/build.sh "${@}" +fi |