aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/link.rb
diff options
context:
space:
mode:
authorJack Nagel2013-01-23 00:26:25 -0600
committerJack Nagel2013-01-26 12:14:45 -0600
commitf82ed2f33dede59e6044a5b42e7c5bec6f7bbe26 (patch)
treea7bdd4052d161c001335c7ecdd1d3acc233a7bed /Library/Homebrew/cmd/link.rb
parentd1dca30bef8ea067b8868379e28e270b59518ac8 (diff)
downloadhomebrew-f82ed2f33dede59e6044a5b42e7c5bec6f7bbe26.tar.bz2
FormulaInstaller: implement installation locks
FormulaInstaller now attempts to take a lock on a "foo.brewing" file for the formula and all of its dependencies before attempting installation. The lock is an advisory lock implemented using flock(), and as such it only locks out other processes that attempt to take the lock. It also means that it is never necessary to manually remove the lock file, because the lock is not enforced by I/O. The uninstall, link, and unlink commands all learn to respect this lock as well, so that the installation cannot be corrupted by a concurrent Homebrew process, and keg operations cannot occur simultaneously.
Diffstat (limited to 'Library/Homebrew/cmd/link.rb')
-rw-r--r--Library/Homebrew/cmd/link.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb
index a85690ecb..6371c41de 100644
--- a/Library/Homebrew/cmd/link.rb
+++ b/Library/Homebrew/cmd/link.rb
@@ -35,8 +35,10 @@ module Homebrew extend self
next
end
- print "Linking #{keg}... " do
- puts "#{keg.link(mode)} symlinks created"
+ keg.lock do
+ print "Linking #{keg}... " do
+ puts "#{keg.link(mode)} symlinks created"
+ end
end
end
end