diff options
| author | Vlad Shablinsky | 2015-08-09 14:56:01 +0300 |
|---|---|---|
| committer | Mike McQuaid | 2015-08-10 13:57:59 +0100 |
| commit | 6a0dcc83240d51f3f8473031cea6c571c5021130 (patch) | |
| tree | e4788732c554e992d21b98c7ca8c3555003b3d24 /Library | |
| parent | 2cc6b9032965fed9e937da7b1c723e4b2cfd60a0 (diff) | |
| download | brew-6a0dcc83240d51f3f8473031cea6c571c5021130.tar.bz2 | |
don't use new name rack if old name rack is a dir
Everything that used HOMEBREW_CELLAR/canonical_name
could point to something that doesn't exist because
loader_for tries to load new name formula if no old
name found. However there can be software installed
from path with the same name that renamed formulae
had and we still need to link/unlink/uninstall etc
that software. The solution is Formulary#to_rack
method that returns rack for given name.
- Add Formulary#to_rack
- Update ARGV.kegs
- Update cmd/switch
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/switch.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ARGV.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/formulary.rb | 18 |
3 files changed, 25 insertions, 8 deletions
diff --git a/Library/Homebrew/cmd/switch.rb b/Library/Homebrew/cmd/switch.rb index 5efebd7e5..b4c3c43d9 100644 --- a/Library/Homebrew/cmd/switch.rb +++ b/Library/Homebrew/cmd/switch.rb @@ -12,8 +12,7 @@ module Homebrew name = ARGV.shift version = ARGV.shift - canonical_name = Formulary.canonical_name(name) - rack = HOMEBREW_CELLAR.join(canonical_name) + rack = Formulary.to_rack(name) unless rack.directory? onoe "#{name} not found in the Cellar." diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 5a13230ac..66ff3dfd5 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -47,14 +47,14 @@ module HomebrewArgvExtension require "keg" require "formula" @kegs ||= downcased_unique_named.collect do |name| - canonical_name = Formulary.canonical_name(name) - rack = HOMEBREW_CELLAR/canonical_name + rack = Formulary.to_rack(name) + dirs = rack.directory? ? rack.subdirs : [] - raise NoSuchKegError.new(canonical_name) if dirs.empty? + raise NoSuchKegError.new(rack.basename) if dirs.empty? - linked_keg_ref = HOMEBREW_LIBRARY.join("LinkedKegs", canonical_name) - opt_prefix = HOMEBREW_PREFIX.join("opt", canonical_name) + linked_keg_ref = HOMEBREW_LIBRARY.join("LinkedKegs", rack.basename) + opt_prefix = HOMEBREW_PREFIX.join("opt", rack.basename) begin if opt_prefix.symlink? && opt_prefix.directory? @@ -66,7 +66,7 @@ module HomebrewArgvExtension elsif (prefix = (name.include?("/") ? Formulary.factory(name) : Formulary.from_rack(rack)).prefix).directory? Keg.new(prefix) else - raise MultipleVersionsInstalledError.new(canonical_name) + raise MultipleVersionsInstalledError.new(rack.basename) end rescue FormulaUnavailableError raise <<-EOS.undent diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 4a31b3121..8fcffb59e 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -195,6 +195,24 @@ class Formulary end end + def self.to_rack(ref) + name = canonical_name(ref) + rack = HOMEBREW_CELLAR/name + + # Handle the case when ref is an old name and the installation + # hasn't been migrated or when it's a package installed from + # path but same name formula was renamed. + unless rack.directory? + if ref =~ HOMEBREW_TAP_FORMULA_REGEX + rack = HOMEBREW_CELLAR/$3 + elsif !ref.include?("/") + rack = HOMEBREW_CELLAR/ref + end + end + + rack + end + def self.canonical_name(ref) loader_for(ref).name rescue TapFormulaAmbiguityError |
