aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-03-19 12:24:13 +0000
committerMax Howell2012-03-19 12:24:13 +0000
commit88118b51b263ff32a0c18dc59e72b9b5ff265a28 (patch)
treebcc1b7ddd5dc3bbfea008d5628efd350077a937e /Library
parentc3370c48ce3ec6d00387e427413e46ca65d585d8 (diff)
downloadbrew-88118b51b263ff32a0c18dc59e72b9b5ff265a28.tar.bz2
Don't error if exact link already exists
If the link already exists exactly (well almost exactly) as we are about to correct it, then it's okay. Otherwise we error out. This is a safe choice, and really, the correct choice too. This will prevent the tickets like Homebrew/homebrew#11050 from occurring.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/link.rb5
-rw-r--r--Library/Homebrew/keg.rb18
2 files changed, 18 insertions, 5 deletions
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb
index 09d16c782..8885d0155 100644
--- a/Library/Homebrew/cmd/link.rb
+++ b/Library/Homebrew/cmd/link.rb
@@ -10,6 +10,11 @@ module Homebrew extend self
end
ARGV.kegs.each do |keg|
+ if keg.linked_keg_record.directory? and keg.linked_keg_record.realpath == keg
+ opoo "Already linked: #{keg}"
+ next
+ end
+
print "Linking #{keg}... " do
puts if ARGV.verbose?
puts "#{keg.link} symlinks created"
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 19e756f8f..6a217e90b 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -102,9 +102,9 @@ class Keg < Pathname
end
end
- (HOMEBREW_REPOSITORY/"Library/LinkedKegs"/fname).make_relative_symlink(self)
+ linked_keg_record.make_relative_symlink(self)
- return $n+$d
+ return $n + $d
end
protected
@@ -123,6 +123,14 @@ protected
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose?
end
+ def make_relative_symlink dst, src
+ if dst.exist? and dst.realpath == src.realpath
+ puts "Skipping; already exists: #{dst}" if ARGV.verbose?
+ else
+ dst.make_relative_symlink src
+ end
+ end
+
# symlinks the contents of self+foo recursively into /usr/local/foo
def link_dir foo
root = self+foo
@@ -141,10 +149,10 @@ protected
when :skip_file
Find.prune
when :info
- dst.make_relative_symlink(src)
+ make_relative_symlink dst, src
dst.install_info
else
- dst.make_relative_symlink(src)
+ make_relative_symlink dst, src
end
elsif src.directory?
# if the dst dir already exists, then great! walk the rest of the tree tho
@@ -161,7 +169,7 @@ protected
dst.mkpath unless resolve_any_conflicts(dst)
else
unless resolve_any_conflicts(dst)
- dst.make_relative_symlink(src)
+ make_relative_symlink dst, src
Find.prune
end
end