2019-02-26 21:30:03 +01:00
|
|
|
# Utility function for golang-using packages to setup a go toolchain.
|
|
|
|
termux_setup_golang() {
|
2019-08-12 23:16:07 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
2022-03-16 03:44:58 +01:00
|
|
|
local TERMUX_GO_VERSION=go1.18
|
2019-08-06 14:39:42 +02:00
|
|
|
local TERMUX_GO_PLATFORM=linux-amd64
|
2019-02-26 21:30:03 +01:00
|
|
|
|
2020-10-22 21:45:33 +02:00
|
|
|
local TERMUX_BUILDGO_FOLDER
|
|
|
|
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
|
|
|
TERMUX_BUILDGO_FOLDER=${TERMUX_SCRIPTDIR}/build-tools/${TERMUX_GO_VERSION}
|
|
|
|
else
|
|
|
|
TERMUX_BUILDGO_FOLDER=${TERMUX_COMMON_CACHEDIR}/${TERMUX_GO_VERSION}
|
|
|
|
fi
|
|
|
|
|
2019-08-06 14:39:42 +02:00
|
|
|
export GOROOT=$TERMUX_BUILDGO_FOLDER
|
2020-10-22 21:45:33 +02:00
|
|
|
export PATH=${GOROOT}/bin:${PATH}
|
2019-02-26 21:30:03 +01:00
|
|
|
|
2019-08-06 14:39:42 +02:00
|
|
|
if [ -d "$TERMUX_BUILDGO_FOLDER" ]; then return; fi
|
2019-02-26 21:30:03 +01:00
|
|
|
|
2019-08-06 14:39:42 +02:00
|
|
|
local TERMUX_BUILDGO_TAR=$TERMUX_COMMON_CACHEDIR/${TERMUX_GO_VERSION}.${TERMUX_GO_PLATFORM}.tar.gz
|
|
|
|
rm -Rf "$TERMUX_COMMON_CACHEDIR/go" "$TERMUX_BUILDGO_FOLDER"
|
2020-07-20 20:40:09 +02:00
|
|
|
termux_download https://golang.org/dl/${TERMUX_GO_VERSION}.${TERMUX_GO_PLATFORM}.tar.gz \
|
2019-08-06 14:39:42 +02:00
|
|
|
"$TERMUX_BUILDGO_TAR" \
|
2022-03-16 03:44:58 +01:00
|
|
|
e85278e98f57cdb150fe8409e6e5df5343ecb13cebf03a5d5ff12bd55a80264f
|
2019-02-26 21:30:03 +01:00
|
|
|
|
2019-08-06 14:39:42 +02:00
|
|
|
( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" )
|
2022-03-31 21:02:16 +02:00
|
|
|
|
|
|
|
( cd "$TERMUX_BUILDGO_FOLDER"; . ${TERMUX_SCRIPTDIR}/packages/golang/fix-hardcoded-etc-resolv-conf.sh )
|
2019-08-06 14:39:42 +02:00
|
|
|
else
|
2022-02-02 15:45:36 +01:00
|
|
|
if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]] ||
|
2022-03-31 21:02:16 +02:00
|
|
|
[[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q golang 2>/dev/null)" ]]; then
|
2019-08-06 14:39:42 +02:00
|
|
|
echo "Package 'golang' is not installed."
|
|
|
|
echo "You can install it with"
|
|
|
|
echo
|
|
|
|
echo " pkg install golang"
|
|
|
|
echo
|
2022-01-14 14:16:37 +01:00
|
|
|
echo " pacman -S golang"
|
|
|
|
echo
|
2019-08-06 14:39:42 +02:00
|
|
|
echo "or build it from source with"
|
|
|
|
echo
|
|
|
|
echo " ./build-package.sh golang"
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-08-19 01:37:06 +02:00
|
|
|
|
|
|
|
export GOROOT="$TERMUX_PREFIX/lib/go"
|
2019-08-06 14:39:42 +02:00
|
|
|
fi
|
2019-02-26 21:30:03 +01:00
|
|
|
}
|