software_spec.rb: change compatible_location

This commit is contained in:
danielnachun 2021-12-06 02:10:55 -08:00
parent 4de01663bc
commit ae1c5c8054
No known key found for this signature in database
GPG Key ID: 7343CCAD07E2D0FB

View File

@ -473,6 +473,8 @@ class Bottle
end
class BottleSpecification
RELOCATABLE_CELLARS = [:any, :any_skip_relocation].freeze
extend T::Sig
attr_rw :rebuild
@ -518,12 +520,15 @@ class BottleSpecification
def compatible_locations?(tag: Utils::Bottles.tag)
cellar = tag_to_cellar(tag)
return true if [:any, :any_skip_relocation].include?(cellar)
return true if RELOCATABLE_CELLARS.include?(cellar)
prefix = Pathname(cellar).parent.to_s
compatible_cellar = cellar == HOMEBREW_CELLAR.to_s
compatible_prefix = prefix == HOMEBREW_PREFIX.to_s
cellar_relocatable = cellar.size >= HOMEBREW_CELLAR.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"]
prefix_relocatable = prefix.size >= HOMEBREW_PREFIX.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"]
compatible_cellar = cellar == HOMEBREW_CELLAR.to_s || cellar_relocatable
compatible_prefix = prefix == HOMEBREW_PREFIX.to_s || prefix_relocatable
compatible_cellar && compatible_prefix
end