From f82ed2f33dede59e6044a5b42e7c5bec6f7bbe26 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 23 Jan 2013 00:26:25 -0600 Subject: 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. --- Library/Homebrew/exceptions.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Library/Homebrew/exceptions.rb') diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index ae2dd20c4..edd5cf1d1 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -45,6 +45,18 @@ class FormulaUnavailableError < RuntimeError end end +class OperationInProgressError < RuntimeError + def initialize name + message = <<-EOS.undent + Operation already in progress for #{name} + Another active Homebrew process is already using #{name}. + Please wait for it to finish or terminate it to continue. + EOS + + super message + end +end + module Homebrew class InstallationError < RuntimeError attr :formula -- cgit v1.2.3