From 70bc181029164a037e5ec327b3a4e168126866b3 Mon Sep 17 00:00:00 2001 From: danielnachun Date: Mon, 6 Dec 2021 02:10:55 -0800 Subject: [PATCH] software_spec.rb: change compatible_location --- Library/Homebrew/software_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index f6eb79b225..e3e549fa23 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -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