From 93dca5fb38ef18d91007d8703fc1bc6fa93e9f0f Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Tue, 18 Dec 2012 14:59:12 -0800 Subject: upgrade.rb: Generate Tab from Keg not Formula Two issues were preventing `brew upgrade` from functioning properly: - `Tab.for_formula` was used to recover options from prior installs. The problem is that during an upgrade `for_formula` will be directed to a non-existant install of the newer version and thus returns a forged tab claiming no options were invoked. - The assignment to `installer.install_bottle` requires parenthesis in order to function properly. --- Library/Homebrew/cmd/upgrade.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 7ec02a0b5..06dfb8732 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -53,12 +53,15 @@ module Homebrew extend self end def upgrade_formula f - tab = Tab.for_formula(f) + # Generate using `for_keg` since the formula object points to a newer version + # that doesn't exist yet. Use `opt_prefix` to guard against keg-only installs. + # Also, guard against old installs that may not have an `opt_prefix` symlink. + tab = (f.opt_prefix.exist? ? Tab.for_keg(f.opt_prefix) : Tab.dummy_tab(f)) outdated_keg = Keg.new(f.linked_keg.realpath) rescue nil installer = FormulaInstaller.new(f, tab) installer.show_header = false - installer.install_bottle = install_bottle?(f) and tab.used_options.empty? + installer.install_bottle = (install_bottle?(f) and tab.used_options.empty?) oh1 "Upgrading #{f.name}" -- cgit v1.2.3