未验证 提交 3b41be99 编辑于 作者: Carlo Cabrera's avatar Carlo Cabrera 提交者: GitHub
浏览文件

Merge pull request #12417 from carlocab/rosetta-arm

vendor-install: handle native ARM running under Rosetta
......@@ -6,23 +6,31 @@
# Doesn't need a default case because we don't support other OSs
# shellcheck disable=SC2249
HOMEBREW_PROCESSOR="$(uname -m)"
HOMEBREW_PHYSICAL_PROCESSOR="${HOMEBREW_PROCESSOR}"
HOMEBREW_SYSTEM="$(uname -s)"
case "${HOMEBREW_SYSTEM}" in
Darwin) HOMEBREW_MACOS="1" ;;
Linux) HOMEBREW_LINUX="1" ;;
esac
# If we're running under macOS Rosetta 2, and it was requested by setting
# HOMEBREW_CHANGE_ARCH_TO_ARM (for example in CI), then we re-exec this
# same file under the native architecture
# These variables are set from the user environment.
# shellcheck disable=SC2154
if [[ "${HOMEBREW_CHANGE_ARCH_TO_ARM}" == "1" ]] &&
[[ "${HOMEBREW_MACOS}" == "1" ]] &&
[[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]] &&
[[ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" == "1" ]]
if [[ "${HOMEBREW_MACOS}" == "1" ]] &&
[[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]]
then
exec arch -arm64e "${HOMEBREW_BREW_FILE}" "$@"
# used in vendor-install.sh
# shellcheck disable=SC2034
HOMEBREW_PHYSICAL_PROCESSOR="arm64"
HOMEBREW_ROSETTA="$(sysctl -n sysctl.proc_translated)"
# If we're running under macOS Rosetta 2, and it was requested by setting
# HOMEBREW_CHANGE_ARCH_TO_ARM (for example in CI), then we re-exec this
# same file under the native architecture
# These variables are set from the user environment.
# shellcheck disable=SC2154
if [[ "${HOMEBREW_CHANGE_ARCH_TO_ARM}" == "1" ]] &&
[[ "${HOMEBREW_ROSETTA}" == "1" ]]
then
exec arch -arm64e "${HOMEBREW_BREW_FILE}" "$@"
fi
fi
# Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local
......
......@@ -14,15 +14,15 @@ VENDOR_DIR="${HOMEBREW_LIBRARY}/Homebrew/vendor"
# Built from https://github.com/Homebrew/homebrew-portable-ruby.
if [[ -n "${HOMEBREW_MACOS}" ]]
then
if [[ "${HOMEBREW_PROCESSOR}" == "Intel" ]] ||
if [[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "x86_64" ]] ||
# Handle the case where /usr/local/bin/brew is run under arm64.
# It's a x86_64 installation there (we refuse to install arm64 binaries) so
# use a x86_64 Portable Ruby.
[[ "${HOMEBREW_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]]
[[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]]
then
ruby_FILENAME="portable-ruby-2.6.8.yosemite.bottle.tar.gz"
ruby_SHA="0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42"
elif [[ "${HOMEBREW_PROCESSOR}" == "arm64" ]]
elif [[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "arm64" ]]
then
ruby_FILENAME="portable-ruby-2.6.8.arm64_big_sur.bottle.tar.gz"
ruby_SHA="f2d5cab5a4dd49e5b3de780a3cd0a1f61642fea247d1c25aa40cd43f1be290b5"
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册