diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cleanup.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/config.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/formula_lock.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/lib/config.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/test/testing_env.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/utils/lock.sh | 4 | 
6 files changed, 13 insertions, 7 deletions
diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 987020bc9..96689be11 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -106,9 +106,9 @@ module Homebrew      end      def self.cleanup_lockfiles -      return unless HOMEBREW_CACHE_FORMULA.directory? -      candidates = HOMEBREW_CACHE_FORMULA.children -      lockfiles  = candidates.select { |f| f.file? && f.extname == ".brewing" } +      return unless HOMEBREW_LOCK_DIR.directory? +      candidates = HOMEBREW_LOCK_DIR.children +      lockfiles  = candidates.select(&:file?)        lockfiles.each do |file|          next unless file.readable?          file.open.flock(File::LOCK_EX | File::LOCK_NB) && file.unlink diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index a7441059f..9635ffbae 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -1,7 +1,7 @@  HOMEBREW_CACHE = Pathname.new(ENV["HOMEBREW_CACHE"] || "~/Library/Caches/Homebrew").expand_path  # Where brews installed via URL are cached -HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula" +HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE/"Formula"  if ENV["HOMEBREW_BREW_FILE"]    HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) @@ -19,6 +19,9 @@ HOMEBREW_LIBRARY = Pathname.new(ENV["HOMEBREW_LIBRARY"])  HOMEBREW_ENV_PATH = HOMEBREW_LIBRARY/"ENV"  HOMEBREW_CONTRIB = HOMEBREW_REPOSITORY/"Library/Contributions" +# Where we store lock files +HOMEBREW_LOCK_DIR = HOMEBREW_LIBRARY/"Locks" +  # Where we store built products  HOMEBREW_CELLAR = Pathname.new(ENV["HOMEBREW_CELLAR"]) diff --git a/Library/Homebrew/formula_lock.rb b/Library/Homebrew/formula_lock.rb index 70b116d3c..25cacdb72 100644 --- a/Library/Homebrew/formula_lock.rb +++ b/Library/Homebrew/formula_lock.rb @@ -1,7 +1,7 @@  require "fcntl"  class FormulaLock -  LOCKDIR = HOMEBREW_CACHE_FORMULA +  LOCKDIR = HOMEBREW_LOCK_DIR    def initialize(name)      @name = name diff --git a/Library/Homebrew/test/lib/config.rb b/Library/Homebrew/test/lib/config.rb index f6e601d52..10c3c8cd7 100644 --- a/Library/Homebrew/test/lib/config.rb +++ b/Library/Homebrew/test/lib/config.rb @@ -18,6 +18,7 @@ HOMEBREW_ENV_PATH      = HOMEBREW_LIBRARY_PATH.parent+"ENV"  HOMEBREW_LOAD_PATH     = [File.expand_path("..", __FILE__), HOMEBREW_LIBRARY_PATH].join(":")  HOMEBREW_CACHE         = HOMEBREW_PREFIX.parent+"cache"  HOMEBREW_CACHE_FORMULA = HOMEBREW_PREFIX.parent+"formula_cache" +HOMEBREW_LOCK_DIR      = HOMEBREW_PREFIX.parent+"locks"  HOMEBREW_CELLAR        = HOMEBREW_PREFIX.parent+"cellar"  HOMEBREW_LOGS          = HOMEBREW_PREFIX.parent+"logs" diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index b70b6cd6d..4e7089e42 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -7,7 +7,7 @@ require "formulary"  # Test environment setup  (HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula").mkpath -%w[cache formula_cache cellar logs].each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath } +%w[cache formula_cache locks cellar logs].each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }  # Test fixtures and files can be found relative to this path  TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__)) diff --git a/Library/Homebrew/utils/lock.sh b/Library/Homebrew/utils/lock.sh index b8e3f61ad..4ff8dc060 100644 --- a/Library/Homebrew/utils/lock.sh +++ b/Library/Homebrew/utils/lock.sh @@ -3,7 +3,9 @@  # Noted due to the fixed FD, a shell process can only create one lock.  lock() {    local name="$1" -  local lock_file="/tmp/homebrew${HOMEBREW_REPOSITORY//\//-}-${name}.lock" +  local lock_dir="$HOMEBREW_LIBRARY/Locks" +  local lock_file="$lock_dir/$name" +  [[ -d "$lock_dir" ]] || mkdir -p "$lock_dir"    # 200 is the file descriptor used in the lock.    # This FD should be used exclusively for lock purpose.    # Any value except 0(stdin), 1(stdout) and 2(stderr) can do the job.  | 
