Fixes static builds and nightlies (#7971)
* Fixed the shebang for building self-extracting static builds * Fixed shellcheck errors/warnings * Fix require_cmd() function too and redirect both stderr/stdout of command -v in conditional
James Mills committed
Feb 4, 2020 at 19:28 UTC
fffc2bc1253e029c5a7e644cec2723b975312d2d
2 files changed
+28
-28
packaging/installer/install-required-packages.sh
+1
-2
@@ -511,12 +511,11 @@ require_cmd() {
511
512
local wanted found
513
for wanted in "${@}"; do
514
- if command -v "${wanted}" 2> /dev/null; then
514
+ if command -v "${wanted}" > /dev/null 2>&1; then
515
found="$(command -v "$wanted" 2> /dev/null)"
516
fi
517
[ -n "${found}" ] && [ -x "${found}" ] && return 0
518
done
519
-
519
return 1
520
}
521
packaging/makeself/build-x86_64-static.sh
+27
-26
@@ -1,41 +1,42 @@
1
-#!/bin/sh
1
+#!/usr/bin/env bash
2
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
5
-. $(dirname "$0")/../installer/functions.sh || exit 1
5
+# shellcheck source=./packaging/installer/functions.sh
6
+. "$(dirname "$0")"/../installer/functions.sh || exit 1
7
8
set -e
9
10
DOCKER_CONTAINER_NAME="netdata-package-x86_64-static-alpine37"
11
11
-if ! docker inspect "${DOCKER_CONTAINER_NAME}" >/dev/null 2>&1; then
12
- # To run interactively:
13
- # docker run -it netdata-package-x86_64-static /bin/sh
14
- # (add -v host-dir:guest-dir:rw arguments to mount volumes)
15
- #
16
- # To remove images in order to re-create:
17
- # docker rm -v $(sudo docker ps -a -q -f status=exited)
18
- # docker rmi netdata-package-x86_64-static
19
- #
20
- # This command maps the current directory to
21
- # /usr/src/netdata.git
22
- # inside the container and runs the script install-alpine-packages.sh
23
- # (also inside the container)
24
- #
25
- run docker run -v $(pwd):/usr/src/netdata.git:rw alpine:3.7 \
26
- /bin/sh /usr/src/netdata.git/packaging/makeself/install-alpine-packages.sh
27
-
28
- # save the changes made permanently
29
- id=$(docker ps -l -q)
30
- run docker commit ${id} "${DOCKER_CONTAINER_NAME}"
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.7 \
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
run docker run -a stdin -a stdout -a stderr -i -t -v \
35
- $(pwd):/usr/src/netdata.git:rw \
36
- "${DOCKER_CONTAINER_NAME}" \
37
- /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
36
+ "$(pwd)":/usr/src/netdata.git:rw \
37
+ "${DOCKER_CONTAINER_NAME}" \
38
+ /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
39
40
if [ "${USER}" ]; then
40
- chown -R "${USER}" .
41
+ chown -R "${USER}" .
42
fi