forked from lix-project/lix-installer
Fix arm64 darwin install (#789)
* fix: workaround for lies from uname -m On an arm64 mac, `uname -m` returns x86_64 which causes install script to install with the wrong architecture * refactor: use same logic from rustup * Tweak credit comment * Prod ci --------- Co-authored-by: oz <otech47@gmail.com>
This commit is contained in:
parent
0b0172547c
commit
e815280881
|
@ -11,7 +11,7 @@
|
|||
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
|
||||
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
|
||||
|
||||
# This script is based off https://github.com/rust-lang/rustup/blob/8f6b53628ad996ad86f9c6225fa500cddf860905/rustup-init.sh
|
||||
# This script is based off https://github.com/rust-lang/rustup/blob/f8d7b3baba7a63237cb2b82ef49a68a37dd0633c/rustup-init.sh
|
||||
|
||||
if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
|
||||
# The version of ksh93 that ships with many illumos systems does not
|
||||
|
@ -143,10 +143,30 @@ get_architecture() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
|
||||
# Darwin `uname -m` lies
|
||||
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
|
||||
_cputype=x86_64
|
||||
if [ "$_ostype" = Darwin ]; then
|
||||
# Darwin `uname -m` can lie due to Rosetta shenanigans. If you manage to
|
||||
# invoke a native shell binary and then a native uname binary, you can
|
||||
# get the real answer, but that's hard to ensure, so instead we use
|
||||
# `sysctl` (which doesn't lie) to check for the actual architecture.
|
||||
if [ "$_cputype" = i386 ]; then
|
||||
# Handling i386 compatibility mode in older macOS versions (<10.15)
|
||||
# running on x86_64-based Macs.
|
||||
# Starting from 10.15, macOS explicitly bans all i386 binaries from running.
|
||||
# See: <https://support.apple.com/en-us/HT208436>
|
||||
|
||||
# Avoid `sysctl: unknown oid` stderr output and/or non-zero exit code.
|
||||
if sysctl hw.optional.x86_64 2> /dev/null || true | grep -q ': 1'; then
|
||||
_cputype=x86_64
|
||||
fi
|
||||
elif [ "$_cputype" = x86_64 ]; then
|
||||
# Handling x86-64 compatibility mode (a.k.a. Rosetta 2)
|
||||
# in newer macOS versions (>=11) running on arm64-based Macs.
|
||||
# Rosetta 2 is built exclusively for x86-64 and cannot run i386 binaries.
|
||||
|
||||
# Avoid `sysctl: unknown oid` stderr output and/or non-zero exit code.
|
||||
if sysctl hw.optional.arm64 2> /dev/null || true | grep -q ': 1'; then
|
||||
_cputype=arm64
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue