Merge pull request #966 from MikeMcQuaid/keg-lock-constants
Use constants for LinkedKegs/PinnedKegs/Locks.
This commit is contained in:
commit
1c5fa19f84
@ -111,7 +111,7 @@ module Homebrew
|
|||||||
if ARGV.include? "--pinned"
|
if ARGV.include? "--pinned"
|
||||||
pinned_versions = {}
|
pinned_versions = {}
|
||||||
names.each do |d|
|
names.each do |d|
|
||||||
keg_pin = (HOMEBREW_LIBRARY/"PinnedKegs"/d.basename.to_s)
|
keg_pin = (HOMEBREW_PINNED_KEGS/d.basename.to_s)
|
||||||
if keg_pin.exist? || keg_pin.symlink?
|
if keg_pin.exist? || keg_pin.symlink?
|
||||||
pinned_versions[d] = keg_pin.readlink.basename.to_s
|
pinned_versions[d] = keg_pin.readlink.basename.to_s
|
||||||
end
|
end
|
||||||
|
|||||||
@ -985,7 +985,7 @@ module Homebrew
|
|||||||
|
|
||||||
def check_for_unlinked_but_not_keg_only
|
def check_for_unlinked_but_not_keg_only
|
||||||
unlinked = Formula.racks.reject do |rack|
|
unlinked = Formula.racks.reject do |rack|
|
||||||
if !(HOMEBREW_REPOSITORY/"Library/LinkedKegs"/rack.basename).directory?
|
if !(HOMEBREW_LINKED_KEGS/rack.basename).directory?
|
||||||
begin
|
begin
|
||||||
Formulary.from_rack(rack).keg_only?
|
Formulary.from_rack(rack).keg_only?
|
||||||
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
||||||
|
|||||||
@ -59,8 +59,8 @@ module HomebrewArgvExtension
|
|||||||
|
|
||||||
raise NoSuchKegError, rack.basename if dirs.empty?
|
raise NoSuchKegError, rack.basename if dirs.empty?
|
||||||
|
|
||||||
linked_keg_ref = HOMEBREW_LIBRARY.join("LinkedKegs", rack.basename)
|
linked_keg_ref = HOMEBREW_LINKED_KEGS/rack.basename
|
||||||
opt_prefix = HOMEBREW_PREFIX.join("opt", rack.basename)
|
opt_prefix = HOMEBREW_PREFIX/"opt/#{rack.basename}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if opt_prefix.symlink? && opt_prefix.directory?
|
if opt_prefix.symlink? && opt_prefix.directory?
|
||||||
|
|||||||
@ -429,10 +429,10 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
# The `LinkedKegs` directory for this {Formula}.
|
# The link status symlink directory for this {Formula}.
|
||||||
# You probably want {#opt_prefix} instead.
|
# You probably want {#opt_prefix} instead.
|
||||||
def linked_keg
|
def linked_keg
|
||||||
Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}")
|
HOMEBREW_LINKED_KEGS/name
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_head_version
|
def latest_head_version
|
||||||
|
|||||||
@ -1,16 +1,14 @@
|
|||||||
require "fcntl"
|
require "fcntl"
|
||||||
|
|
||||||
class FormulaLock
|
class FormulaLock
|
||||||
LOCKDIR = HOMEBREW_LOCK_DIR
|
|
||||||
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
@name = name
|
@name = name
|
||||||
@path = LOCKDIR.join("#{@name}.brewing")
|
@path = HOMEBREW_LOCK_DIR/"#{@name}.brewing"
|
||||||
@lockfile = nil
|
@lockfile = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def lock
|
def lock
|
||||||
LOCKDIR.mkpath
|
HOMEBREW_LOCK_DIR.mkpath
|
||||||
@lockfile = get_or_create_lockfile
|
@lockfile = get_or_create_lockfile
|
||||||
unless @lockfile.flock(File::LOCK_EX | File::LOCK_NB)
|
unless @lockfile.flock(File::LOCK_EX | File::LOCK_NB)
|
||||||
raise OperationInProgressError, @name
|
raise OperationInProgressError, @name
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
require "keg"
|
require "keg"
|
||||||
|
|
||||||
class FormulaPin
|
class FormulaPin
|
||||||
PINDIR = Pathname.new("#{HOMEBREW_LIBRARY}/PinnedKegs")
|
|
||||||
|
|
||||||
def initialize(f)
|
def initialize(f)
|
||||||
@f = f
|
@f = f
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
Pathname.new("#{PINDIR}/#{@f.name}")
|
HOMEBREW_PINNED_KEGS/@f.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def pin_at(version)
|
def pin_at(version)
|
||||||
PINDIR.mkpath
|
HOMEBREW_PINNED_KEGS.mkpath
|
||||||
version_path = @f.rack.join(version)
|
version_path = @f.rack.join(version)
|
||||||
path.make_relative_symlink(version_path) unless pinned? || !version_path.exist?
|
path.make_relative_symlink(version_path) unless pinned? || !version_path.exist?
|
||||||
end
|
end
|
||||||
@ -23,7 +21,7 @@ class FormulaPin
|
|||||||
|
|
||||||
def unpin
|
def unpin
|
||||||
path.unlink if pinned?
|
path.unlink if pinned?
|
||||||
PINDIR.rmdir_if_possible
|
HOMEBREW_PINNED_KEGS.rmdir_if_possible
|
||||||
end
|
end
|
||||||
|
|
||||||
def pinned?
|
def pinned?
|
||||||
|
|||||||
@ -22,6 +22,9 @@ 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
|
||||||
|
|
||||||
|
|||||||
@ -100,8 +100,8 @@ class Keg
|
|||||||
raise "#{path} is not a directory" unless path.directory?
|
raise "#{path} is not a directory" unless path.directory?
|
||||||
@path = path
|
@path = path
|
||||||
@name = path.parent.basename.to_s
|
@name = path.parent.basename.to_s
|
||||||
@linked_keg_record = HOMEBREW_LIBRARY.join("LinkedKegs", name)
|
@linked_keg_record = HOMEBREW_LINKED_KEGS/name
|
||||||
@opt_record = HOMEBREW_PREFIX.join("opt", name)
|
@opt_record = HOMEBREW_PREFIX/"opt/#{name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|||||||
@ -107,8 +107,8 @@ class Migrator
|
|||||||
@new_linked_keg_record = HOMEBREW_CELLAR/"#{newname}/#{File.basename(old_linked_keg)}"
|
@new_linked_keg_record = HOMEBREW_CELLAR/"#{newname}/#{File.basename(old_linked_keg)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@old_pin_record = HOMEBREW_LIBRARY/"PinnedKegs"/oldname
|
@old_pin_record = HOMEBREW_PINNED_KEGS/oldname
|
||||||
@new_pin_record = HOMEBREW_LIBRARY/"PinnedKegs"/newname
|
@new_pin_record = HOMEBREW_PINNED_KEGS/newname
|
||||||
@pinned = old_pin_record.symlink?
|
@pinned = old_pin_record.symlink?
|
||||||
@old_pin_link_record = old_pin_record.readlink if @pinned
|
@old_pin_link_record = old_pin_record.readlink if @pinned
|
||||||
end
|
end
|
||||||
|
|||||||
@ -505,7 +505,7 @@ class FormulaTests < Homebrew::TestCase
|
|||||||
f3.brew { f3.install }
|
f3.brew { f3.install }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal HOMEBREW_LIBRARY.join("PinnedKegs/#{f1.name}").resolved_path, f1.prefix
|
assert_equal (HOMEBREW_PINNED_KEGS/f1.name).resolved_path, f1.prefix
|
||||||
|
|
||||||
assert_predicate f1, :installed?
|
assert_predicate f1, :installed?
|
||||||
assert_predicate f2, :installed?
|
assert_predicate f2, :installed?
|
||||||
|
|||||||
@ -114,8 +114,8 @@ class FormulaInstallerTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
dependency.prefix("0.1").join("bin/a").mkpath
|
dependency.prefix("0.1").join("bin/a").mkpath
|
||||||
HOMEBREW_LIBRARY.join("PinnedKegs").mkpath
|
HOMEBREW_PINNED_KEGS.mkpath
|
||||||
FileUtils.ln_s dependency.prefix("0.1"), HOMEBREW_LIBRARY.join("PinnedKegs/#{dep_name}")
|
FileUtils.ln_s dependency.prefix("0.1"), HOMEBREW_PINNED_KEGS/dep_name
|
||||||
|
|
||||||
dependency_keg = Keg.new(dependency.prefix("0.1"))
|
dependency_keg = Keg.new(dependency.prefix("0.1"))
|
||||||
dependency_keg.link
|
dependency_keg.link
|
||||||
|
|||||||
@ -9,7 +9,7 @@ class FormulaLockTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
@lock.unlock
|
@lock.unlock
|
||||||
FormulaLock::LOCKDIR.children.each(&:unlink)
|
HOMEBREW_LOCK_DIR.children.each(&:unlink)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_locking_file_with_existing_lock_raises_error
|
def test_locking_file_with_existing_lock_raises_error
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class FormulaPinTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rack
|
def rack
|
||||||
Pathname.new("#{HOMEBREW_CELLAR}/#{name}")
|
HOMEBREW_CELLAR/name
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed_prefixes
|
def installed_prefixes
|
||||||
@ -31,21 +31,21 @@ class FormulaPinTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_pinnable_if_kegs_exist
|
def test_pinnable_if_kegs_exist
|
||||||
(@f.rack+"0.1").mkpath
|
(@f.rack/"0.1").mkpath
|
||||||
assert_predicate @pin, :pinnable?
|
assert_predicate @pin, :pinnable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unpin
|
def test_unpin
|
||||||
(@f.rack+"0.1").mkpath
|
(@f.rack/"0.1").mkpath
|
||||||
@pin.pin
|
@pin.pin
|
||||||
|
|
||||||
assert_predicate @pin, :pinned?
|
assert_predicate @pin, :pinned?
|
||||||
assert_equal 1, FormulaPin::PINDIR.children.length
|
assert_equal 1, HOMEBREW_PINNED_KEGS.children.length
|
||||||
|
|
||||||
@pin.unpin
|
@pin.unpin
|
||||||
|
|
||||||
refute_predicate @pin, :pinned?
|
refute_predicate @pin, :pinned?
|
||||||
refute_predicate FormulaPin::PINDIR, :directory?
|
refute_predicate HOMEBREW_PINNED_KEGS, :directory?
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
HOMEBREW_PREFIX/"bin",
|
HOMEBREW_PREFIX/"bin",
|
||||||
HOMEBREW_PREFIX/"share",
|
HOMEBREW_PREFIX/"share",
|
||||||
HOMEBREW_PREFIX/"opt",
|
HOMEBREW_PREFIX/"opt",
|
||||||
HOMEBREW_LIBRARY/"LinkedKegs",
|
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",
|
||||||
@ -533,12 +533,12 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
HOMEBREW_CELLAR.join("testball/0.1").mkpath
|
HOMEBREW_CELLAR.join("testball/0.1").mkpath
|
||||||
HOMEBREW_LIBRARY.join("PinnedKegs").mkpath
|
HOMEBREW_PINNED_KEGS.mkpath
|
||||||
FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_LIBRARY.join("PinnedKegs/testball")
|
FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_PINNED_KEGS/"testball"
|
||||||
|
|
||||||
assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball")
|
assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball")
|
||||||
|
|
||||||
HOMEBREW_LIBRARY.join("PinnedKegs").rmtree
|
HOMEBREW_PINNED_KEGS.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_home
|
def test_home
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
@keg.link
|
@keg.link
|
||||||
@keg.optlink
|
@keg.optlink
|
||||||
|
|
||||||
@old_pin = HOMEBREW_LIBRARY/"PinnedKegs/oldname"
|
@old_pin = HOMEBREW_PINNED_KEGS/"oldname"
|
||||||
@old_pin.make_relative_symlink @old_keg_record
|
@old_pin.make_relative_symlink @old_keg_record
|
||||||
|
|
||||||
@migrator = Migrator.new(@new_f)
|
@migrator = Migrator.new(@new_f)
|
||||||
@ -92,7 +92,7 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
# What to do with pin?
|
# What to do with pin?
|
||||||
@new_f.unpin
|
@new_f.unpin
|
||||||
|
|
||||||
FormulaLock::LOCKDIR.children.each(&:unlink)
|
HOMEBREW_LOCK_DIR.children.each(&:unlink)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_move_cellar
|
def test_move_cellar
|
||||||
@ -117,7 +117,7 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def test_repin
|
def test_repin
|
||||||
@new_keg_record.join("bin").mkpath
|
@new_keg_record.join("bin").mkpath
|
||||||
expected_relative = @new_keg_record.relative_path_from HOMEBREW_LIBRARY/"PinnedKegs"
|
expected_relative = @new_keg_record.relative_path_from HOMEBREW_PINNED_KEGS
|
||||||
|
|
||||||
@migrator.repin
|
@migrator.repin
|
||||||
|
|
||||||
@ -127,13 +127,13 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_unlink_oldname
|
def test_unlink_oldname
|
||||||
assert_equal 1, HOMEBREW_LIBRARY.join("LinkedKegs").children.size
|
assert_equal 1, HOMEBREW_LINKED_KEGS.children.size
|
||||||
assert_equal 1, HOMEBREW_PREFIX.join("opt").children.size
|
assert_equal 1, (HOMEBREW_PREFIX/"opt").children.size
|
||||||
|
|
||||||
shutup { @migrator.unlink_oldname }
|
shutup { @migrator.unlink_oldname }
|
||||||
|
|
||||||
refute_predicate HOMEBREW_LIBRARY/"LinkedKegs", :exist?
|
refute_predicate HOMEBREW_LINKED_KEGS, :exist?
|
||||||
refute_predicate HOMEBREW_LIBRARY.join("bin"), :exist?
|
refute_predicate HOMEBREW_LIBRARY/"bin", :exist?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_newname
|
def test_link_newname
|
||||||
@ -144,8 +144,8 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
|
|
||||||
shutup { @migrator.link_newname }
|
shutup { @migrator.link_newname }
|
||||||
|
|
||||||
assert_equal 1, HOMEBREW_LIBRARY.join("LinkedKegs").children.size
|
assert_equal 1, HOMEBREW_LINKED_KEGS.children.size
|
||||||
assert_equal 1, HOMEBREW_PREFIX.join("opt").children.size
|
assert_equal 1, (HOMEBREW_PREFIX/"opt").children.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_oldname_opt
|
def test_link_oldname_opt
|
||||||
@ -182,12 +182,12 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
|
|
||||||
assert_predicate @new_keg_record, :exist?
|
assert_predicate @new_keg_record, :exist?
|
||||||
assert_predicate @old_keg_record.parent, :symlink?
|
assert_predicate @old_keg_record.parent, :symlink?
|
||||||
refute_predicate HOMEBREW_LIBRARY/"LinkedKegs/oldname", :exist?
|
refute_predicate HOMEBREW_LINKED_KEGS/"oldname", :exist?
|
||||||
assert_equal @new_keg_record.realpath, (HOMEBREW_LIBRARY/"LinkedKegs/newname").realpath
|
assert_equal @new_keg_record.realpath, (HOMEBREW_LINKED_KEGS/"newname").realpath
|
||||||
assert_equal @new_keg_record.realpath, @old_keg_record.realpath
|
assert_equal @new_keg_record.realpath, @old_keg_record.realpath
|
||||||
assert_equal @new_keg_record.realpath, (HOMEBREW_PREFIX/"opt/oldname").realpath
|
assert_equal @new_keg_record.realpath, (HOMEBREW_PREFIX/"opt/oldname").realpath
|
||||||
assert_equal @new_keg_record.parent.realpath, (HOMEBREW_CELLAR/"oldname").realpath
|
assert_equal @new_keg_record.parent.realpath, (HOMEBREW_CELLAR/"oldname").realpath
|
||||||
assert_equal @new_keg_record.realpath, (HOMEBREW_LIBRARY/"PinnedKegs/newname").realpath
|
assert_equal @new_keg_record.realpath, (HOMEBREW_PINNED_KEGS/"newname").realpath
|
||||||
assert_equal @new_f.path.to_s, Tab.for_keg(@new_keg_record).source["path"]
|
assert_equal @new_f.path.to_s, Tab.for_keg(@new_keg_record).source["path"]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -234,9 +234,9 @@ class MigratorTests < Homebrew::TestCase
|
|||||||
def check_after_backup
|
def check_after_backup
|
||||||
assert_predicate @old_keg_record.parent, :directory?
|
assert_predicate @old_keg_record.parent, :directory?
|
||||||
refute_predicate @old_keg_record.parent.subdirs, :empty?
|
refute_predicate @old_keg_record.parent.subdirs, :empty?
|
||||||
assert_predicate HOMEBREW_LIBRARY/"LinkedKegs/oldname", :exist?
|
assert_predicate HOMEBREW_LINKED_KEGS/"oldname", :exist?
|
||||||
assert_predicate HOMEBREW_PREFIX/"opt/oldname", :exist?
|
assert_predicate HOMEBREW_PREFIX/"opt/oldname", :exist?
|
||||||
assert_predicate HOMEBREW_LIBRARY/"PinnedKegs/oldname", :symlink?
|
assert_predicate HOMEBREW_PINNED_KEGS/"oldname", :symlink?
|
||||||
assert_predicate @keg, :linked?
|
assert_predicate @keg, :linked?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user