@cryptotaxi247 / netdata-1 / commits / 428113b20

fix arch detection on i386 (native packages) (#15218)

Ilya Mashchenko committed Jun 20, 2023 at 19:48 UTC 428113b20203ce5fb891061db7105dd55e09a6b4
2 files changed +79 -82
contrib/debian/install_go.sh
+76 -80
@@ -7,92 +7,88 @@ LIBEXEC_DIR="$3"
7 # ############################################################
8 # Package Go within netdata (TBD: Package it separately)
9 safe_sha256sum() {
10 - # Within the context of the installer, we only use -c option that is common between the two commands
11 - # We will have to reconsider if we start non-common options
12 - if command -v sha256sum >/dev/null 2>&1; then
13 - sha256sum $@
14 - elif command -v shasum >/dev/null 2>&1; then
15 - shasum -a 256 $@
16 - else
17 - fatal "I could not find a suitable checksum binary to use"
18 - fi
10 + # Within the context of the installer, we only use -c option that is common between the two commands
11 + # We will have to reconsider if we start non-common options
12 + if command -v sha256sum >/dev/null 2>&1; then
13 + sha256sum $@
14 + elif command -v shasum >/dev/null 2>&1; then
15 + shasum -a 256 $@
16 + else
17 + fatal "I could not find a suitable checksum binary to use"
18 + fi
19 }
20
21 download_go() {
22 - url="${1}"
23 - dest="${2}"
24 -
25 - if command -v curl >/dev/null 2>&1; then
26 - curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}"
27 - elif command -v wget >/dev/null 2>&1; then
28 - wget -T 15 -O - "${url}" > "${dest}"
29 - else
30 - echo >&2
31 - echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
32 - echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
33 - echo >&2
34 - exit 1
35 - fi
22 + url="${1}"
23 + dest="${2}"
24 +
25 + if command -v curl >/dev/null 2>&1; then
26 + curl -sSL --connect-timeout 10 --retry 3 "${url}" >"${dest}"
27 + elif command -v wget >/dev/null 2>&1; then
28 + wget -T 15 -O - "${url}" >"${dest}"
29 + else
30 + echo >&2
31 + echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
32 + echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
33 + echo >&2
34 + exit 1
35 + fi
36 }
37
38 install_go() {
39 - ARCH_MAP=(
40 - 'i386::386'
41 - 'i686::386'
42 - 'x86_64::amd64'
43 - 'aarch64::arm64'
44 - 'armv64::arm64'
45 - 'armv6l::arm'
46 - 'armv7l::arm'
47 - 'armv5tel::arm'
48 - )
49 -
50 - if [ -z "${NETDATA_DISABLE_GO+x}" ]; then
51 - echo >&2 "Install go.d.plugin"
52 - ARCH=$(uname -m)
53 - OS=$(uname -s | tr '[:upper:]' '[:lower:]')
54 -
55 - for index in "${ARCH_MAP[@]}" ; do
56 - KEY="${index%%::*}"
57 - VALUE="${index##*::}"
58 - if [ "$KEY" = "$ARCH" ]; then
59 - ARCH="${VALUE}"
60 - break
61 - fi
62 - done
63 - tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
64 - GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}.tar.gz"
65 - download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
66 - download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
67 -
68 - if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
69 - echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
70 - echo >&2
71 - return 1
72 - fi
73 -
74 - grep "${GO_PACKAGE_BASENAME}\$" "packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2>/dev/null
75 - grep "config.tar.gz" "packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
76 -
77 - # Checksum validation
78 - if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
79 -
80 - echo >&2 "go.d plugin checksum validation failure."
81 - echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
82 - echo >&2
83 -
84 - echo "go.d.plugin package files checksum validation failed."
85 - exit 1
86 - fi
87 -
88 - # Install files
89 - tar -xf "${tmp}/config.tar.gz" -C "${LIB_DIR}/conf.d/"
90 - tar xf "${tmp}/${GO_PACKAGE_BASENAME}"
91 - mv "${GO_PACKAGE_BASENAME/\.tar\.gz/}" "${LIBEXEC_DIR}/plugins.d/go.d.plugin"
92 -
93 - rm -rf "${tmp}"
94 - fi
95 - return 0
39 + ARCH_MAP=(
40 + 'i386::386'
41 + 'armhf::arm'
42 + )
43 + if [ -z "${NETDATA_DISABLE_GO+x}" ]; then
44 + ARCH="${DEB_TARGET_ARCH}"
45 +
46 + for index in "${ARCH_MAP[@]}" ; do
47 + KEY="${index%%::*}"
48 + VALUE="${index##*::}"
49 + if [ "$KEY" = "$ARCH" ]; then
50 + ARCH="${VALUE}"
51 + break
52 + fi
53 + done
54 +
55 + OS=$(uname -s | tr '[:upper:]' '[:lower:]')
56 +
57 + echo >&2 "Install go.d.plugin (ARCH=${ARCH}, OS=${OS})"
58 +
59 + tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
60 + GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}.tar.gz"
61 + download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
62 + download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
63 +
64 + if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
65 + echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
66 + echo >&2
67 + return 1
68 + fi
69 +
70 + grep "${GO_PACKAGE_BASENAME}\$" "packaging/go.d.checksums" >"${tmp}/sha256sums.txt" 2>/dev/null
71 + grep "config.tar.gz" "packaging/go.d.checksums" >>"${tmp}/sha256sums.txt" 2>/dev/null
72 +
73 + # Checksum validation
74 + if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
75 +
76 + echo >&2 "go.d plugin checksum validation failure."
77 + echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
78 + echo >&2
79 +
80 + echo "go.d.plugin package files checksum validation failed."
81 + exit 1
82 + fi
83 +
84 + # Install files
85 + tar -xf "${tmp}/config.tar.gz" -C "${LIB_DIR}/conf.d/"
86 + tar xf "${tmp}/${GO_PACKAGE_BASENAME}"
87 + mv "${GO_PACKAGE_BASENAME/\.tar\.gz/}" "${LIBEXEC_DIR}/plugins.d/go.d.plugin"
88 +
89 + rm -rf "${tmp}"
90 + fi
91 + return 0
92 }
93
94 install_go
netdata.spec.in
+3 -2
@@ -393,10 +393,11 @@ install_go() {
393 )
394
395 if [ -z "${NETDATA_DISABLE_GO+x}" ]; then
396 - echo >&2 "Install go.d.plugin"
397 - ARCH=$(uname -m)
396 + ARCH="%{_arch}"
397 OS=$(uname -s | tr '[:upper:]' '[:lower:]')
398
399 + echo >&2 "Install go.d.plugin (ARCH=${ARCH}, OS=${OS})"
400 +
401 for index in "${ARCH_MAP[@]}" ; do
402 KEY="${index%%::*}"
403 VALUE="${index##*::}"