summaryrefslogtreecommitdiffstats
path: root/packaging/check-for-go-toolchain.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/check-for-go-toolchain.sh')
-rw-r--r--packaging/check-for-go-toolchain.sh262
1 files changed, 131 insertions, 131 deletions
diff --git a/packaging/check-for-go-toolchain.sh b/packaging/check-for-go-toolchain.sh
index fe5dabfad..2c6298969 100644
--- a/packaging/check-for-go-toolchain.sh
+++ b/packaging/check-for-go-toolchain.sh
@@ -14,163 +14,163 @@
# GOLANG_FAILURE_REASON set to an error message indicating what went wrong.
GOLANG_MIN_MAJOR_VERSION='1'
-GOLANG_MIN_MINOR_VERSION='22'
-GOLANG_MIN_PATCH_VERSION='0'
+GOLANG_MIN_MINOR_VERSION='23'
+GOLANG_MIN_PATCH_VERSION='3'
GOLANG_MIN_VERSION="${GOLANG_MIN_MAJOR_VERSION}.${GOLANG_MIN_MINOR_VERSION}.${GOLANG_MIN_PATCH_VERSION}"
GOLANG_TEMP_PATH="${TMPDIR}/go-toolchain"
check_go_version() {
- version="$("${go}" version | awk '{ print $3 }' | sed 's/^go//')"
- version_major="$(echo "${version}" | cut -f 1 -d '.')"
- version_minor="$(echo "${version}" | cut -f 2 -d '.')"
- version_patch="$(echo "${version}" | cut -f 3 -d '.')"
-
- if [ -z "${version_major}" ] || [ "${version_major}" -lt "${GOLANG_MIN_MAJOR_VERSION}" ]; then
- return 1
- elif [ "${version_major}" -gt "${GOLANG_MIN_MAJOR_VERSION}" ]; then
- return 0
- fi
-
- if [ -z "${version_minor}" ] || [ "${version_minor}" -lt "${GOLANG_MIN_MINOR_VERSION}" ]; then
- return 1
- elif [ "${version_minor}" -gt "${GOLANG_MIN_MINOR_VERSION}" ]; then
- return 0
- fi
+ version="$("${go}" version | awk '{ print $3 }' | sed 's/^go//')"
+ version_major="$(echo "${version}" | cut -f 1 -d '.')"
+ version_minor="$(echo "${version}" | cut -f 2 -d '.')"
+ version_patch="$(echo "${version}" | cut -f 3 -d '.')"
- if [ -n "${version_patch}" ] && [ "${version_patch}" -ge "${GOLANG_MIN_PATCH_VERSION}" ]; then
- return 0
- fi
+ if [ -z "${version_major}" ] || [ "${version_major}" -lt "${GOLANG_MIN_MAJOR_VERSION}" ]; then
+ return 1
+ elif [ "${version_major}" -gt "${GOLANG_MIN_MAJOR_VERSION}" ]; then
+ return 0
+ fi
+ if [ -z "${version_minor}" ] || [ "${version_minor}" -lt "${GOLANG_MIN_MINOR_VERSION}" ]; then
return 1
+ elif [ "${version_minor}" -gt "${GOLANG_MIN_MINOR_VERSION}" ]; then
+ return 0
+ fi
+
+ if [ -n "${version_patch}" ] && [ "${version_patch}" -ge "${GOLANG_MIN_PATCH_VERSION}" ]; then
+ return 0
+ fi
+
+ return 1
}
install_go_toolchain() {
- GOLANG_ARCHIVE_NAME="${GOLANG_TEMP_PATH}/golang.tar.gz"
- GOLANG_CHECKSUM_FILE="${GOLANG_TEMP_PATH}/golang.sha256sums"
-
- case "$(uname -s)" in
- Linux)
- case "$(uname -m)" in
- i?86)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-386.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="1e209c4abde069067ac9afb341c8003db6a210f8173c77777f02d3a524313da3"
- ;;
- x86_64)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-amd64.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="f6c8a87aa03b92c4b0bf3d558e28ea03006eb29db78917daec5cfb6ec1046265"
- ;;
- aarch64)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-arm64.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="6a63fef0e050146f275bf02a0896badfe77c11b6f05499bb647e7bd613a45a10"
- ;;
- armv*)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-armv6l.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="0525f92f79df7ed5877147bce7b955f159f3962711b69faac66bc7121d36dcc4"
- ;;
- ppc64le)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-ppc64le.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="0e57f421df9449066f00155ce98a5be93744b3d81b00ee4c2c9b511be2a31d93"
- ;;
- riscv64)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-riscv64.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="afe9cedcdbd6fdff27c57efd30aa5ce0f666f471fed5fa96cd4fb38d6b577086"
- ;;
- s390x)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.linux-s390x.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="2e546a3583ba7bd3988f8f476245698f6a93dfa9fe206a8ca8f85c1ceecb2446"
- ;;
- *)
- GOLANG_FAILURE_REASON="Linux $(uname -m) platform is not supported out-of-box by Go, you must install a toolchain for it yourself."
- return 1
- ;;
- esac
- ;;
- FreeBSD)
- case "$(uname -m)" in
- 386)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.freebsd-386.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="b8065da37783e8b9e7086365a54d74537e832c92311b61101a66989ab2458d8e"
- ;;
- amd64)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.freebsd-amd64.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="50f421c7f217083ac94aab1e09400cb9c2fea7d337679ec11f1638a11460da30"
- ;;
- arm)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.freebsd-arm.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="c9c8b305f90903536f4981bad9f029828c2483b3216ca1783777344fbe603f2d"
- ;;
- arm64)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.freebsd-arm64.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="e23385e5c640787fa02cd58f2301ea09e162c4d99f8ca9fa6d52766f428a933d"
- ;;
- riscv64)
- GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.22.0.freebsd-riscv64.tar.gz"
- GOLANG_ARCHIVE_CHECKSUM="c8f94d1de6024546194d58e7b9370dc7ea06176aad94a675b0062c25c40cb645"
- ;;
- *)
- GOLANG_FAILURE_REASON="FreeBSD $(uname -m) platform is not supported out-of-box by Go, you must install a toolchain for it yourself."
- return 1
- ;;
- esac
- ;;
+ GOLANG_ARCHIVE_NAME="${GOLANG_TEMP_PATH}/golang.tar.gz"
+ GOLANG_CHECKSUM_FILE="${GOLANG_TEMP_PATH}/golang.sha256sums"
+
+ case "$(uname -s)" in
+ Linux)
+ case "$(uname -m)" in
+ i?86)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-386.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="0c8e9f824bf443f51e06ac017b9ae402ea066d761b309d880dbb2ca5793db8a2"
+ ;;
+ x86_64)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-amd64.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="a0afb9744c00648bafb1b90b4aba5bdb86f424f02f9275399ce0c20b93a2c3a8"
+ ;;
+ aarch64)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-arm64.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="1f7cbd7f668ea32a107ecd41b6488aaee1f5d77a66efd885b175494439d4e1ce"
+ ;;
+ armv*)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-armv6l.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="5f0332754beffc65af65a7b2da76e9dd997567d0d81b6f4f71d3588dc7b4cb00"
+ ;;
+ ppc64le)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-ppc64le.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="e3b926c81e8099d3cee6e6e270b85b39c3bd44263f8d3df29aacb4d7e00507c8"
+ ;;
+ riscv64)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-riscv64.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="324e03b6f59be841dfbaeabc466224b0f0905f5ad3a225b7c0703090e6c4b1a5"
+ ;;
+ s390x)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.linux-s390x.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="6bd72fcef72b046b6282c2d1f2c38f31600e4fe9361fcd8341500c754fb09c38"
+ ;;
+ *)
+ GOLANG_FAILURE_REASON="Linux $(uname -m) platform is not supported out-of-box by Go, you must install a toolchain for it yourself."
+ return 1
+ ;;
+ esac
+ ;;
+ FreeBSD)
+ case "$(uname -m)" in
+ 386)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.freebsd-386.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="69479fa016ec5b4605885643ce0c2dd5c583e02353978feb6de38c961863b9cc"
+ ;;
+ amd64)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.freebsd-amd64.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="bf1de22a900646ef4f79480ed88337856d47089cc610f87e6fef46f6b8db0e1f"
+ ;;
+ arm)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.freebsd-arm.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="e461f866479bc36bdd4cfec32bfecb1bb243152268a1b3223de109410dec3407"
+ ;;
+ arm64)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.freebsd-arm64.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="24154b4018a45540aefeb6b5b9ffdcc8d9a8cdb78cd7fec262787b89fed19997"
+ ;;
+ riscv64)
+ GOLANG_ARCHIVE_URL="https://go.dev/dl/go1.23.3.freebsd-riscv64.tar.gz"
+ GOLANG_ARCHIVE_CHECKSUM="218f3f1532e61dd65c330c2a5fc85bec18cc3690489763e62ffa9bb9fc85a68e"
+ ;;
*)
- GOLANG_FAILURE_REASON="We do not support automatic handling of a Go toolchain on this system, you must install one manually."
- return 1
- ;;
- esac
-
- if [ -d '/usr/local/go' ]; then
- if [ -f '/usr/local/go/.installed-by-netdata' ]; then
- rm -rf /usr/local/go
- else
- GOLANG_FAILURE_REASON="Refusing to overwrite existing Go toolchain install at /usr/local/go, it needs to be updated manually."
- return 1
- fi
+ GOLANG_FAILURE_REASON="FreeBSD $(uname -m) platform is not supported out-of-box by Go, you must install a toolchain for it yourself."
+ return 1
+ ;;
+ esac
+ ;;
+ *)
+ GOLANG_FAILURE_REASON="We do not support automatic handling of a Go toolchain on this system, you must install one manually."
+ return 1
+ ;;
+ esac
+
+ if [ -d '/usr/local/go' ]; then
+ if [ -f '/usr/local/go/.installed-by-netdata' ]; then
+ rm -rf /usr/local/go
+ else
+ GOLANG_FAILURE_REASON="Refusing to overwrite existing Go toolchain install at /usr/local/go, it needs to be updated manually."
+ return 1
fi
+ fi
- mkdir -p "${GOLANG_TEMP_PATH}"
+ mkdir -p "${GOLANG_TEMP_PATH}"
- if ! curl --fail -q -sSL --connect-timeout 10 --retry 3 --output "${GOLANG_ARCHIVE_NAME}" "${GOLANG_ARCHIVE_URL}"; then
- GOLANG_FAILURE_REASON="Failed to download Go toolchain."
- return 1
- fi
+ if ! curl --fail -q -sSL --connect-timeout 10 --retry 3 --output "${GOLANG_ARCHIVE_NAME}" "${GOLANG_ARCHIVE_URL}"; then
+ GOLANG_FAILURE_REASON="Failed to download Go toolchain."
+ return 1
+ fi
- echo "${GOLANG_ARCHIVE_CHECKSUM} ${GOLANG_ARCHIVE_NAME}" > "${GOLANG_CHECKSUM_FILE}"
+ echo "${GOLANG_ARCHIVE_CHECKSUM} ${GOLANG_ARCHIVE_NAME}" >"${GOLANG_CHECKSUM_FILE}"
- if ! sha256sum -c "${GOLANG_CHECKSUM_FILE}"; then
- GOLANG_FAILURE_REASON="Invalid checksum for downloaded Go toolchain."
- return 1
- fi
+ if ! sha256sum -c "${GOLANG_CHECKSUM_FILE}"; then
+ GOLANG_FAILURE_REASON="Invalid checksum for downloaded Go toolchain."
+ return 1
+ fi
- if ! tar -C /usr/local/ -xzf "${GOLANG_ARCHIVE_NAME}"; then
- GOLANG_FAILURE_REASON="Failed to extract Go toolchain."
- return 1
- fi
+ if ! tar -C /usr/local/ -xzf "${GOLANG_ARCHIVE_NAME}"; then
+ GOLANG_FAILURE_REASON="Failed to extract Go toolchain."
+ return 1
+ fi
- touch /usr/local/go/.installed-by-netdata
+ touch /usr/local/go/.installed-by-netdata
- rm -rf "${GOLANG_TEMP_PATH}"
+ rm -rf "${GOLANG_TEMP_PATH}"
}
ensure_go_toolchain() {
- go="$(PATH="/usr/local/go/bin:${PATH}" command -v go 2>/dev/null)"
-
- need_go_install=0
+ go="$(PATH="/usr/local/go/bin:${PATH}" command -v go 2>/dev/null)"
- if [ -z "${go}" ]; then
- need_go_install=1
- elif ! check_go_version; then
- need_go_install=1
- fi
+ need_go_install=0
- if [ "${need_go_install}" -eq 1 ]; then
- if ! install_go_toolchain; then
- return 1
- fi
+ if [ -z "${go}" ]; then
+ need_go_install=1
+ elif ! check_go_version; then
+ need_go_install=1
+ fi
- rm -rf "${GOLANG_TEMP_PATH}" || true
+ if [ "${need_go_install}" -eq 1 ]; then
+ if ! install_go_toolchain; then
+ return 1
fi
- return 0
+ rm -rf "${GOLANG_TEMP_PATH}" || true
+ fi
+
+ return 0
}