Merge pull request #4445 from MikeMcQuaid/rework-link
link: refactor, reorder and fix bugs.
This commit is contained in:
commit
a2b11f25c3
@ -27,49 +27,62 @@ module Homebrew
|
|||||||
|
|
||||||
ARGV.kegs.each do |keg|
|
ARGV.kegs.each do |keg|
|
||||||
keg_only = Formulary.keg_only?(keg.rack)
|
keg_only = Formulary.keg_only?(keg.rack)
|
||||||
if HOMEBREW_PREFIX.to_s == "/usr/local" && keg_only
|
|
||||||
if keg.name.start_with?("openssl", "libressl")
|
|
||||||
opoo <<~EOS
|
|
||||||
Refusing to link: #{keg.name}
|
|
||||||
Linking keg-only #{keg.name} means you may end up linking against the insecure,
|
|
||||||
deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}.
|
|
||||||
Instead, pass the full include/library paths to your compiler e.g.:
|
|
||||||
-I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib
|
|
||||||
EOS
|
|
||||||
next
|
|
||||||
elsif (MacOS.version >= :mojave ||
|
|
||||||
MacOS::Xcode.version >= "10.0" ||
|
|
||||||
MacOS::CLT.version >= "10.0") &&
|
|
||||||
keg.to_formula.keg_only_reason.reason == :provided_by_macos
|
|
||||||
opoo <<~EOS
|
|
||||||
Refusing to link macOS-provided software: #{keg.name}
|
|
||||||
Instead, pass the full include/library paths to your compiler e.g.:
|
|
||||||
-I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib
|
|
||||||
EOS
|
|
||||||
next
|
|
||||||
end
|
|
||||||
elsif keg.linked?
|
|
||||||
opoo "Already linked: #{keg}"
|
|
||||||
puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}"
|
|
||||||
next
|
|
||||||
elsif keg_only && !ARGV.force?
|
|
||||||
opoo "#{keg.name} is keg-only and must be linked with --force"
|
|
||||||
puts "Note that doing so can interfere with building software."
|
|
||||||
puts_keg_only_path_message(keg)
|
|
||||||
next
|
|
||||||
elsif mode.dry_run && mode.overwrite
|
|
||||||
puts "Would remove:"
|
|
||||||
keg.link(mode)
|
|
||||||
|
|
||||||
|
if keg.linked?
|
||||||
|
opoo "Already linked: #{keg}"
|
||||||
|
name_and_flag = if keg_only
|
||||||
|
"--force #{keg.name}"
|
||||||
|
else
|
||||||
|
keg.name
|
||||||
|
end
|
||||||
|
puts "To relink: brew unlink #{keg.name} && brew link #{name_and_flag}"
|
||||||
next
|
next
|
||||||
elsif mode.dry_run
|
end
|
||||||
puts "Would link:"
|
|
||||||
|
if mode.dry_run
|
||||||
|
if mode.overwrite
|
||||||
|
puts "Would remove:"
|
||||||
|
else
|
||||||
|
puts "Would link:"
|
||||||
|
end
|
||||||
keg.link(mode)
|
keg.link(mode)
|
||||||
puts_keg_only_path_message(keg) if keg_only
|
puts_keg_only_path_message(keg) if keg_only
|
||||||
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if keg_only
|
||||||
|
if HOMEBREW_PREFIX.to_s == "/usr/local"
|
||||||
|
if keg.to_formula.keg_only_reason.reason == :provided_by_macos &&
|
||||||
|
(MacOS.version >= :mojave ||
|
||||||
|
MacOS::Xcode.version >= "10.0" ||
|
||||||
|
MacOS::CLT.version >= "10.0")
|
||||||
|
opoo <<~EOS
|
||||||
|
Refusing to link macOS-provided software: #{keg.name}
|
||||||
|
Instead, pass the full include/library paths to your compiler e.g.:
|
||||||
|
-I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib
|
||||||
|
EOS
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
if keg.name.start_with?("openssl", "libressl")
|
||||||
|
opoo <<~EOS
|
||||||
|
Refusing to link: #{keg.name}
|
||||||
|
Linking keg-only #{keg.name} means you may end up linking against the insecure,
|
||||||
|
deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}.
|
||||||
|
Instead, pass the full include/library paths to your compiler e.g.:
|
||||||
|
-I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib
|
||||||
|
EOS
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless ARGV.force?
|
||||||
|
opoo "#{keg.name} is keg-only and must be linked with --force"
|
||||||
|
puts_keg_only_path_message(keg)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
keg.lock do
|
keg.lock do
|
||||||
print "Linking #{keg}... "
|
print "Linking #{keg}... "
|
||||||
puts if ARGV.verbose?
|
puts if ARGV.verbose?
|
||||||
|
|||||||
@ -37,9 +37,8 @@ describe "brew link", :integration_test do
|
|||||||
|
|
||||||
expect { brew "link", "testball1", "SHELL" => "/bin/zsh" }
|
expect { brew "link", "testball1", "SHELL" => "/bin/zsh" }
|
||||||
.to output(/testball1 is keg-only/).to_stderr
|
.to output(/testball1 is keg-only/).to_stderr
|
||||||
.and output(a_string_matching(/Note that doing so can interfere with building software\./)
|
.and output(a_string_matching(/If you need to have this software first in your PATH instead consider running:/)
|
||||||
.and(matching("If you need to have this software first in your PATH instead consider running:")
|
.and(including("echo 'export PATH=\"#{HOMEBREW_PREFIX}/opt/testball1/bin:$PATH\"' >> ~/.zshrc"))).to_stdout
|
||||||
.and(including("echo 'export PATH=\"#{HOMEBREW_PREFIX}/opt/testball1/bin:$PATH\"' >> ~/.zshrc")))).to_stdout
|
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user