aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2012-02-10 17:21:48 -0600
committerJack Nagel2012-02-10 23:52:01 -0600
commitc1fecab3651c876a88d5971bc2ed31fe30bd66cd (patch)
tree5e1cf62f3d037e52b7e815518b12c113bbee6d85
parentddde478f63666bb090c6351eb29cc58d449f6f0f (diff)
downloadbrew-c1fecab3651c876a88d5971bc2ed31fe30bd66cd.tar.bz2
Don't return nil from Formula#linked_keg
Doing so was the result of a quick hack to fix the "deps installed as upgrades don't get linked" bug, but it was a mistake. Instead, always return the LinkedKegs entry as a Pathname object, and let callers be responsible for checking that it exists. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
-rw-r--r--Library/Homebrew/cmd/install.rb2
-rw-r--r--Library/Homebrew/formula.rb3
-rw-r--r--Library/Homebrew/formula_installer.rb2
-rw-r--r--Library/Homebrew/tab.rb2
4 files changed, 4 insertions, 5 deletions
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 5aa198f31..4a20dc7cb 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -12,7 +12,7 @@ module Homebrew extend self
end unless ARGV.force?
ARGV.formulae.each do |f|
- if File.directory? HOMEBREW_REPOSITORY/"Library/LinkedKegs/#{f.name}"
+ if f.linked_keg.directory?
raise "#{f} already installed\nTry: brew upgrade #{f}"
end
end unless ARGV.force?
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 28592eb72..512dafaf0 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -69,8 +69,7 @@ class Formula
end
def linked_keg
- keg = Pathname.new(HOMEBREW_REPOSITORY/"Library/LinkedKegs"/@name)
- if keg.exist? then Keg.new(keg.realpath) else nil end
+ HOMEBREW_REPOSITORY/'Library/LinkedKegs'/@name
end
def installed_prefix
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 9e52b9e3b..469db2db3 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -66,7 +66,7 @@ class FormulaInstaller
fi.show_header = false
oh1 "Installing #{f} dependency: #{dep}"
fi.install
- dep.linked_keg.unlink if dep.linked_keg
+ Keg.new(dep.linked_keg.realpath).unlink if dep.linked_keg.directory?
fi.caveats
fi.finish
end
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index cf457f674..c22998dc3 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -46,7 +46,7 @@ class Tab < OpenStruct
def self.for_formula f
f = Formula.factory f unless f.kind_of? Formula
- path = HOMEBREW_REPOSITORY + 'Library' + 'LinkedKegs' + f.name + 'INSTALL_RECEIPT.json'
+ path = f.linked_keg/'INSTALL_RECEIPT.json'
if path.exist?
self.from_file path