Relocate @@HOMEBREW_REPOSITORY@@/Library

Ensure that $HOMEBREW_REPOSITORY/Library is relocated to
@@HOMEBREW_REPOSITORY@@/Library even when
HOMEBREW_PREFIX = HOMEBREW_REPOSITORY.
This commit is contained in:
Shaun Jackman 2020-12-10 10:16:26 -08:00
parent d73fc480a7
commit 4edf28409d

View File

@ -5,9 +5,10 @@ class Keg
PREFIX_PLACEHOLDER = "@@HOMEBREW_PREFIX@@"
CELLAR_PLACEHOLDER = "@@HOMEBREW_CELLAR@@"
REPOSITORY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@"
LIBRARY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@/Library"
Relocation = Struct.new(:old_prefix, :old_cellar, :old_repository,
:new_prefix, :new_cellar, :new_repository) do
Relocation = Struct.new(:old_prefix, :old_cellar, :old_repository, :old_library,
:new_prefix, :new_cellar, :new_repository, :new_library) do
# Use keyword args instead of positional args for initialization.
def initialize(**kwargs)
super(*members.map { |k| kwargs[k] })
@ -40,9 +41,11 @@ class Keg
old_prefix: HOMEBREW_PREFIX.to_s,
old_cellar: HOMEBREW_CELLAR.to_s,
old_repository: HOMEBREW_REPOSITORY.to_s,
old_library: HOMEBREW_LIBRARY.to_s,
new_prefix: PREFIX_PLACEHOLDER,
new_cellar: CELLAR_PLACEHOLDER,
new_repository: REPOSITORY_PLACEHOLDER,
new_library: LIBRARY_PLACEHOLDER,
)
relocate_dynamic_linkage(relocation)
replace_text_in_files(relocation)
@ -53,9 +56,11 @@ class Keg
old_prefix: PREFIX_PLACEHOLDER,
old_cellar: CELLAR_PLACEHOLDER,
old_repository: REPOSITORY_PLACEHOLDER,
old_library: LIBRARY_PLACEHOLDER,
new_prefix: HOMEBREW_PREFIX.to_s,
new_cellar: HOMEBREW_CELLAR.to_s,
new_repository: HOMEBREW_REPOSITORY.to_s,
new_library: HOMEBREW_LIBRARY.to_s,
)
relocate_dynamic_linkage(relocation) unless skip_linkage
replace_text_in_files(relocation, files: files)
@ -71,6 +76,7 @@ class Keg
replacements = {
relocation.old_prefix => relocation.new_prefix,
relocation.old_cellar => relocation.new_cellar,
relocation.old_library => relocation.new_library,
}
# when HOMEBREW_PREFIX == HOMEBREW_REPOSITORY we should use HOMEBREW_PREFIX for all relocations to avoid
# being unable to differentiate between them.