tool/go: don't use the names GOOS/GOARCH in script

The use of GOOS to mean "the compiler's host architecture" ends up
overriding whatever GOOS the user passed in, resulting in befuddling
errors like "unsupported GOOS/GOARCH pair linux/wasm" when the caller
requests js/wasm.

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/7265/head
David Anderson 1 year ago committed by Dave Anderson
parent fe5558094c
commit afe19d1d81

@ -27,14 +27,14 @@ fi
# This works for linux and darwin, which is sufficient # This works for linux and darwin, which is sufficient
# (we do not build tailscale-go for other targets). # (we do not build tailscale-go for other targets).
GOOS=$(uname -s | tr A-Z a-z) host_os=$(uname -s | tr A-Z a-z)
ARCH="$(uname -m)" host_arch="$(uname -m)"
if [ "$ARCH" = "aarch64" ]; then if [ "$host_arch" = "aarch64" ]; then
# Go uses the name "arm64". # Go uses the name "arm64".
ARCH="arm64" host_arch="arm64"
elif [ "$ARCH" = "x86_64" ]; then elif [ "$host_arch" = "x86_64" ]; then
# Go uses the name "amd64". # Go uses the name "amd64".
ARCH="amd64" host_arch="amd64"
fi fi
get_cached() { get_cached() {
@ -58,7 +58,7 @@ get_cached() {
rm -f "$archive.new" "$TOOLCHAIN.extracted" rm -f "$archive.new" "$TOOLCHAIN.extracted"
if [ ! -e "$archive" ]; then if [ ! -e "$archive" ]; then
log "Need to download go '$REV'." log "Need to download go '$REV'."
curl -f -L -o "$archive.new" "https://github.com/tailscale/go/releases/download/build-${REV}/${GOOS}-${ARCH}.tar.gz" curl -f -L -o "$archive.new" "https://github.com/tailscale/go/releases/download/build-${REV}/${host_os}-${host_arch}.tar.gz"
rm -f "$archive" rm -f "$archive"
mv "$archive.new" "$archive" mv "$archive.new" "$archive"
fi fi
@ -72,8 +72,8 @@ get_cached() {
} }
if [ "${REV}" = "SKIP" ] || if [ "${REV}" = "SKIP" ] ||
[ "${GOOS}" != "darwin" -a "${GOOS}" != "linux" ] || [ "${host_os}" != "darwin" -a "${host_os}" != "linux" ] ||
[ "${ARCH}" != "amd64" -a "${ARCH}" != "arm64" ]; then [ "${host_arch}" != "amd64" -a "${host_arch}" != "arm64" ]; then
# Use whichever go is available # Use whichever go is available
exec go "$@" exec go "$@"
else else

Loading…
Cancel
Save