diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2022-07-14 14:26:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-14 07:26:11 -0400 |
commit | bd5f778838ff6b4206509a19b967f7b6eb6b16c7 (patch) | |
tree | 3e6ec0b7a044fcdfc38528e0624ee9a204a41828 /packaging/makeself/build-static.sh | |
parent | 1cea4f77ee42ebcd979efbcab13094c7818a4f8b (diff) |
Add basic runtime checks to static build process. (#13339)
* Enable use of Podman for static builds.
This way those of us who have migrated away from Docker can still easily
test static builds.
* Add basic runtime testing to the static build process.
This will help catch basic runtime issues that would not show up just
from building the agent.
Diffstat (limited to 'packaging/makeself/build-static.sh')
-rwxr-xr-x | packaging/makeself/build-static.sh | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/packaging/makeself/build-static.sh b/packaging/makeself/build-static.sh index c7c5a4bcc7..f9f635c79a 100755 --- a/packaging/makeself/build-static.sh +++ b/packaging/makeself/build-static.sh @@ -15,30 +15,44 @@ 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" 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 + ${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 - img_platform="$(docker image inspect netdata/static-builder --format '{{.Os}}/{{.Architecture}}/{{.Variant}}')" - if [ "${img_platform%'/'}" != "${platform}" ]; then - docker image rm "${DOCKER_IMAGE_NAME}" || exit 1 +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}" +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 \ + 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 \ + 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 |