Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brew.sh: set HOMEBREW_FORCE_HOMEBREW_ON_LINUX when core repo is homeb… #11938

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Library/Homebrew/api/versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def casks

sig { params(name: String).returns(T.nilable(PkgVersion)) }
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
else
linux
Expand Down
15 changes: 13 additions & 2 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,17 @@ Your Git executable: $(unset git && type -p ${HOMEBREW_GIT})"

HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION="2.13"
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

# A bug in the auto-update process prior to 3.1.2 means $HOMEBREW_BOTTLE_DOMAIN
Expand All @@ -484,7 +495,7 @@ then
unset HOMEBREW_BOTTLE_DOMAIN
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
HOMEBREW_BOTTLE_DEFAULT_DOMAIN="https://ghcr.io/v2/homebrew/core"
else
Expand Down Expand Up @@ -624,7 +635,7 @@ then
fi
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
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
else
Expand Down
142 changes: 73 additions & 69 deletions Library/Homebrew/env_config.rb

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Library/Homebrew/extend/os/linux/api/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module API
module Analytics
class << self
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"
end
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/os/linux/api/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module API
module Bottle
class << self
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"
end
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/os/linux/api/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module API
module Formula
class << self
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"
end
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/os/linux/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class CoreTap < Tap
# @private
def initialize
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
2 changes: 2 additions & 0 deletions Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -9817,6 +9817,8 @@ module Homebrew::EnvConfig

def self.force_homebrew_on_linux?(); end

def self.force_homebrew_core_repo_on_linux?(); end

def self.force_vendor_ruby?(); end

def self.ftp_proxy(); end
Expand Down