Skip to content

Commit

Permalink
fix arch detection for arm mac (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoalexandre authored Sep 14, 2024
1 parent 48b949b commit 2557f01
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ GITHUB_REPO="sfcompute/cli"
BINARY_NAME="sf"

# Check the operating system
OS="$(uname)"
OS="$(uname -ms)"

# If the operating system is Linux, set the target directory to '/usr/local/bin'
# If the operating system is Darwin (macOS), set the target directory to '${HOME}/.local/bin'
if [[ "$OS" == "Linux" ]]; then
if [[ "$OS" == "Linux"* ]]; then
TARGET_DIR="/usr/local/bin"
elif [[ "$OS" == "Darwin" ]]; then
elif [[ "$OS" == "Darwin"* ]]; then
TARGET_DIR="${HOME}/.local/bin"
else
echo "Unsupported operating system: $OS"
Expand Down Expand Up @@ -48,20 +48,20 @@ mkdir -p "${TARGET_DIR}"
# Define the target file path for the 'sf' CLI binary.
TARGET_FILE="${TARGET_DIR}/${BINARY_NAME}"

case $(uname -ms) in
'Darwin x86_64')
target=bun-darwin-x64
;;
'Darwin arm64')
target=bun-darwin-arm64
;;
'Linux x86_64' | *)
target=bun-linux-x64
;;
'Linux aarch64')
target=bun-linux-arm64
;;
esac
if [[ "$OS" == "Linux"* ]]; then
if [[ "$OS" == 'Linux aarch64' ]]; then
target='bun-linux-arm64'
else
target='bun-linux-x64'
fi
elif [[ "$OS" == "Darwin"* ]]; then
sys="$(sysctl -n machdep.cpu.brand_string)"
if [[ $sys == *"M1"* || $sys == *"M2"* ]]; then
target='bun-darwin-arm64'
else
target='bun-darwin-x64'
fi
fi

# Set up temporary directory for download and extraction
TMPDIR=$(mktemp -d)
Expand Down Expand Up @@ -127,4 +127,4 @@ if [ -f "${TARGET_FILE}" ]; then

else
echo "Installation failed. '${BINARY_NAME}' CLI could not be installed."
fi
fi

0 comments on commit 2557f01

Please sign in to comment.