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
|
2020-03-20 12:17:48 +01:00
|
|
|
local TERMUX_GO_VERSION=go1.14.1
|
2019-08-06 14:39:42 +02:00
|
|
|
local TERMUX_GO_PLATFORM=linux-amd64
|
2019-02-26 21:30:03 +01:00
|
|
|
|
2019-08-06 14:39:42 +02:00
|
|
|
local TERMUX_BUILDGO_FOLDER=$TERMUX_COMMON_CACHEDIR/${TERMUX_GO_VERSION}
|
|
|
|
export GOROOT=$TERMUX_BUILDGO_FOLDER
|
|
|
|
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"
|
|
|
|
termux_download https://storage.googleapis.com/golang/${TERMUX_GO_VERSION}.${TERMUX_GO_PLATFORM}.tar.gz \
|
|
|
|
"$TERMUX_BUILDGO_TAR" \
|
2020-03-20 12:17:48 +01:00
|
|
|
2f49eb17ce8b48c680cdb166ffd7389702c0dec6effa090c324804a5cac8a7f8
|
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" )
|
|
|
|
else
|
|
|
|
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]; then
|
|
|
|
echo "Package 'golang' is not installed."
|
|
|
|
echo "You can install it with"
|
|
|
|
echo
|
|
|
|
echo " pkg install golang"
|
|
|
|
echo
|
|
|
|
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
|
|
|
}
|