tool/go: update to correct toolchain as needed

Ensure that the target revision is loaded from this repository, not from
the working directory.
Update go to the target revision if the marker file does not match the
target.

Updates #501

Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
James Tucker
2024-09-13 16:39:14 -07:00
committed by James Tucker
parent 209045d4f7
commit b3a7f7f2ae
+8 -3
View File
@@ -8,6 +8,8 @@ if [[ "${CI:-}" == "true" && "${NOBASHDEBUG:-}" != "true" ]]; then
set -x
fi
tsandroid=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
# Allow TOOLCHAINDIR to be overridden, as a special case for the fdroid build
if [[ -z "${TOOLCHAINDIR}" ]]; then
toolchain="$HOME/.cache/tailscale-go"
@@ -29,10 +31,13 @@ if [[ -z "${TOOLCHAINDIR}" ]]; then
rm -rf "$toolchain" "$toolchain.extracted"
fi
fi
if [[ ! -d "$toolchain" ]]; then
mkdir -p "$HOME/.cache"
read -r REV <go.toolchain.rev
REV="$(<${tsandroid}/go.toolchain.rev)"
EREV=""
[[ -f ${toolchain}.extracted ]] && EREV="$(<${toolchain}.extracted)"
if [[ ! -d "$toolchain" || "$EREV" != "$REV" ]]; then
mkdir -p "$HOME/.cache"
case "$REV" in
/*)