*: introduce tool/go following our common pattern
- This tool/go does not currently invoke gocross, as there's more work to do in gocross to be fully compatible with gomobile. - Use GOBIN to target the output destinations for gomobile and gobind. - Remove the old toolchain targets from the Makefile. - Use ~/.cache/tailscale-go, like the OSS repo does. - Introduce go.toolchain.rev as we have in the OSS repo, and update it in the bumposs task. Updates tailscale/corp#18202 Signed-off-by: James Tucker <james@tailscale.com>raggi/builds3
parent
2a14964878
commit
526b614ef4
@ -0,0 +1 @@
|
|||||||
|
f86d7c8ef64a0f8a2516fc23652eee28abc8d8e0
|
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
if [[ "${CI:-}" == "true" && "${NOBASHDEBUG:-}" != "true" ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Allow TOOLCHAINDIR to be overridden, as a special case for the fdroid build
|
||||||
|
if [[ -z "${TOOLCHAINDIR}" ]]; then
|
||||||
|
toolchain="$HOME/.cache/tailscale-go"
|
||||||
|
|
||||||
|
if [[ -d "$toolchain" ]]; then
|
||||||
|
# A toolchain exists, but is it recent enough to compile gocross? If not,
|
||||||
|
# wipe it out so that the next if block fetches a usable one.
|
||||||
|
want_go_minor=$(grep -E '^go ' "go.mod" | cut -f2 -d'.')
|
||||||
|
have_go_minor=""
|
||||||
|
if [[ -f "$toolchain/VERSION" ]]; then
|
||||||
|
have_go_minor=$(head -1 "$toolchain/VERSION" | cut -f2 -d'.')
|
||||||
|
fi
|
||||||
|
# Shortly before stable releases, we run release candidate
|
||||||
|
# toolchains, which have a non-numeric suffix on the version
|
||||||
|
# number. Remove the rc qualifier, we just care about the minor
|
||||||
|
# version.
|
||||||
|
have_go_minor="${have_go_minor%rc*}"
|
||||||
|
if [[ -z "$have_go_minor" || "$have_go_minor" -lt "$want_go_minor" ]]; then
|
||||||
|
rm -rf "$toolchain" "$toolchain.extracted"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$toolchain" ]]; then
|
||||||
|
mkdir -p "$HOME/.cache"
|
||||||
|
|
||||||
|
read -r REV <go.toolchain.rev
|
||||||
|
|
||||||
|
case "$REV" in
|
||||||
|
/*)
|
||||||
|
toolchain="$REV"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# This works for linux and darwin, which is sufficient
|
||||||
|
# (we do not build tailscale-go for other targets).
|
||||||
|
HOST_OS=$(uname -s | tr A-Z a-z)
|
||||||
|
HOST_ARCH="$(uname -m)"
|
||||||
|
if [[ "$HOST_ARCH" == "aarch64" ]]; then
|
||||||
|
# Go uses the name "arm64".
|
||||||
|
HOST_ARCH="arm64"
|
||||||
|
elif [[ "$HOST_ARCH" == "x86_64" ]]; then
|
||||||
|
# Go uses the name "amd64".
|
||||||
|
HOST_ARCH="amd64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$toolchain" "$toolchain.extracted"
|
||||||
|
curl -f -L -o "$toolchain.tar.gz" "https://github.com/tailscale/go/releases/download/build-${REV}/${HOST_OS}-${HOST_ARCH}.tar.gz"
|
||||||
|
mkdir -p "$toolchain"
|
||||||
|
(cd "$toolchain" && tar --strip-components=1 -xf "$toolchain.tar.gz")
|
||||||
|
echo "$REV" >"$toolchain.extracted"
|
||||||
|
rm -f "$toolchain.tar.gz"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# fdroid supplies it's own toolchain, rather than using ours.
|
||||||
|
toolchain="${TOOLCHAINDIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "${toolchain}/bin/go" "$@"
|
Loading…
Reference in New Issue