Merge pull request #12334 from carlocab/java-relocation
keg_relocate: handle `JAVA_HOME`
This commit is contained in:
commit
d810f4aa72
@ -172,6 +172,11 @@ class Keg
|
||||
end
|
||||
relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, perl_path)
|
||||
|
||||
if (openjdk = openjdk_dep_name_if_applicable)
|
||||
openjdk_path = HOMEBREW_PREFIX/"opt"/openjdk/"libexec/openjdk.jdk/Contents/Home"
|
||||
relocation.add_replacement_pair(:java, JAVA_PLACEHOLDER, openjdk_path.to_s)
|
||||
end
|
||||
|
||||
relocation
|
||||
end
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ class Keg
|
||||
REPOSITORY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@"
|
||||
LIBRARY_PLACEHOLDER = "@@HOMEBREW_LIBRARY@@"
|
||||
PERL_PLACEHOLDER = "@@HOMEBREW_PERL@@"
|
||||
JAVA_PLACEHOLDER = "@@HOMEBREW_JAVA@@"
|
||||
|
||||
class Relocation
|
||||
extend T::Sig
|
||||
@ -82,6 +83,8 @@ class Keg
|
||||
[]
|
||||
end
|
||||
|
||||
JAVA_REGEX = %r{#{HOMEBREW_PREFIX}/opt/openjdk(@\d+(\.\d+)*)?/libexec(/openjdk\.jdk/Contents/Home)?}.freeze
|
||||
|
||||
def prepare_relocation_to_placeholders
|
||||
relocation = Relocation.new
|
||||
relocation.add_replacement_pair(:prefix, HOMEBREW_PREFIX.to_s, PREFIX_PLACEHOLDER, path: true)
|
||||
@ -95,6 +98,8 @@ class Keg
|
||||
relocation.add_replacement_pair(:perl,
|
||||
%r{\A#!(?:/usr/bin/perl\d\.\d+|#{HOMEBREW_PREFIX}/opt/perl/bin/perl)( |$)}o,
|
||||
"#!#{PERL_PLACEHOLDER}\\1")
|
||||
# TODO: Enable relocation upon bottling when relocation upon pouring is in a brew release tag.
|
||||
# relocation.add_replacement_pair(:java, JAVA_REGEX, JAVA_PLACEHOLDER)
|
||||
relocation
|
||||
end
|
||||
alias generic_prepare_relocation_to_placeholders prepare_relocation_to_placeholders
|
||||
@ -112,6 +117,10 @@ class Keg
|
||||
relocation.add_replacement_pair(:repository, REPOSITORY_PLACEHOLDER, HOMEBREW_REPOSITORY.to_s)
|
||||
relocation.add_replacement_pair(:library, LIBRARY_PLACEHOLDER, HOMEBREW_LIBRARY.to_s)
|
||||
relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, "#{HOMEBREW_PREFIX}/opt/perl/bin/perl")
|
||||
if (openjdk = openjdk_dep_name_if_applicable)
|
||||
relocation.add_replacement_pair(:java, JAVA_PLACEHOLDER, "#{HOMEBREW_PREFIX}/opt/#{openjdk}/libexec")
|
||||
end
|
||||
|
||||
relocation
|
||||
end
|
||||
alias generic_prepare_relocation_to_locations prepare_relocation_to_locations
|
||||
@ -122,6 +131,14 @@ class Keg
|
||||
replace_text_in_files(relocation, files: files)
|
||||
end
|
||||
|
||||
def openjdk_dep_name_if_applicable
|
||||
deps = runtime_dependencies
|
||||
return if deps.blank?
|
||||
|
||||
dep_names = deps.map { |d| d["full_name"] }
|
||||
dep_names.find { |d| d.match? Version.formula_optionally_versioned_regex(:openjdk) }
|
||||
end
|
||||
|
||||
def replace_text_in_files(relocation, files: nil)
|
||||
files ||= text_files | libtool_files
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user