From b3de2d9b0383ec5df2b034c8eae03d5fe0863fb2 Mon Sep 17 00:00:00 2001 From: Brandon High <759848+highb@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:47:46 -0700 Subject: [PATCH 1/5] Add arch detection --- lib/utils.bash | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index 2315a34..664fbd7 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -159,16 +159,13 @@ detect_os() { detect_arch() { # TODO Figure out arm, arm64, i386, etc if [ "$ARCH" = "unknown" ]; then - if [ "$1" = "darwin" ]; then - echo 'amd64' - elif [ "$1" = "linux" ]; then - echo 'amd64' - else + ARCH="$(command -v uname -m)" + if [ $? != 0 ]; then fail "Unknown architecture. Please provide the architecture by setting \$ARCH." fi - else - echo "$ARCH" fi + + echo "$ARCH" } download_release() { From 7e848c38990e57d56900883e2fe48ea3ba1c17c7 Mon Sep 17 00:00:00 2001 From: Brandon High <759848+highb@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:49:06 -0700 Subject: [PATCH 2/5] Use uname directly --- lib/utils.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index 664fbd7..7a3c21e 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -132,7 +132,7 @@ list_all_versions() { detect_os() { if [ "$OS" = "unknown" ]; then - UNAME="$(command -v uname)" + UNAME="$(uname)" case $("${UNAME}" | tr '[:upper:]' '[:lower:]') in linux*) @@ -159,7 +159,7 @@ detect_os() { detect_arch() { # TODO Figure out arm, arm64, i386, etc if [ "$ARCH" = "unknown" ]; then - ARCH="$(command -v uname -m)" + ARCH="$(uname -m)" if [ $? != 0 ]; then fail "Unknown architecture. Please provide the architecture by setting \$ARCH." fi From 0bd365b62575d7f15a71fc3e971e714c5602bc52 Mon Sep 17 00:00:00 2001 From: Brandon High <759848+highb@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:50:43 -0700 Subject: [PATCH 3/5] Use uname directly in arch detection --- lib/utils.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.bash b/lib/utils.bash index 7a3c21e..00d8cfe 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -132,7 +132,7 @@ list_all_versions() { detect_os() { if [ "$OS" = "unknown" ]; then - UNAME="$(uname)" + UNAME="$(command -v uname)" case $("${UNAME}" | tr '[:upper:]' '[:lower:]') in linux*) From 03ab09109f913e0073d4098e7833408d4fae0b6b Mon Sep 17 00:00:00 2001 From: Brandon High <759848+highb@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:54:30 -0700 Subject: [PATCH 4/5] Handle x86_64 as special case --- lib/utils.bash | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index 00d8cfe..1cff3aa 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -163,9 +163,16 @@ detect_arch() { if [ $? != 0 ]; then fail "Unknown architecture. Please provide the architecture by setting \$ARCH." fi - fi - echo "$ARCH" + # Translate to Teleport arch names + if [ "${ARCH}" == "x86_64" ]; then + echo "amd64" + else + echo "$ARCH" + fi + else + echo "$ARCH" + fi } download_release() { From aa17408282b05da92120f5a5bd6021067e95748c Mon Sep 17 00:00:00 2001 From: Brandon High <759848+highb@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:00:20 -0700 Subject: [PATCH 5/5] Explicit list of supported arch --- lib/utils.bash | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index 1cff3aa..0d341e4 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -161,14 +161,22 @@ detect_arch() { if [ "$ARCH" = "unknown" ]; then ARCH="$(uname -m)" if [ $? != 0 ]; then - fail "Unknown architecture. Please provide the architecture by setting \$ARCH." + fail "\$ARCH not provided and could not call uname -m." fi - # Translate to Teleport arch names + # Translate to Teleport arch names/explicit list of supported arch if [ "${ARCH}" == "x86_64" ]; then echo "amd64" - else + elif [ "${ARCH}" == "amd64" ]; then + echo "$ARCH" + elif [ "${ARCH}" == "arm64" ]; then + echo "$ARCH" + elif [ "${ARCH}" == "i386" ]; then echo "$ARCH" + elif [ "${ARCH}" == "armv7" ]; then + echo "$ARCH" + else + fail "Unknown architecture. Please provide the architecture by setting \$ARCH." fi else echo "$ARCH"