Merge pull request #9481 from MikeMcQuaid/bottle_prefix_repository_handling
Fix bottle prefix and repository handling
This commit is contained in:
commit
2c77a540b5
@ -13,7 +13,7 @@ module Homebrew
|
|||||||
return true if args.force_bottle? && bottle
|
return true if args.force_bottle? && bottle
|
||||||
return false unless bottle && f.pour_bottle?
|
return false unless bottle && f.pour_bottle?
|
||||||
return false if args.build_from_source_formulae.include?(f.full_name)
|
return false if args.build_from_source_formulae.include?(f.full_name)
|
||||||
return false unless bottle.compatible_cellar?
|
return false unless bottle.compatible_locations?
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -343,6 +343,7 @@ class Formula
|
|||||||
:bottle_disabled?,
|
:bottle_disabled?,
|
||||||
:bottle_disable_reason,
|
:bottle_disable_reason,
|
||||||
:bottle_defined?,
|
:bottle_defined?,
|
||||||
|
:bottle_tag?,
|
||||||
:bottled?,
|
:bottled?,
|
||||||
:bottle_specification,
|
:bottle_specification,
|
||||||
:downloader,
|
:downloader,
|
||||||
|
|||||||
@ -156,7 +156,7 @@ class FormulaInstaller
|
|||||||
def pour_bottle?(install_bottle_options = { warn: false })
|
def pour_bottle?(install_bottle_options = { warn: false })
|
||||||
return false if @pour_failed
|
return false if @pour_failed
|
||||||
|
|
||||||
return false if !formula.bottled? && !formula.local_bottle_path
|
return false if !formula.bottle_tag? && !formula.local_bottle_path
|
||||||
return true if force_bottle?
|
return true if force_bottle?
|
||||||
return false if build_from_source? || build_bottle? || interactive?
|
return false if build_from_source? || build_bottle? || interactive?
|
||||||
return false if @cc
|
return false if @cc
|
||||||
@ -174,11 +174,13 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
bottle = formula.bottle_specification
|
bottle = formula.bottle_specification
|
||||||
unless bottle.compatible_cellar?
|
unless bottle.compatible_locations?
|
||||||
if install_bottle_options[:warn]
|
if install_bottle_options[:warn]
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
Building #{formula.full_name} from source:
|
Building #{formula.full_name} from source as the bottle needs:
|
||||||
The bottle needs a #{bottle.cellar} Cellar (yours is #{HOMEBREW_CELLAR}).
|
- HOMEBREW_CELLAR: #{bottle.cellar} (yours is #{HOMEBREW_CELLAR})
|
||||||
|
- HOMEBREW_PREFIX: #{bottle.prefix} (yours is #{HOMEBREW_PREFIX})
|
||||||
|
- HOMEBREW_REPOSITORY: #{bottle.repository} (yours is #{HOMEBREW_REPOSITORY})
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -193,7 +195,7 @@ class FormulaInstaller
|
|||||||
return false if @build_from_source_formulae.include?(dep.full_name)
|
return false if @build_from_source_formulae.include?(dep.full_name)
|
||||||
return false unless dep.bottle && dep.pour_bottle?
|
return false unless dep.bottle && dep.pour_bottle?
|
||||||
return false unless build.used_options.empty?
|
return false unless build.used_options.empty?
|
||||||
return false unless dep.bottle&.compatible_cellar?
|
return false unless dep.bottle&.compatible_locations?
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -61,8 +61,11 @@ HOMEBREW_USER_AGENT_FAKE_SAFARI =
|
|||||||
"(KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
|
"(KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
|
||||||
|
|
||||||
HOMEBREW_DEFAULT_PREFIX = "/usr/local"
|
HOMEBREW_DEFAULT_PREFIX = "/usr/local"
|
||||||
|
HOMEBREW_DEFAULT_REPOSITORY = "#{HOMEBREW_DEFAULT_PREFIX}/Homebrew"
|
||||||
HOMEBREW_MACOS_ARM_DEFAULT_PREFIX = "/opt/homebrew"
|
HOMEBREW_MACOS_ARM_DEFAULT_PREFIX = "/opt/homebrew"
|
||||||
|
HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY = HOMEBREW_MACOS_ARM_DEFAULT_PREFIX
|
||||||
HOMEBREW_LINUX_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew"
|
HOMEBREW_LINUX_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew"
|
||||||
|
HOMEBREW_LINUX_DEFAULT_REPOSITORY = "#{HOMEBREW_LINUX_DEFAULT_PREFIX}/Homebrew"
|
||||||
|
|
||||||
HOMEBREW_PULL_API_REGEX =
|
HOMEBREW_PULL_API_REGEX =
|
||||||
%r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}.freeze
|
%r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}.freeze
|
||||||
@ -81,11 +84,11 @@ module Homebrew
|
|||||||
extend FileUtils
|
extend FileUtils
|
||||||
|
|
||||||
DEFAULT_PREFIX ||= HOMEBREW_DEFAULT_PREFIX
|
DEFAULT_PREFIX ||= HOMEBREW_DEFAULT_PREFIX
|
||||||
|
DEFAULT_REPOSITORY ||= HOMEBREW_DEFAULT_REPOSITORY
|
||||||
DEFAULT_CELLAR = "#{DEFAULT_PREFIX}/Cellar"
|
DEFAULT_CELLAR = "#{DEFAULT_PREFIX}/Cellar"
|
||||||
DEFAULT_MACOS_CELLAR = "#{HOMEBREW_DEFAULT_PREFIX}/Cellar"
|
DEFAULT_MACOS_CELLAR = "#{HOMEBREW_DEFAULT_PREFIX}/Cellar"
|
||||||
DEFAULT_MACOS_ARM_CELLAR = "#{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}/Cellar"
|
DEFAULT_MACOS_ARM_CELLAR = "#{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}/Cellar"
|
||||||
DEFAULT_LINUX_CELLAR = "#{HOMEBREW_LINUX_DEFAULT_PREFIX}/Cellar"
|
DEFAULT_LINUX_CELLAR = "#{HOMEBREW_LINUX_DEFAULT_PREFIX}/Cellar"
|
||||||
DEFAULT_REPOSITORY = "#{DEFAULT_PREFIX}/Homebrew"
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_writer :failed, :raise_deprecation_exceptions, :auditing
|
attr_writer :failed, :raise_deprecation_exceptions, :auditing
|
||||||
|
|||||||
@ -69,10 +69,12 @@ class Keg
|
|||||||
s = first.open("rb", &:read)
|
s = first.open("rb", &:read)
|
||||||
|
|
||||||
replacements = {
|
replacements = {
|
||||||
relocation.old_prefix => relocation.new_prefix,
|
relocation.old_prefix => relocation.new_prefix,
|
||||||
relocation.old_cellar => relocation.new_cellar,
|
relocation.old_cellar => relocation.new_cellar,
|
||||||
relocation.old_repository => relocation.new_repository,
|
|
||||||
}
|
}
|
||||||
|
# when HOMEBREW_PREFIX == HOMEBREW_REPOSITORY we should use HOMEBREW_PREFIX for all relocations to avoid
|
||||||
|
# being unable to differentiate between them.
|
||||||
|
replacements[relocation.old_repository] = relocation.new_repository if HOMEBREW_PREFIX != HOMEBREW_REPOSITORY
|
||||||
changed = s.gsub!(Regexp.union(replacements.keys.sort_by(&:length).reverse), replacements)
|
changed = s.gsub!(Regexp.union(replacements.keys.sort_by(&:length).reverse), replacements)
|
||||||
next unless changed
|
next unless changed
|
||||||
|
|
||||||
|
|||||||
@ -10,9 +10,11 @@ HOMEBREW_PATCHELF_RB_WRITE = (
|
|||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
DEFAULT_PREFIX ||= if EnvConfig.force_homebrew_on_linux?
|
if EnvConfig.force_homebrew_on_linux?
|
||||||
HOMEBREW_DEFAULT_PREFIX
|
DEFAULT_PREFIX ||= HOMEBREW_DEFAULT_PREFIX.freeze
|
||||||
|
DEFAULT_REPOSITORY ||= HOMEBREW_DEFAULT_REPOSITORY.freeze
|
||||||
else
|
else
|
||||||
HOMEBREW_LINUX_DEFAULT_PREFIX
|
DEFAULT_PREFIX ||= HOMEBREW_LINUX_DEFAULT_PREFIX.freeze
|
||||||
end.freeze
|
DEFAULT_REPOSITORY ||= HOMEBREW_LINUX_DEFAULT_REPOSITORY.freeze
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,9 +2,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
DEFAULT_PREFIX ||= if Hardware::CPU.arm?
|
if Hardware::CPU.arm?
|
||||||
HOMEBREW_MACOS_ARM_DEFAULT_PREFIX
|
DEFAULT_PREFIX ||= HOMEBREW_MACOS_ARM_DEFAULT_PREFIX.freeze
|
||||||
|
DEFAULT_REPOSITORY ||= HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY.freeze
|
||||||
else
|
else
|
||||||
HOMEBREW_DEFAULT_PREFIX
|
DEFAULT_PREFIX ||= HOMEBREW_DEFAULT_PREFIX.freeze
|
||||||
end.freeze
|
DEFAULT_REPOSITORY ||= HOMEBREW_DEFAULT_REPOSITORY.freeze
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -93,9 +93,13 @@ class SoftwareSpec
|
|||||||
!bottle_specification.collector.keys.empty?
|
!bottle_specification.collector.keys.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bottle_tag?
|
||||||
|
bottle_specification.tag?(Utils::Bottles.tag)
|
||||||
|
end
|
||||||
|
|
||||||
def bottled?
|
def bottled?
|
||||||
bottle_specification.tag?(Utils::Bottles.tag) && \
|
bottle_tag? && \
|
||||||
(bottle_specification.compatible_cellar? || owner.force_bottle)
|
(bottle_specification.compatible_locations? || owner.force_bottle)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle(disable_type = nil, disable_reason = nil, &block)
|
def bottle(disable_type = nil, disable_reason = nil, &block)
|
||||||
@ -317,8 +321,8 @@ class Bottle
|
|||||||
@rebuild = spec.rebuild
|
@rebuild = spec.rebuild
|
||||||
end
|
end
|
||||||
|
|
||||||
def compatible_cellar?
|
def compatible_locations?
|
||||||
@spec.compatible_cellar?
|
@spec.compatible_locations?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Does the bottle need to be relocated?
|
# Does the bottle need to be relocated?
|
||||||
@ -341,17 +345,16 @@ end
|
|||||||
class BottleSpecification
|
class BottleSpecification
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
|
|
||||||
DEFAULT_PREFIX = Homebrew::DEFAULT_PREFIX
|
|
||||||
|
|
||||||
attr_rw :prefix, :cellar, :rebuild
|
attr_rw :prefix, :cellar, :rebuild
|
||||||
attr_accessor :tap
|
attr_accessor :tap
|
||||||
attr_reader :checksum, :collector, :root_url_specs
|
attr_reader :checksum, :collector, :root_url_specs, :repository
|
||||||
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def initialize
|
def initialize
|
||||||
@rebuild = 0
|
@rebuild = 0
|
||||||
@prefix = Homebrew::DEFAULT_PREFIX
|
@prefix = Homebrew::DEFAULT_PREFIX
|
||||||
@cellar = Homebrew::DEFAULT_CELLAR
|
@cellar = Homebrew::DEFAULT_CELLAR
|
||||||
|
@repository = Homebrew::DEFAULT_REPOSITORY
|
||||||
@collector = Utils::Bottles::Collector.new
|
@collector = Utils::Bottles::Collector.new
|
||||||
@root_url_specs = {}
|
@root_url_specs = {}
|
||||||
end
|
end
|
||||||
@ -365,8 +368,23 @@ class BottleSpecification
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def compatible_cellar?
|
def compatible_locations?
|
||||||
cellar == :any || cellar == :any_skip_relocation || cellar == HOMEBREW_CELLAR.to_s
|
compatible_cellar = cellar == :any ||
|
||||||
|
cellar == :any_skip_relocation ||
|
||||||
|
cellar == HOMEBREW_CELLAR.to_s
|
||||||
|
|
||||||
|
compatible_prefix = prefix == HOMEBREW_PREFIX.to_s
|
||||||
|
|
||||||
|
# Only check the repository matches if the prefix is the default.
|
||||||
|
# This is because the bottle DSL does not allow setting a custom repository
|
||||||
|
# but does allow setting a custom prefix.
|
||||||
|
compatible_repository = if prefix == Homebrew::DEFAULT_PREFIX
|
||||||
|
repository == HOMEBREW_REPOSITORY.to_s
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
compatible_cellar && compatible_prefix && compatible_repository
|
||||||
end
|
end
|
||||||
|
|
||||||
# Does the {Bottle} this {BottleSpecification} belongs to need to be relocated?
|
# Does the {Bottle} this {BottleSpecification} belongs to need to be relocated?
|
||||||
|
|||||||
@ -8118,6 +8118,7 @@ class HeadVersion
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
DEFAULT_REPOSITORY = ::T.let(nil, ::T.untyped)
|
||||||
MAX_PORT = ::T.let(nil, ::T.untyped)
|
MAX_PORT = ::T.let(nil, ::T.untyped)
|
||||||
MIN_PORT = ::T.let(nil, ::T.untyped)
|
MIN_PORT = ::T.let(nil, ::T.untyped)
|
||||||
end
|
end
|
||||||
@ -13533,14 +13534,17 @@ class Object
|
|||||||
HOMEBREW_DEFAULT_CACHE = ::T.let(nil, ::T.untyped)
|
HOMEBREW_DEFAULT_CACHE = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_DEFAULT_LOGS = ::T.let(nil, ::T.untyped)
|
HOMEBREW_DEFAULT_LOGS = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_DEFAULT_PREFIX = ::T.let(nil, ::T.untyped)
|
HOMEBREW_DEFAULT_PREFIX = ::T.let(nil, ::T.untyped)
|
||||||
|
HOMEBREW_DEFAULT_REPOSITORY = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_DEFAULT_TEMP = ::T.let(nil, ::T.untyped)
|
HOMEBREW_DEFAULT_TEMP = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_LIBRARY = ::T.let(nil, ::T.untyped)
|
HOMEBREW_LIBRARY = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_LIBRARY_PATH = ::T.let(nil, ::T.untyped)
|
HOMEBREW_LIBRARY_PATH = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_LINKED_KEGS = ::T.let(nil, ::T.untyped)
|
HOMEBREW_LINKED_KEGS = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_LINUX_DEFAULT_PREFIX = ::T.let(nil, ::T.untyped)
|
HOMEBREW_LINUX_DEFAULT_PREFIX = ::T.let(nil, ::T.untyped)
|
||||||
|
HOMEBREW_LINUX_DEFAULT_REPOSITORY = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_LOCKS = ::T.let(nil, ::T.untyped)
|
HOMEBREW_LOCKS = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_LOGS = ::T.let(nil, ::T.untyped)
|
HOMEBREW_LOGS = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_MACOS_ARM_DEFAULT_PREFIX = ::T.let(nil, ::T.untyped)
|
HOMEBREW_MACOS_ARM_DEFAULT_PREFIX = ::T.let(nil, ::T.untyped)
|
||||||
|
HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = ::T.let(nil, ::T.untyped)
|
HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_PATCHELF_RB_WRITE = ::T.let(nil, ::T.untyped)
|
HOMEBREW_PATCHELF_RB_WRITE = ::T.let(nil, ::T.untyped)
|
||||||
HOMEBREW_PINNED_KEGS = ::T.let(nil, ::T.untyped)
|
HOMEBREW_PINNED_KEGS = ::T.let(nil, ::T.untyped)
|
||||||
|
|||||||
@ -45,6 +45,7 @@ describe Pathname do
|
|||||||
describe "#patch!" do
|
describe "#patch!" do
|
||||||
# testing only patchelf.rb as HOMEBREW_PREFIX is different for tests,
|
# testing only patchelf.rb as HOMEBREW_PREFIX is different for tests,
|
||||||
# and DevelopmentTools.locate fails to locate patchelf
|
# and DevelopmentTools.locate fails to locate patchelf
|
||||||
|
# TODO: use stub_const("HOMEBREW_PATCHELF_RB_WRITE", true) in tests instead.
|
||||||
HOMEBREW_PATCHELF_RB_WRITE = true
|
HOMEBREW_PATCHELF_RB_WRITE = true
|
||||||
|
|
||||||
let(:placeholder_prefix) { "@@HOMEBREW_PREFIX@@" }
|
let(:placeholder_prefix) { "@@HOMEBREW_PREFIX@@" }
|
||||||
|
|||||||
@ -50,5 +50,9 @@ TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
|
|||||||
|
|
||||||
# For testing's sake always assume the default prefix
|
# For testing's sake always assume the default prefix
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
remove_const :DEFAULT_PREFIX if defined?(DEFAULT_PREFIX)
|
||||||
DEFAULT_PREFIX = HOMEBREW_PREFIX.to_s.freeze
|
DEFAULT_PREFIX = HOMEBREW_PREFIX.to_s.freeze
|
||||||
|
|
||||||
|
remove_const :DEFAULT_REPOSITORY if defined?(DEFAULT_REPOSITORY)
|
||||||
|
DEFAULT_REPOSITORY = HOMEBREW_REPOSITORY.to_s.freeze
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user