diff --git a/libexec/tfenv-install b/libexec/tfenv-install index 08c6ed0..d13b384 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -82,49 +82,64 @@ if [ -f "${dst_path}/terraform" ]; then exit 0; fi; -# Add support of ARM64 for Linux & Apple Silicon -case "$(uname -m)" in - aarch64* | arm64*) - # There is no arm64 support for versions: - # < 0.11.15 - # >= 0.12.0, < 0.12.30 - # >= 0.13.0, < 0.13.5 - if [[ "${version}" =~ 0\.(([0-9]|10))\.\d* || - "${version}" =~ 0\.11\.(([0-9]|1[0-4]))$ || - "${version}" =~ 0\.12\.(([0-9]|[1-2][0-9]))$ || - "${version}" =~ 0\.13\.[0-4]$ - ]]; then - TFENV_ARCH="${TFENV_ARCH:-amd64}"; - else - TFENV_ARCH="${TFENV_ARCH:-arm64}"; - fi; - ;; - *) - TFENV_ARCH="${TFENV_ARCH:-amd64}"; - ;; -esac; - case "$(uname -s)" in Darwin*) - os="darwin_${TFENV_ARCH}"; + kernel="darwin"; ;; MINGW64*) - os="windows_${TFENV_ARCH}"; + kernel="windows"; ;; - MSYS_NT*) - os="windows_${TFENV_ARCH}"; + MSYSNT*) + kernel="windows"; ;; - CYGWIN_NT*) - os="windows_${TFENV_ARCH}"; + CYGWINNT*) + kernel="windows"; ;; FreeBSD*) - os="freebsd_${TFENV_ARCH}"; + kernel="freebsd"; ;; *) - os="linux_${TFENV_ARCH}"; + kernel="linux"; ;; esac; +# Add support of ARM64 for Linux & Apple Silicon +case "$(uname -m)" in + aarch64* | arm64*) + case "${kernel}" in + "linux") + # There is no arm64 support for versions: + # < 0.11.15 + # >= 0.12.0, < 0.12.30 + # >= 0.13.0, < 0.13.5 + if [[ "${version}" =~ 0\.(([0-9]|10))\.\d* || + "${version}" =~ 0\.11\.(([0-9]|1[0-4]))$ || + "${version}" =~ 0\.12\.(([0-9]|[1-2][0-9]))$ || + "${version}" =~ 0\.13\.[0-4]$ + ]]; then + TFENV_ARCH="${TFENV_ARCH:-amd64}"; + else + TFENV_ARCH="${TFENV_ARCH:-arm64}"; + fi; + ;; + "darwin") + # No Apple Silicon builds before 1.0.2 + if [[ "${version}" =~ 0\..+$ || "${version}" =~ 1\.0\.0|1$ + ]]; then + TFENV_ARCH="${TFENV_ARCH:-amd64}"; + else + TFENV_ARCH="${TFENV_ARCH:-arm64}"; + fi; + ;; + esac; + ;; + *) + TFENV_ARCH="${TFENV_ARCH:-amd64}"; + ;; +esac; + +os="${kernel}_${TFENV_ARCH}" + keybase_bin="$(command -v keybase 2>/dev/null)"; shasum_bin="$(command -v shasum 2>/dev/null)"; sha256sum_bin="$(command -v sha256sum 2>/dev/null)";