From afe19d1d8110d0501b17156dc9f7b1453424c317 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 11 Feb 2023 12:28:24 -0800 Subject: [PATCH] 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 --- tool/go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tool/go b/tool/go index da8752446..776852023 100755 --- a/tool/go +++ b/tool/go @@ -27,14 +27,14 @@ fi # This works for linux and darwin, which is sufficient # (we do not build tailscale-go for other targets). -GOOS=$(uname -s | tr A-Z a-z) -ARCH="$(uname -m)" -if [ "$ARCH" = "aarch64" ]; then +host_os=$(uname -s | tr A-Z a-z) +host_arch="$(uname -m)" +if [ "$host_arch" = "aarch64" ]; then # Go uses the name "arm64". - ARCH="arm64" -elif [ "$ARCH" = "x86_64" ]; then + host_arch="arm64" +elif [ "$host_arch" = "x86_64" ]; then # Go uses the name "amd64". - ARCH="amd64" + host_arch="amd64" fi get_cached() { @@ -58,7 +58,7 @@ get_cached() { rm -f "$archive.new" "$TOOLCHAIN.extracted" if [ ! -e "$archive" ]; then 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" mv "$archive.new" "$archive" fi @@ -72,8 +72,8 @@ get_cached() { } if [ "${REV}" = "SKIP" ] || - [ "${GOOS}" != "darwin" -a "${GOOS}" != "linux" ] || - [ "${ARCH}" != "amd64" -a "${ARCH}" != "arm64" ]; then + [ "${host_os}" != "darwin" -a "${host_os}" != "linux" ] || + [ "${host_arch}" != "amd64" -a "${host_arch}" != "arm64" ]; then # Use whichever go is available exec go "$@" else