Merge pull request #10044 from MikeMcQuaid/more_bottle_library_changes
More bottling HOMEBREW_LIBRARY changes
This commit is contained in:
commit
6fc1570134
@ -254,7 +254,6 @@ module Homebrew
|
|||||||
tar_path = Pathname.pwd/tar_filename
|
tar_path = Pathname.pwd/tar_filename
|
||||||
|
|
||||||
prefix = HOMEBREW_PREFIX.to_s
|
prefix = HOMEBREW_PREFIX.to_s
|
||||||
repository = HOMEBREW_REPOSITORY.to_s
|
|
||||||
cellar = HOMEBREW_CELLAR.to_s
|
cellar = HOMEBREW_CELLAR.to_s
|
||||||
|
|
||||||
ohai "Bottling #{filename}..."
|
ohai "Bottling #{filename}..."
|
||||||
@ -326,13 +325,24 @@ module Homebrew
|
|||||||
ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/#{go_regex}/[\d.]+/libexec}
|
ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/#{go_regex}/[\d.]+/libexec}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
repository_reference = if HOMEBREW_PREFIX == HOMEBREW_REPOSITORY
|
||||||
|
HOMEBREW_LIBRARY
|
||||||
|
else
|
||||||
|
HOMEBREW_REPOSITORY
|
||||||
|
end.to_s
|
||||||
|
if keg_contain?(repository_reference, keg, ignores, args: args)
|
||||||
|
odie "Bottle contains non-relocatable reference to #{repository_reference}!"
|
||||||
|
end
|
||||||
|
|
||||||
relocatable = true
|
relocatable = true
|
||||||
if args.skip_relocation?
|
if args.skip_relocation?
|
||||||
skip_relocation = true
|
skip_relocation = true
|
||||||
else
|
else
|
||||||
relocatable = false if keg_contain?(prefix_check, keg, ignores, formula_and_runtime_deps_names, args: args)
|
relocatable = false if keg_contain?(prefix_check, keg, ignores, formula_and_runtime_deps_names, args: args)
|
||||||
relocatable = false if keg_contain?(repository, keg, ignores, args: args)
|
|
||||||
relocatable = false if keg_contain?(cellar, keg, ignores, formula_and_runtime_deps_names, args: args)
|
relocatable = false if keg_contain?(cellar, keg, ignores, formula_and_runtime_deps_names, args: args)
|
||||||
|
if keg_contain?(HOMEBREW_LIBRARY.to_s, keg, ignores, formula_and_runtime_deps_names, args: args)
|
||||||
|
relocatable = false
|
||||||
|
end
|
||||||
if prefix != prefix_check
|
if prefix != prefix_check
|
||||||
relocatable = false if keg_contain_absolute_symlink_starting_with?(prefix, keg, args: args)
|
relocatable = false if keg_contain_absolute_symlink_starting_with?(prefix, keg, args: args)
|
||||||
relocatable = false if keg_contain?("#{prefix}/etc", keg, ignores, args: args)
|
relocatable = false if keg_contain?("#{prefix}/etc", keg, ignores, args: args)
|
||||||
|
|||||||
@ -7,10 +7,6 @@ require "utils/shell"
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module FormulaCellarChecks
|
module FormulaCellarChecks
|
||||||
# If the location of HOMEBREW_LIBRARY changes
|
|
||||||
# keg_relocate.rb, test/global_spec.rb, and this constant need to change.
|
|
||||||
REPOSITORY_AND_NOT_LIBRARY_REGEX = %r{#{HOMEBREW_REPOSITORY}(?!/Library/)}.freeze
|
|
||||||
|
|
||||||
def check_env_path(bin)
|
def check_env_path(bin)
|
||||||
# warn the user if stuff was installed outside of their PATH
|
# warn the user if stuff was installed outside of their PATH
|
||||||
return unless bin.directory?
|
return unless bin.directory?
|
||||||
@ -211,26 +207,6 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_repository_references(prefix)
|
|
||||||
return if HOMEBREW_PREFIX != HOMEBREW_REPOSITORY
|
|
||||||
return unless prefix.directory?
|
|
||||||
|
|
||||||
keg = Keg.new(prefix)
|
|
||||||
|
|
||||||
matches = []
|
|
||||||
keg.each_unique_file_matching(HOMEBREW_REPOSITORY) do |f|
|
|
||||||
matches << f.relative_path_from(keg.to_path) if f.read.match? REPOSITORY_AND_NOT_LIBRARY_REGEX
|
|
||||||
end
|
|
||||||
|
|
||||||
return if matches.empty?
|
|
||||||
|
|
||||||
<<~EOS
|
|
||||||
Files were found with references to the Homebrew repository directory
|
|
||||||
that are outside of the Library directory. The offending files are:
|
|
||||||
#{matches * "\n "}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_shim_references(prefix)
|
def check_shim_references(prefix)
|
||||||
return unless prefix.directory?
|
return unless prefix.directory?
|
||||||
|
|
||||||
@ -316,7 +292,6 @@ module FormulaCellarChecks
|
|||||||
problem_if_output(check_elisp_dirname(formula.share, formula.name))
|
problem_if_output(check_elisp_dirname(formula.share, formula.name))
|
||||||
problem_if_output(check_elisp_root(formula.share, formula.name))
|
problem_if_output(check_elisp_root(formula.share, formula.name))
|
||||||
problem_if_output(check_python_packages(formula.lib, formula.deps))
|
problem_if_output(check_python_packages(formula.lib, formula.deps))
|
||||||
problem_if_output(check_repository_references(formula.prefix))
|
|
||||||
problem_if_output(check_shim_references(formula.prefix))
|
problem_if_output(check_shim_references(formula.prefix))
|
||||||
problem_if_output(check_plist(formula.prefix, formula.plist))
|
problem_if_output(check_plist(formula.prefix, formula.plist))
|
||||||
problem_if_output(check_python_symlinks(formula.name, formula.keg_only?))
|
problem_if_output(check_python_symlinks(formula.name, formula.keg_only?))
|
||||||
|
|||||||
@ -175,6 +175,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
bottle = formula.bottle_specification
|
bottle = formula.bottle_specification
|
||||||
unless bottle.compatible_locations?
|
unless bottle.compatible_locations?
|
||||||
|
# TODO: delete HOMEBREW_REPOSITORY reference after Homebrew 2.7.0 is released.
|
||||||
if output_warning
|
if output_warning
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
Building #{formula.full_name} from source as the bottle needs:
|
Building #{formula.full_name} from source as the bottle needs:
|
||||||
|
|||||||
@ -5,13 +5,15 @@ class Keg
|
|||||||
PREFIX_PLACEHOLDER = "@@HOMEBREW_PREFIX@@"
|
PREFIX_PLACEHOLDER = "@@HOMEBREW_PREFIX@@"
|
||||||
CELLAR_PLACEHOLDER = "@@HOMEBREW_CELLAR@@"
|
CELLAR_PLACEHOLDER = "@@HOMEBREW_CELLAR@@"
|
||||||
REPOSITORY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@"
|
REPOSITORY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@"
|
||||||
|
LIBRARY_PLACEHOLDER = "@@HOMEBREW_LIBRARY@@"
|
||||||
|
|
||||||
# If the location of HOMEBREW_LIBRARY changes
|
# TODO: delete this after Homebrew 2.7.0 is released.
|
||||||
# formula_cellar_checks.rb, test/global_spec.rb, and this constant need to change.
|
REPOSITORY_LIBRARY_PLACEHOLDER = "#{REPOSITORY_PLACEHOLDER}/Library"
|
||||||
LIBRARY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@/Library"
|
|
||||||
|
|
||||||
Relocation = Struct.new(:old_prefix, :old_cellar, :old_repository, :old_library,
|
Relocation = Struct.new(:old_prefix, :old_cellar, :old_repository, :old_library,
|
||||||
:new_prefix, :new_cellar, :new_repository, :new_library) do
|
:new_prefix, :new_cellar, :new_repository, :new_library,
|
||||||
|
# TODO: delete these after Homebrew 2.7.0 is released.
|
||||||
|
:old_repository_library, :new_repository_library) do
|
||||||
# Use keyword args instead of positional args for initialization.
|
# Use keyword args instead of positional args for initialization.
|
||||||
def initialize(**kwargs)
|
def initialize(**kwargs)
|
||||||
super(*members.map { |k| kwargs[k] })
|
super(*members.map { |k| kwargs[k] })
|
||||||
@ -43,12 +45,16 @@ class Keg
|
|||||||
relocation = Relocation.new(
|
relocation = Relocation.new(
|
||||||
old_prefix: HOMEBREW_PREFIX.to_s,
|
old_prefix: HOMEBREW_PREFIX.to_s,
|
||||||
old_cellar: HOMEBREW_CELLAR.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_prefix: PREFIX_PLACEHOLDER,
|
||||||
new_cellar: CELLAR_PLACEHOLDER,
|
new_cellar: CELLAR_PLACEHOLDER,
|
||||||
|
# TODO: delete these after Homebrew 2.7.0 is released.
|
||||||
|
old_library: HOMEBREW_LIBRARY.to_s,
|
||||||
|
new_library: REPOSITORY_LIBRARY_PLACEHOLDER,
|
||||||
|
old_repository: HOMEBREW_REPOSITORY.to_s,
|
||||||
new_repository: REPOSITORY_PLACEHOLDER,
|
new_repository: REPOSITORY_PLACEHOLDER,
|
||||||
new_library: LIBRARY_PLACEHOLDER,
|
# TODO: add these after Homebrew 2.7.0 is released.
|
||||||
|
# old_library: HOMEBREW_LIBRARY.to_s,
|
||||||
|
# new_library: LIBRARY_PLACEHOLDER,
|
||||||
)
|
)
|
||||||
relocate_dynamic_linkage(relocation)
|
relocate_dynamic_linkage(relocation)
|
||||||
replace_text_in_files(relocation)
|
replace_text_in_files(relocation)
|
||||||
@ -56,14 +62,17 @@ class Keg
|
|||||||
|
|
||||||
def replace_placeholders_with_locations(files, skip_linkage: false)
|
def replace_placeholders_with_locations(files, skip_linkage: false)
|
||||||
relocation = Relocation.new(
|
relocation = Relocation.new(
|
||||||
old_prefix: PREFIX_PLACEHOLDER,
|
old_prefix: PREFIX_PLACEHOLDER,
|
||||||
old_cellar: CELLAR_PLACEHOLDER,
|
old_cellar: CELLAR_PLACEHOLDER,
|
||||||
old_repository: REPOSITORY_PLACEHOLDER,
|
old_repository: REPOSITORY_PLACEHOLDER,
|
||||||
old_library: LIBRARY_PLACEHOLDER,
|
old_library: LIBRARY_PLACEHOLDER,
|
||||||
new_prefix: HOMEBREW_PREFIX.to_s,
|
new_prefix: HOMEBREW_PREFIX.to_s,
|
||||||
new_cellar: HOMEBREW_CELLAR.to_s,
|
new_cellar: HOMEBREW_CELLAR.to_s,
|
||||||
new_repository: HOMEBREW_REPOSITORY.to_s,
|
new_repository: HOMEBREW_REPOSITORY.to_s,
|
||||||
new_library: HOMEBREW_LIBRARY.to_s,
|
new_library: HOMEBREW_LIBRARY.to_s,
|
||||||
|
# TODO: delete these after Homebrew 2.7.0 is released.
|
||||||
|
old_repository_library: REPOSITORY_LIBRARY_PLACEHOLDER,
|
||||||
|
new_repository_library: HOMEBREW_LIBRARY.to_s,
|
||||||
)
|
)
|
||||||
relocate_dynamic_linkage(relocation) unless skip_linkage
|
relocate_dynamic_linkage(relocation) unless skip_linkage
|
||||||
replace_text_in_files(relocation, files: files)
|
replace_text_in_files(relocation, files: files)
|
||||||
@ -77,16 +86,15 @@ 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_library => relocation.new_library,
|
||||||
|
# TODO: delete this after Homebrew 2.7.0 is released.
|
||||||
|
relocation.old_repository_library => relocation.new_repository_library,
|
||||||
|
}.compact
|
||||||
# when HOMEBREW_PREFIX == HOMEBREW_REPOSITORY we should use HOMEBREW_PREFIX for all relocations to avoid
|
# when HOMEBREW_PREFIX == HOMEBREW_REPOSITORY we should use HOMEBREW_PREFIX for all relocations to avoid
|
||||||
# being unable to differentiate between them.
|
# being unable to differentiate between them.
|
||||||
if HOMEBREW_PREFIX == HOMEBREW_REPOSITORY
|
replacements[relocation.old_repository] = relocation.new_repository if HOMEBREW_PREFIX != HOMEBREW_REPOSITORY
|
||||||
replacements[relocation.old_library] = relocation.new_library
|
|
||||||
else
|
|
||||||
replacements[relocation.old_repository] = relocation.new_repository
|
|
||||||
end
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@ -389,6 +389,7 @@ class BottleSpecification
|
|||||||
# Only check the repository matches if the prefix is the default.
|
# Only check the repository matches if the prefix is the default.
|
||||||
# This is because the bottle DSL does not allow setting a custom repository
|
# This is because the bottle DSL does not allow setting a custom repository
|
||||||
# but does allow setting a custom prefix.
|
# but does allow setting a custom prefix.
|
||||||
|
# TODO: delete this after Homebrew 2.7.0 is released.
|
||||||
compatible_repository = if Homebrew.default_prefix?(prefix)
|
compatible_repository = if Homebrew.default_prefix?(prefix)
|
||||||
repository == HOMEBREW_REPOSITORY.to_s
|
repository == HOMEBREW_REPOSITORY.to_s
|
||||||
else
|
else
|
||||||
|
|||||||
@ -8,10 +8,4 @@ describe "brew", :integration_test do
|
|||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
end
|
||||||
|
|
||||||
# If the location of HOMEBREW_LIBRARY changes
|
|
||||||
# keg_relocate.rb, formula_cellar_checks.rb, and this test need to change.
|
|
||||||
it "ensures that HOMEBREW_LIBRARY=HOMEBREW_REPOSITORY/Library" do
|
|
||||||
expect(HOMEBREW_LIBRARY.to_s).to eq("#{HOMEBREW_REPOSITORY}/Library")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user