From e576fe0062f813cd0de95c124a76e3bd2e0ed469 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 27 Jul 2023 11:35:37 +0800 Subject: [PATCH] Revert "brew.sh: don't set `HOMEBREW_NO_INSTALL_FROM_API` automatically." https://github.com/Homebrew/brew/pull/15765#issuecomment-1652856355 This reverts commit d9bc51f8171b49486a871a8bb12a2629df28a519. --- Library/Homebrew/brew.sh | 14 ++++++++++++++ docs/Installation.md | 2 ++ 2 files changed, 16 insertions(+) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 861d3d27e9236..91212115a634a 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -533,6 +533,8 @@ then # shellcheck disable=SC2086,SC2183 printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_VERSION//./ } # shellcheck disable=SC2248 + printf -v HOMEBREW_MACOS_OLDEST_SUPPORTED_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_OLDEST_SUPPORTED//./ } + # shellcheck disable=SC2248 printf -v HOMEBREW_MACOS_OLDEST_ALLOWED_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_OLDEST_ALLOWED//./ } # Don't include minor versions for Big Sur and later. @@ -591,6 +593,12 @@ then # shellcheck disable=SC2034 HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH="1" fi + + # Don't support API at this time for older macOS versions. + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "${HOMEBREW_MACOS_OLDEST_SUPPORTED_NUMERIC}" ]] + then + export HOMEBREW_NO_INSTALL_FROM_API=1 + fi else HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew" [[ -n "${HOMEBREW_LINUX}" ]] && HOMEBREW_OS_VERSION="$(source /etc/os-release && echo "${PRETTY_NAME}")" @@ -663,6 +671,12 @@ Your Git executable: $(unset git && type -p "${HOMEBREW_GIT}")" fi fi +# Generic OS or non-default prefix: API not supported. +if [[ (-z "${HOMEBREW_MACOS}" && -z "${HOMEBREW_LINUX}") || "${HOMEBREW_PREFIX}" != "${HOMEBREW_DEFAULT_PREFIX}" ]] +then + export HOMEBREW_NO_INSTALL_FROM_API=1 +fi + setup_ca_certificates() { if [[ -n "${HOMEBREW_FORCE_BREWED_CA_CERTIFICATES}" && -f "${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem" ]] then diff --git a/docs/Installation.md b/docs/Installation.md index fdda275629007..a0e8c69b645f5 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -36,6 +36,8 @@ export HOMEBREW_NO_INSTALL_FROM_API=1 This will make Homebrew install formulae and casks from the `homebrew/core` and `homebrew/cask` taps using local checkouts of these repositories instead of Homebrew’s API. +Note that this will automatically be set on unsupported configurations (i.e. not using the default Homebrew prefix or, if on macOS, on an unsupported version). + ## Unattended installation If you want a non-interactive run of the Homebrew installer that doesn't prompt for passwords (e.g. in automation scripts), prepend [`NONINTERACTIVE=1`](https://github.com/Homebrew/install/#install-homebrew-on-macos-or-linux) to the installation command.