diff options
| author | Mike McQuaid | 2016-09-16 13:51:21 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2016-09-16 13:51:56 +0100 | 
| commit | e3609b6fd4001523679562c33064e17d03e1534f (patch) | |
| tree | 6864f57a269e237c0d1cad531b457b5de0346e5e | |
| parent | 53713593d677cb916402742940d14bfc7e60a5a4 (diff) | |
| download | brew-e3609b6fd4001523679562c33064e17d03e1534f.tar.bz2 | |
Move LinkedKegs/PinnedKegs/Locks from Library.
These don't make sense to be tied to the `HOMEBREW_REPOSITORY` but
instead should live in the `HOMEBREW_PREFIX` as they all relate to its
state.
| -rw-r--r-- | Library/Homebrew/cmd/update-report.rb | 19 | ||||
| -rw-r--r-- | Library/Homebrew/config.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/global.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/keg.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/lib/config.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_integration_cmds.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/utils/lock.sh | 2 | 
7 files changed, 32 insertions, 7 deletions
| diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index c068d02ee..fa82c875d 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -75,6 +75,7 @@ module Homebrew      end      migrate_legacy_cache_if_necessary +    migrate_legacy_keg_symlinks_if_necessary      if !updated        if !ARGV.include?("--preinstall") && !ENV["HOMEBREW_UPDATE_FAILED"] @@ -167,6 +168,24 @@ module Homebrew      end    end +  def migrate_legacy_keg_symlinks_if_necessary +    legacy_linked_kegs = HOMEBREW_LIBRARY/"LinkedKegs" +    return unless legacy_linked_kegs.directory? + +    legacy_linked_kegs.children.each {|f| Keg.new(f.realpath).link } +    FileUtils.rm_rf legacy_linked_kegs + +    legacy_pinned_kegs = HOMEBREW_LIBRARY/"PinnedKegs" +    return unless legacy_pinned_kegs.directory? + +    legacy_pinned_kegs.children.each do |f| +      pin_version = Keg.new(f.realpath).version +      formula = Formulary.factory(f.basename.to_s) +      FormulaPin.new(formula).pin_at(pin_version) +    end +    FileUtils.rm_rf legacy_pinned_kegs +  end +    def link_completions_and_docs      return if HOMEBREW_PREFIX.to_s == HOMEBREW_REPOSITORY.to_s      command = "brew update" diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index cef615365..19ad7a7e5 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -17,8 +17,14 @@ HOMEBREW_LIBRARY = Pathname.new(ENV["HOMEBREW_LIBRARY"])  # Where shim scripts for various build and SCM tools are stored  HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY/"Homebrew/shims" +# Where we store symlinks to currently linked kegs +HOMEBREW_LINKED_KEGS = HOMEBREW_PREFIX/"var/homebrew/linked" + +# Wehere we store symlinks to currently version-pinned kegs +HOMEBREW_PINNED_KEGS = HOMEBREW_PREFIX/"var/homebrew/pinned" +  # Where we store lock files -HOMEBREW_LOCK_DIR = HOMEBREW_LIBRARY/"Locks" +HOMEBREW_LOCK_DIR = HOMEBREW_PREFIX/"var/homebrew/locks"  # Where we store built products  HOMEBREW_CELLAR = Pathname.new(ENV["HOMEBREW_CELLAR"]) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 36eb97baa..8472eba5c 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -22,9 +22,6 @@ require "config"  HOMEBREW_REPOSITORY.extend(GitRepositoryExtension) -HOMEBREW_LINKED_KEGS = HOMEBREW_LIBRARY/"LinkedKegs" -HOMEBREW_PINNED_KEGS = HOMEBREW_LIBRARY/"PinnedKegs" -  RUBY_PATH = Pathname.new(RbConfig.ruby)  RUBY_BIN = RUBY_PATH.dirname diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 68a96024f..febb60971 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -66,7 +66,7 @@ class Keg    INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}    TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks]    ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze -  PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs].map do |d| +  PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs var/homebrew].map do |d|      case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end    end diff --git a/Library/Homebrew/test/lib/config.rb b/Library/Homebrew/test/lib/config.rb index 713bc9c3a..98144d71e 100644 --- a/Library/Homebrew/test/lib/config.rb +++ b/Library/Homebrew/test/lib/config.rb @@ -24,6 +24,8 @@ HOMEBREW_REPOSITORY    = HOMEBREW_PREFIX  HOMEBREW_LIBRARY       = HOMEBREW_REPOSITORY+"Library"  HOMEBREW_CACHE         = HOMEBREW_PREFIX.parent+"cache"  HOMEBREW_CACHE_FORMULA = HOMEBREW_PREFIX.parent+"formula_cache" +HOMEBREW_LINKED_KEGS   = HOMEBREW_PREFIX.parent+"linked" +HOMEBREW_PINNED_KEGS   = HOMEBREW_PREFIX.parent+"pinned"  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/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb index 5b64dfd85..3eef41515 100644 --- a/Library/Homebrew/test/test_integration_cmds.rb +++ b/Library/Homebrew/test/test_integration_cmds.rb @@ -14,6 +14,8 @@ class IntegrationCommandTests < Homebrew::TestCase    def teardown      coretap = CoreTap.new      paths_to_delete = [ +      HOMEBREW_LINKED_KEGS, +      HOMEBREW_PINNED_KEGS,        HOMEBREW_CELLAR.children,        HOMEBREW_CACHE.children,        HOMEBREW_LOCK_DIR.children, @@ -22,7 +24,6 @@ class IntegrationCommandTests < Homebrew::TestCase        HOMEBREW_PREFIX/"bin",        HOMEBREW_PREFIX/"share",        HOMEBREW_PREFIX/"opt", -      HOMEBREW_LINKED_KEGS,        HOMEBREW_LIBRARY/"Taps/caskroom",        HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",        HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", diff --git a/Library/Homebrew/utils/lock.sh b/Library/Homebrew/utils/lock.sh index ab6d2533d..cc041fa74 100644 --- a/Library/Homebrew/utils/lock.sh +++ b/Library/Homebrew/utils/lock.sh @@ -3,7 +3,7 @@  # Noted due to the fixed FD, a shell process can only create one lock.  lock() {    local name="$1" -  local lock_dir="$HOMEBREW_LIBRARY/Locks" +  local lock_dir="$HOMEBREW_PREFIX/var/homebrew/locks"    local lock_file="$lock_dir/$name"    [[ -d "$lock_dir" ]] || mkdir -p "$lock_dir"    # 200 is the file descriptor used in the lock. | 
