From 0a60714de58fe4abcf43afe61e44a1f86ba7f499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20Gen=C3=A7?= <25902330+denizgenc@users.noreply.github.com> Date: Tue, 19 Jul 2022 12:59:48 +0100 Subject: [PATCH 1/3] Select kernel before setting TFENV_ARCH --- libexec/tfenv-install | 66 +++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/libexec/tfenv-install b/libexec/tfenv-install index 08c6ed0..82eec59 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -82,49 +82,55 @@ 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"; + ;; + *) + 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; + ;; + esac; ;; *) - os="linux_${TFENV_ARCH}"; + 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)"; From c30dae23c8fc70cc0022dc9c34a95da646dc8249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20Gen=C3=A7?= <25902330+denizgenc@users.noreply.github.com> Date: Tue, 19 Jul 2022 13:01:11 +0100 Subject: [PATCH 2/3] Add MacOS case for TFENV_ARCH initialisation --- libexec/tfenv-install | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libexec/tfenv-install b/libexec/tfenv-install index 82eec59..a542f54 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -122,6 +122,15 @@ case "$(uname -m)" in TFENV_ARCH="${TFENV_ARCH:-arm64}"; fi; ;; + "darwin") + # No M1 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; ;; *) From 94f0d2cc3a143c74c54c23764c7dfd84ff98fba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20Gen=C3=A7?= <25902330+denizgenc@users.noreply.github.com> Date: Tue, 19 Jul 2022 13:21:52 +0100 Subject: [PATCH 3/3] Clarify comment Not just M1 Macs are affected by this change, of course. --- libexec/tfenv-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/tfenv-install b/libexec/tfenv-install index a542f54..d13b384 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -123,7 +123,7 @@ case "$(uname -m)" in fi; ;; "darwin") - # No M1 builds before 1.0.2 + # No Apple Silicon builds before 1.0.2 if [[ "${version}" =~ 0\..+$ || "${version}" =~ 1\.0\.0|1$ ]]; then TFENV_ARCH="${TFENV_ARCH:-amd64}";