scripts: template_setup_posix: Add Bash 3.x support on M1 Mac

The macOS default Bash 3.x (`/bin/bash`) sets the `HOSTTYPE` variable
to `arm64` instead of `aarch64` on the M1 Macs, causing the setup
script to try fetching the toolchain tarballs from an incorrect URL.

This commit updates the setup script to re-set the `HOSTTYPE` variable
to `aarch64` if `arm64` is set by the Bash.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2022-05-13 22:36:17 +09:00
parent 524d52fbc7
commit 0cc56ecd18
1 changed files with 11 additions and 2 deletions

View File

@ -185,8 +185,17 @@ version=$(<sdk_version)
# Resolve host type
case ${OSTYPE} in
linux-gnu*) host="linux-${HOSTTYPE}" ;;
darwin*) host="macos-${HOSTTYPE}" ;;
linux-gnu*)
host="linux-${HOSTTYPE}"
;;
darwin*)
# Bash 3.x on AArch64 Darwin sets HOSTTYPE to 'arm64'
if [ "${HOSTTYPE}" = "arm64" ]; then
HOSTTYPE="aarch64"
fi
host="macos-${HOSTTYPE}"
;;
*)
echo "ERROR: Unsupported host operating system"
exit 5