#!/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 "$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" "$@"