Leave kegs keg-only if linking step fails

Rationale: well, it should always have been like this!

However now we are opening ourselves up to more-mixed installations of formula not maintained by us, it's important that
This commit is contained in:
Max Howell 2012-03-06 13:02:10 +00:00
parent 921f0e5674
commit 765ae96180
3 changed files with 9 additions and 16 deletions

View File

@ -11,12 +11,7 @@ module Homebrew extend self
ARGV.kegs.each do |keg|
print "Linking #{keg}... "
puts if ARGV.verbose?
begin
puts "#{keg.link} symlinks created"
rescue Exception
puts
raise
end
end
end
end

View File

@ -273,15 +273,10 @@ class Pathname
self.dirname.mkpath
Dir.chdir self.dirname do
# TODO use Ruby function so we get exceptions
# NOTE Ruby functions may work, but I had a lot of problems
rv = system 'ln', '-sf', src.relative_path_from(self.dirname), self.basename
unless rv and $? == 0
raise <<-EOS.undent
Could not create symlink #{to_s}.
Check that you have permissions on #{self.dirname}
EOS
end
# NOTE only system ln -s will create RELATIVE symlinks
system 'ln', '-s', src.relative_path_from(self.dirname), self.basename
# ln outputs useful error message for us
raise "Could not create symlink: #{to_s}." unless $?.success?
end
end

View File

@ -214,11 +214,14 @@ class FormulaInstaller
f.linked_keg.unlink
end
Keg.new(f.prefix).link
keg = Keg.new(f.prefix)
keg.link
rescue Exception => e
onoe "The linking step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts "You can try again using `brew link #{f.name}'"
keg.unlink
ohai e, e.backtrace if ARGV.debug?
@show_summary_heading = true
end