brew.sh: set HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX when core repo is homebrew-core

See https://github.com/Homebrew/install/pull/571

When the install script sets as https://github.com/Homebrew/homebrew-core,
we need to use the homebrew-core bottle domain, and correctly set
the HOMEBREW_CORE_DEFAULT_GIT_REMOTE below.

This also fixes the brew doctor issue for new homebrew-core Linux installations

Warning: Suspicious https://github.com/Homebrew/linuxbrew-core git origin remote found.
The current git origin is:
  https://github.com/Homebrew/homebrew-core

With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
  git -C "/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core" remote set-url origin https://github.com/Homebrew/linuxbrew-core
This commit is contained in:
Michka Popoff 2021-08-29 21:40:35 +02:00
parent d429780e3f
commit 4ef058412c
No known key found for this signature in database
GPG Key ID: 033D03F151030611
8 changed files with 103 additions and 76 deletions

View File

@ -27,7 +27,9 @@ module Homebrew
sig { params(name: String).returns(T.nilable(PkgVersion)) } sig { params(name: String).returns(T.nilable(PkgVersion)) }
def latest_formula_version(name) def latest_formula_version(name)
versions = if OS.mac? || Homebrew::EnvConfig.force_homebrew_on_linux? versions = if OS.mac? ||
Homebrew::EnvConfig.force_homebrew_on_linux? ||
Homebrew::EnvConfig.force_homebrew_core_repo_on_linux?
formulae formulae
else else
linux linux

View File

@ -469,6 +469,17 @@ Your Git executable: $(unset git && type -p ${HOMEBREW_GIT})"
HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION="2.13" HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION="2.13"
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
HOMEBREW_CORE_REPOSITORY_ORIGIN="$("${HOMEBREW_GIT}" -C "${HOMEBREW_CORE_REPOSITORY}" remote get-url origin)"
if [[ "${HOMEBREW_CORE_REPOSITORY_ORIGIN}" = "https://github.com/Homebrew/homebrew-core" ]]
then
# If the remote origin has been set to Homebrew/homebrew-core by the install script,
# then we are in the case of a new installation of brew, using Homebrew/homebrew-core as a Linux core repository.
# In that case, set HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX=1 to set the right HOMEBREW_BOTTLE_DOMAIN below.
# TODO: Once the linuxbrew-core migration is done we will be able to clean this up and
# remove HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX
export HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX="1"
fi
fi fi
# A bug in the auto-update process prior to 3.1.2 means $HOMEBREW_BOTTLE_DOMAIN # A bug in the auto-update process prior to 3.1.2 means $HOMEBREW_BOTTLE_DOMAIN
@ -484,7 +495,7 @@ then
unset HOMEBREW_BOTTLE_DOMAIN unset HOMEBREW_BOTTLE_DOMAIN
fi fi
if [[ -n "${HOMEBREW_MACOS}" || -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" ]] if [[ -n "${HOMEBREW_MACOS}" || -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" || -n "${HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX}" ]]
then then
HOMEBREW_BOTTLE_DEFAULT_DOMAIN="https://ghcr.io/v2/homebrew/core" HOMEBREW_BOTTLE_DEFAULT_DOMAIN="https://ghcr.io/v2/homebrew/core"
else else
@ -624,7 +635,7 @@ then
fi fi
export HOMEBREW_BREW_GIT_REMOTE export HOMEBREW_BREW_GIT_REMOTE
if [[ -n "${HOMEBREW_MACOS}" ]] || [[ -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" ]] if [[ -n "${HOMEBREW_MACOS}" ]] || [[ -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" ]] || [[ -n "${HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX}" ]]
then then
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core" HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
else else

View File

@ -277,6 +277,10 @@ module Homebrew
"when auditing macOS formulae while on Linux. Implies `HOMEBREW_FORCE_HOMEBREW_ON_LINUX`.", "when auditing macOS formulae while on Linux. Implies `HOMEBREW_FORCE_HOMEBREW_ON_LINUX`.",
boolean: true, boolean: true,
}, },
HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX: {
description: "If set, running Homebrew on Linux will use homebrew-core instead of linuxbrew-core.",
boolean: true,
},
HOMEBREW_SKIP_OR_LATER_BOTTLES: { HOMEBREW_SKIP_OR_LATER_BOTTLES: {
description: "If set along with `HOMEBREW_DEVELOPER`, do not use bottles from older versions " \ description: "If set along with `HOMEBREW_DEVELOPER`, do not use bottles from older versions " \
"of macOS. This is useful in development on new macOS versions.", "of macOS. This is useful in development on new macOS versions.",

View File

@ -6,7 +6,9 @@ module Homebrew
module Analytics module Analytics
class << self class << self
def analytics_api_path def analytics_api_path
return generic_analytics_api_path if Homebrew::EnvConfig.force_homebrew_on_linux? return generic_analytics_api_path if
Homebrew::EnvConfig.force_homebrew_on_linux? ||
Homebrew::EnvConfig.force_homebrew_core_repo_on_linux?
"analytics-linux" "analytics-linux"
end end

View File

@ -6,7 +6,9 @@ module Homebrew
module Bottle module Bottle
class << self class << self
def bottle_api_path def bottle_api_path
return generic_bottle_api_path if Homebrew::EnvConfig.force_homebrew_on_linux? return generic_bottle_api_path if
Homebrew::EnvConfig.force_homebrew_on_linux? ||
Homebrew::EnvConfig.force_homebrew_core_repo_on_linux?
"bottle-linux" "bottle-linux"
end end

View File

@ -6,7 +6,9 @@ module Homebrew
module Formula module Formula
class << self class << self
def formula_api_path def formula_api_path
return generic_formula_api_path if Homebrew::EnvConfig.force_homebrew_on_linux? return generic_formula_api_path if
Homebrew::EnvConfig.force_homebrew_on_linux? ||
Homebrew::EnvConfig.force_homebrew_core_repo_on_linux?
"formula-linux" "formula-linux"
end end

View File

@ -5,6 +5,8 @@ class CoreTap < Tap
# @private # @private
def initialize def initialize
super "Homebrew", "core" super "Homebrew", "core"
@full_name = "Homebrew/linuxbrew-core" unless Homebrew::EnvConfig.force_homebrew_on_linux? @full_name = "Homebrew/linuxbrew-core" if
!Homebrew::EnvConfig.force_homebrew_on_linux? &&
!Homebrew::EnvConfig.force_homebrew_core_repo_on_linux?
end end
end end

View File

@ -9817,6 +9817,8 @@ module Homebrew::EnvConfig
def self.force_homebrew_on_linux?(); end def self.force_homebrew_on_linux?(); end
def self.force_homebrew_core_repo_on_linux?(); end
def self.force_vendor_ruby?(); end def self.force_vendor_ruby?(); end
def self.ftp_proxy(); end def self.ftp_proxy(); end