Embed build architecture in static build archive names. (#11463)
* Embed build architecture in static build archive names. This is required for proper support for static installs in the new kickstart script. The associated changes will also simplify adding static builds for other architectures in the future. * Update CI to use new static build changes properly. * Fix typos. * Fix link created by static build process. * Fix build environment setup.
Austin S. Hemmelgarn committed
Sep 6, 2021 at 09:10 UTC
214cb3a41e86bc11c825b9ed8ff2513d4e69c72d
6 files changed
+101
-57
.github/scripts/build-static.sh
renamed
+5
-4
@@ -7,6 +7,7 @@ set -e
7
# shellcheck source=.github/scripts/functions.sh
8
. "$(dirname "$0")/functions.sh"
9
10
+BUILDARCH="${1}"
11
NAME="${NAME:-netdata}"
12
VERSION="${VERSION:-"$(git describe)"}"
13
BASENAME="$NAME-$VERSION"
@@ -18,10 +19,10 @@ prepare_build() {
19
) >&2
20
}
21
21
-build_static_x86_64() {
22
- progress "Building static x86_64"
22
+build_static() {
23
+ progress "Building static ${BUILDARCH}"
24
(
24
- USER="" ./packaging/makeself/build-x86_64-static.sh
25
+ USER="" ./packaging/makeself/build-static.sh "${BUILDARCH}"
26
) >&2
27
}
28
@@ -36,7 +37,7 @@ prepare_assets() {
37
) >&2
38
}
39
39
-steps="prepare_build build_static_x86_64"
40
+steps="prepare_build build_static"
41
steps="$steps prepare_assets"
42
43
_main() {
.github/workflows/build-and-install.yml
+7
-5
@@ -9,18 +9,20 @@ env:
9
DO_NOT_TRACK: 1
10
jobs:
11
static-build:
12
- name: Build (x86_64)
12
+ name: Static Build
13
runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ arch:
17
+ - 'x86_64'
18
steps:
19
- name: Git clone repository
20
uses: actions/checkout@v2
21
with:
22
+ fetch-depth: 0
23
submodules: recursive
19
- - run: |
20
- git fetch --prune --unshallow --tags
24
- name: Build
22
- run: |
23
- .github/scripts/build-static-x86_64.sh
25
+ run: .github/scripts/build-static.sh ${{ matrix.arch }}
26
source-build:
27
name: Build & Install
28
strategy:
.travis/create_artifacts.sh
+12
-2
@@ -67,8 +67,12 @@ make dist
67
mv "${BASENAME}.tar.gz" artifacts/
68
69
echo "--- Create self-extractor ---"
70
-command -v git > /dev/null && [ -d .git ] && git clean -d -f
71
-./packaging/makeself/build-x86_64-static.sh
70
+sxarches="x86_64"
71
+for arch in ${sxarches}; do
72
+ git clean -d -f
73
+ rm -rf packating/makeself/tmp
74
+ ./packaging/makeself/build-static.sh ${arch}
75
+done
76
77
# Needed for GCS
78
echo "--- Copy artifacts to separate directory ---"
@@ -76,7 +80,13 @@ echo "--- Copy artifacts to separate directory ---"
80
cp packaging/version artifacts/latest-version.txt
81
cd artifacts
82
ln -s "${BASENAME}.tar.gz" netdata-latest.tar.gz
83
+
84
+for arch in ${sxarches}; do
85
+ ln -s "netdata-${arch}-$(git describe).gz.run" netdata-${arch}-latest.gz.run
86
+done
87
+
88
ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
89
+
90
sha256sum -b ./* > "sha256sums.txt"
91
echo "checksums:"
92
cat sha256sums.txt
packaging/makeself/build-static.sh
new
+65
@@ -0,0 +1,65 @@
1
+#!/usr/bin/env bash
2
+
3
+# SPDX-License-Identifier: GPL-3.0-or-later
4
+
5
+# shellcheck source=./packaging/installer/functions.sh
6
+. "$(dirname "$0")"/../installer/functions.sh || exit 1
7
+
8
+BUILDARCH="${1}"
9
+
10
+set -e
11
+
12
+case ${BUILDARCH} in
13
+ x86_64) platform=linux/amd64 ;;
14
+ arm7) platform=linux/arm/v7 ;;
15
+ aarch64) platform=linux/arm64/v8 ;;
16
+ *)
17
+ echo "Unknown target architecture '${BUILDARCH}'."
18
+ exit 1
19
+ ;;
20
+esac
21
+
22
+DOCKER_CONTAINER_NAME="netdata-package-${BUILDARCH}-static-alpine312"
23
+
24
+if [ "${BUILDARCH}" != "x86_64" ]; then
25
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes || exit 1
26
+fi
27
+
28
+if ! docker inspect "${DOCKER_CONTAINER_NAME}" > /dev/null 2>&1; then
29
+ # To run interactively:
30
+ # docker run -it netdata-package-x86_64-static /bin/sh
31
+ # (add -v host-dir:guest-dir:rw arguments to mount volumes)
32
+ #
33
+ # To remove images in order to re-create:
34
+ # docker rm -v $(sudo docker ps -a -q -f status=exited)
35
+ # docker rmi netdata-package-x86_64-static
36
+ #
37
+ # This command maps the current directory to
38
+ # /usr/src/netdata.git
39
+ # inside the container and runs the script install-alpine-packages.sh
40
+ # (also inside the container)
41
+ #
42
+ run docker pull alpine:3.12
43
+
44
+ run docker run --platform=${platform} -v "$(pwd)":/usr/src/netdata.git:rw alpine:3.12 \
45
+ /bin/sh /usr/src/netdata.git/packaging/makeself/install-alpine-packages.sh
46
+
47
+ # save the changes made permanently
48
+ id=$(docker ps -l -q)
49
+ run docker commit "${id}" "${DOCKER_CONTAINER_NAME}"
50
+fi
51
+
52
+# Run the build script inside the container
53
+if [ -t 1 ]; then
54
+ run docker run -e BUILDARCH="${BUILDARCH}" -a stdin -a stdout -a stderr -i -t -v "$(pwd)":/usr/src/netdata.git:rw \
55
+ "${DOCKER_CONTAINER_NAME}" \
56
+ /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
57
+else
58
+ run docker run -e BUILDARCH="${BUILDARCH}" -v "$(pwd)":/usr/src/netdata.git:rw \
59
+ "${DOCKER_CONTAINER_NAME}" \
60
+ /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
61
+fi
62
+
63
+if [ "${USER}" ]; then
64
+ sudo chown -R "${USER}" .
65
+fi
packaging/makeself/build-x86_64-static.sh
+2
-43
@@ -2,47 +2,6 @@
2
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
5
-# shellcheck source=./packaging/installer/functions.sh
6
-. "$(dirname "$0")"/../installer/functions.sh || exit 1
5
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
6
8
-set -e
9
-
10
-DOCKER_CONTAINER_NAME="netdata-package-x86_64-static-alpine312"
11
-
12
-if ! docker inspect "${DOCKER_CONTAINER_NAME}" > /dev/null 2>&1; then
13
- # To run interactively:
14
- # docker run -it netdata-package-x86_64-static /bin/sh
15
- # (add -v host-dir:guest-dir:rw arguments to mount volumes)
16
- #
17
- # To remove images in order to re-create:
18
- # docker rm -v $(sudo docker ps -a -q -f status=exited)
19
- # docker rmi netdata-package-x86_64-static
20
- #
21
- # This command maps the current directory to
22
- # /usr/src/netdata.git
23
- # inside the container and runs the script install-alpine-packages.sh
24
- # (also inside the container)
25
- #
26
- run docker run -v "$(pwd)":/usr/src/netdata.git:rw alpine:3.12 \
27
- /bin/sh /usr/src/netdata.git/packaging/makeself/install-alpine-packages.sh
28
-
29
- # save the changes made permanently
30
- id=$(docker ps -l -q)
31
- run docker commit "${id}" "${DOCKER_CONTAINER_NAME}"
32
-fi
33
-
34
-# Run the build script inside the container
35
-if [ -t 1 ]; then
36
- run docker run -a stdin -a stdout -a stderr -i -t -v \
37
- "$(pwd)":/usr/src/netdata.git:rw \
38
- "${DOCKER_CONTAINER_NAME}" \
39
- /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
40
-else
41
- run docker run -v "$(pwd)":/usr/src/netdata.git:rw \
42
- "${DOCKER_CONTAINER_NAME}" \
43
- /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
44
-fi
45
-
46
-if [ "${USER}" ]; then
47
- sudo chown -R "${USER}" .
48
-fi
7
+"${SCRIPT_DIR}/build-static.sh" x86_64
packaging/makeself/jobs/99-makeself.install.sh
+10
-3
@@ -90,12 +90,19 @@ run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
90
# -----------------------------------------------------------------------------
91
# copy it to the netdata build dir
92
93
-FILE="netdata-${VERSION}.gz.run"
93
+FILE="netdata-${BUILDARCH}-${VERSION}.gz.run"
94
95
run mkdir -p artifacts
96
run mv "${NETDATA_INSTALL_PATH}.gz.run" "artifacts/${FILE}"
97
98
-[ -f netdata-latest.gz.run ] && rm netdata-latest.gz.run
99
-run ln -s "artifacts/${FILE}" netdata-latest.gz.run
98
+[ -f "netdata-${BUILDARCH}-latest.gz.run" ] && rm "netdata-${BUILDARCH}-latest.gz.run"
99
+run ln -s "artifacts/${FILE}" "netdata-${BUILDARCH}-latest.gz.run"
100
+
101
+if [ "${BUILDARCH}" = "x86_64" ]; then
102
+ [ -f "netdata-latest.gz.run" ] && rm "netdata-latest.gz.run"
103
+ run ln -s "artifacts/${FILE}" "netdata-latest.gz.run"
104
+ [ -f "artifacts/netdata-${VERSION}.gz.run" ] && rm "netdata-${VERSION}.gz.run"
105
+ run ln -s "./${FILE}" "artifacts/netdata-${VERSION}.gz.run"
106
+fi
107
108
echo >&2 "Self-extracting installer moved to 'artifacts/${FILE}'"