metadata: Use options from previous installs
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 Homebrew/homebrew#5250.
This commit is contained in:
parent
028104b861
commit
ec1c7aaa38
@ -248,9 +248,11 @@ class FormulaInstaller
|
|||||||
# Did the user actually pass the formula this installer is considering on
|
# Did the user actually pass the formula this installer is considering on
|
||||||
# the command line?
|
# the command line?
|
||||||
def explicitly_requested?; ARGV.formulae.include? f end
|
def explicitly_requested?; ARGV.formulae.include? f end
|
||||||
|
previous_install = Tab.for_formula f
|
||||||
|
|
||||||
args = ARGV.clone
|
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?
|
%w[--HEAD --verbose -v --debug -d --interactive -i].each {|f| args.delete f} unless explicitly_requested?
|
||||||
|
|
||||||
|
@ -20,6 +20,41 @@ class Tab < OpenStruct
|
|||||||
:tabfile => f.prefix + 'INSTALL_RECEIPT.json'
|
:tabfile => f.prefix + 'INSTALL_RECEIPT.json'
|
||||||
end
|
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
|
def to_json
|
||||||
MultiJson.encode({
|
MultiJson.encode({
|
||||||
:used_options => used_options,
|
:used_options => used_options,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user