Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
metadata: Use options from previous installs
Browse files Browse the repository at this point in the history
FormulaInstaller now loads the install recipt of a previous install and appends
the `used_options` to ARGV before forking to build. This means `brew upgrade`
will "remember" which options were invoked for the last install and re-use
them.

Fixes #5250.
  • Loading branch information
Sharpie committed Nov 13, 2011
1 parent 9e773c3 commit 7148211
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ def filtered_args
# Did the user actually pass the formula this installer is considering on
# the command line?
def explicitly_requested?; ARGV.formulae.include? f end
previous_install = Tab.for_formula f

args = ARGV.clone
args.uniq! # Just in case someone was playing around...
args.concat previous_install.used_options
args.uniq! # Just in case some dupes were added

%w[--HEAD --verbose -v --debug -d --interactive -i].each {|f| args.delete f} unless explicitly_requested?

Expand Down
35 changes: 35 additions & 0 deletions Library/Homebrew/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,41 @@ def self.for_install f, args
:tabfile => f.prefix + 'INSTALL_RECEIPT.json'
end

def self.from_file path
tab = Tab.new MultiJson.decode(open(path).read)
tab.tabfile = path

return tab
end

def self.for_formula f
f = Formula.factory f unless f.kind_of? Formula
path = HOMEBREW_REPOSITORY + 'Library' + 'LinkedKegs' + f.name + 'INSTALL_RECEIPT.json'

if path.exist?
self.from_file path
else
# Really should bail out with an error if a formula was not installed
# with a Tab. However, there will be lots of legacy installs that have no
# receipt---so we fabricate one that claims the formula was installed with
# no options.
#
# TODO:
# This isn't the best behavior---perhaps a future version of Homebrew can
# treat missing Tabs as errors.
Tab.new :used_options => [],
:unused_options => f.options.map { |o, _| o}
end
end

def installed_with? opt
used_options.include? opt
end

def options
used_options + unused_options
end

def to_json
MultiJson.encode({
:used_options => used_options,
Expand Down

0 comments on commit 7148211

Please sign in to comment.