From cf01a7f9856865342f85370fc5b48f0b30da6d93 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 24 Nov 2022 22:07:30 +0800 Subject: [PATCH 1/2] brew.sh: remove `HOMEBREW_CHANGE_ARCH_TO_ARM` We used to need this because the GitHub runner process was running under Rosetta. GitHub Actions has supported native M1 runners for a few months now, so I think it's time to remove this. --- .github/workflows/doctor.yml | 1 - Library/Homebrew/brew.sh | 27 +++++++-------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/doctor.yml b/.github/workflows/doctor.yml index 50409557e6..51d30f5d7d 100644 --- a/.github/workflows/doctor.yml +++ b/.github/workflows/doctor.yml @@ -13,7 +13,6 @@ permissions: env: HOMEBREW_DEVELOPER: 1 HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_CHANGE_ARCH_TO_ARM: 1 jobs: tests: strategy: diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 22ea354764..4ab5345058 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -13,26 +13,6 @@ case "${HOMEBREW_SYSTEM}" in Linux) HOMEBREW_LINUX="1" ;; esac -if [[ "${HOMEBREW_MACOS}" == "1" ]] && - [[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]] -then - # 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 # for bottles) unless there's already a Cellar in HOMEBREW_REPOSITORY. # These variables are set by bin/brew @@ -442,6 +422,13 @@ then # Don't change this from Mac OS X to match what macOS itself does in Safari on 10.12 HOMEBREW_OS_USER_AGENT_VERSION="Mac OS X ${HOMEBREW_MACOS_VERSION}" + if [[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]] + then + # used in vendor-install.sh + # shellcheck disable=SC2034 + HOMEBREW_PHYSICAL_PROCESSOR="arm64" + fi + # Intentionally set this variable by exploding another. # shellcheck disable=SC2086,SC2183 printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_VERSION//./ } From 239743f39bdd8699abcb8d1652e7b2e8249fb1ec Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 24 Nov 2022 22:15:03 +0800 Subject: [PATCH 2/2] Fix `shellcheck` error --- Library/Homebrew/brew.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 4ab5345058..98373deac4 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -150,6 +150,8 @@ safe_cd() { } brew() { + # This variable is set by bin/brew + # shellcheck disable=SC2154 "${HOMEBREW_BREW_FILE}" "$@" }