mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
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.
This commit is contained in:
parent
53713593d6
commit
e3609b6fd4
@ -75,6 +75,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
migrate_legacy_cache_if_necessary
|
migrate_legacy_cache_if_necessary
|
||||||
|
migrate_legacy_keg_symlinks_if_necessary
|
||||||
|
|
||||||
if !updated
|
if !updated
|
||||||
if !ARGV.include?("--preinstall") && !ENV["HOMEBREW_UPDATE_FAILED"]
|
if !ARGV.include?("--preinstall") && !ENV["HOMEBREW_UPDATE_FAILED"]
|
||||||
@ -167,6 +168,24 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
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
|
def link_completions_and_docs
|
||||||
return if HOMEBREW_PREFIX.to_s == HOMEBREW_REPOSITORY.to_s
|
return if HOMEBREW_PREFIX.to_s == HOMEBREW_REPOSITORY.to_s
|
||||||
command = "brew update"
|
command = "brew update"
|
||||||
|
@ -17,8 +17,14 @@ HOMEBREW_LIBRARY = Pathname.new(ENV["HOMEBREW_LIBRARY"])
|
|||||||
# Where shim scripts for various build and SCM tools are stored
|
# Where shim scripts for various build and SCM tools are stored
|
||||||
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY/"Homebrew/shims"
|
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
|
# Where we store lock files
|
||||||
HOMEBREW_LOCK_DIR = HOMEBREW_LIBRARY/"Locks"
|
HOMEBREW_LOCK_DIR = HOMEBREW_PREFIX/"var/homebrew/locks"
|
||||||
|
|
||||||
# Where we store built products
|
# Where we store built products
|
||||||
HOMEBREW_CELLAR = Pathname.new(ENV["HOMEBREW_CELLAR"])
|
HOMEBREW_CELLAR = Pathname.new(ENV["HOMEBREW_CELLAR"])
|
||||||
|
@ -22,9 +22,6 @@ require "config"
|
|||||||
|
|
||||||
HOMEBREW_REPOSITORY.extend(GitRepositoryExtension)
|
HOMEBREW_REPOSITORY.extend(GitRepositoryExtension)
|
||||||
|
|
||||||
HOMEBREW_LINKED_KEGS = HOMEBREW_LIBRARY/"LinkedKegs"
|
|
||||||
HOMEBREW_PINNED_KEGS = HOMEBREW_LIBRARY/"PinnedKegs"
|
|
||||||
|
|
||||||
RUBY_PATH = Pathname.new(RbConfig.ruby)
|
RUBY_PATH = Pathname.new(RbConfig.ruby)
|
||||||
RUBY_BIN = RUBY_PATH.dirname
|
RUBY_BIN = RUBY_PATH.dirname
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class Keg
|
|||||||
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
|
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
|
||||||
TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks]
|
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
|
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
|
case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ HOMEBREW_REPOSITORY = HOMEBREW_PREFIX
|
|||||||
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY+"Library"
|
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY+"Library"
|
||||||
HOMEBREW_CACHE = HOMEBREW_PREFIX.parent+"cache"
|
HOMEBREW_CACHE = HOMEBREW_PREFIX.parent+"cache"
|
||||||
HOMEBREW_CACHE_FORMULA = HOMEBREW_PREFIX.parent+"formula_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_LOCK_DIR = HOMEBREW_PREFIX.parent+"locks"
|
||||||
HOMEBREW_CELLAR = HOMEBREW_PREFIX.parent+"cellar"
|
HOMEBREW_CELLAR = HOMEBREW_PREFIX.parent+"cellar"
|
||||||
HOMEBREW_LOGS = HOMEBREW_PREFIX.parent+"logs"
|
HOMEBREW_LOGS = HOMEBREW_PREFIX.parent+"logs"
|
||||||
|
@ -14,6 +14,8 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
def teardown
|
def teardown
|
||||||
coretap = CoreTap.new
|
coretap = CoreTap.new
|
||||||
paths_to_delete = [
|
paths_to_delete = [
|
||||||
|
HOMEBREW_LINKED_KEGS,
|
||||||
|
HOMEBREW_PINNED_KEGS,
|
||||||
HOMEBREW_CELLAR.children,
|
HOMEBREW_CELLAR.children,
|
||||||
HOMEBREW_CACHE.children,
|
HOMEBREW_CACHE.children,
|
||||||
HOMEBREW_LOCK_DIR.children,
|
HOMEBREW_LOCK_DIR.children,
|
||||||
@ -22,7 +24,6 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
HOMEBREW_PREFIX/"bin",
|
HOMEBREW_PREFIX/"bin",
|
||||||
HOMEBREW_PREFIX/"share",
|
HOMEBREW_PREFIX/"share",
|
||||||
HOMEBREW_PREFIX/"opt",
|
HOMEBREW_PREFIX/"opt",
|
||||||
HOMEBREW_LINKED_KEGS,
|
|
||||||
HOMEBREW_LIBRARY/"Taps/caskroom",
|
HOMEBREW_LIBRARY/"Taps/caskroom",
|
||||||
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
|
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
|
||||||
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
|
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# Noted due to the fixed FD, a shell process can only create one lock.
|
# Noted due to the fixed FD, a shell process can only create one lock.
|
||||||
lock() {
|
lock() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local lock_dir="$HOMEBREW_LIBRARY/Locks"
|
local lock_dir="$HOMEBREW_PREFIX/var/homebrew/locks"
|
||||||
local lock_file="$lock_dir/$name"
|
local lock_file="$lock_dir/$name"
|
||||||
[[ -d "$lock_dir" ]] || mkdir -p "$lock_dir"
|
[[ -d "$lock_dir" ]] || mkdir -p "$lock_dir"
|
||||||
# 200 is the file descriptor used in the lock.
|
# 200 is the file descriptor used in the lock.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user