diff --git a/Library/Homebrew/cmd/--cache.rb b/Library/Homebrew/cmd/--cache.rb index 9e2cf7acb5..bd6018efe4 100644 --- a/Library/Homebrew/cmd/--cache.rb +++ b/Library/Homebrew/cmd/--cache.rb @@ -60,7 +60,7 @@ module Homebrew def print_formula_cache(name, args:) formula = Formulary.factory(name, force_bottle: args.force_bottle?, flags: args.flags_only) - if fetch_bottle?(formula) + if fetch_bottle?(formula, args: args) puts formula.bottle.cached_download else puts formula.cached_download diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index e0dab2af95..fbf45cfcf2 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -46,7 +46,7 @@ module Homebrew end def fetch - fetch_args.parse + args = fetch_args.parse if args.deps? bucket = [] @@ -64,7 +64,7 @@ module Homebrew f.print_tap_action verb: "Fetching" fetched_bottle = false - if fetch_bottle?(f) + if fetch_bottle?(f, args: args) begin fetch_formula(f.bottle) rescue Interrupt diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index a0da11894a..29f6cd51b9 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -325,7 +325,7 @@ module Homebrew build_options = f.build fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?, - build_from_source: args.build_from_source?) + build_from_source: args.build_from_source?, args: args) fi.options = build_options.used_options fi.env = args.env fi.force = args.force? diff --git a/Library/Homebrew/fetch.rb b/Library/Homebrew/fetch.rb index 4db267aa72..b6941223cc 100644 --- a/Library/Homebrew/fetch.rb +++ b/Library/Homebrew/fetch.rb @@ -2,7 +2,7 @@ module Homebrew module Fetch - def fetch_bottle?(f) + def fetch_bottle?(f, args:) return true if args.force_bottle? && f.bottle return false unless f.bottle && f.pour_bottle? return false if args.build_formula_from_source?(f) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index b06c788d83..126fb949a8 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -39,15 +39,16 @@ class FormulaInstaller end attr_reader :formula - attr_accessor :cc, :env, :options, :build_bottle, :bottle_arch, - :installed_as_dependency, :installed_on_request, :link_keg + attr_accessor :cc, :env, :args, :options, :build_bottle, :bottle_arch, + :installed_as_dependency, :installed_on_request, :link_keg, :other_installers mode_attr_accessor :show_summary_heading, :show_header mode_attr_accessor :build_from_source, :force_bottle, :include_test mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git, :force, :keep_tmp mode_attr_accessor :verbose, :debug, :quiet - def initialize(formula, force_bottle: false, include_test: false, build_from_source: false, cc: nil) + def initialize(formula, force_bottle: false, include_test: false, build_from_source: false, cc: nil, args: nil) + @args = args @formula = formula @env = nil @force = false @@ -96,10 +97,10 @@ class FormulaInstaller # it's necessary to interrupt the user before any sort of installation # can proceed. Only invoked when the user has no developer tools. def self.prevent_build_flags - build_flags = Homebrew.args.collect_build_args - return if build_flags.empty? + build_flags = args&.collect_build_args + return if build_flags.blank? - all_bottled = Homebrew.args.formulae.all?(&:bottled?) + all_bottled = args.formulae.all?(&:bottled?) raise BuildFlagsError.new(build_flags, bottled: all_bottled) end @@ -145,7 +146,7 @@ class FormulaInstaller def install_bottle_for?(dep, build) return pour_bottle? if dep == formula - return false if Homebrew.args.build_formula_from_source?(dep) + return false if args&.build_formula_from_source?(dep) return false unless dep.bottle && dep.pour_bottle? return false unless build.used_options.empty? return false unless dep.bottle.compatible_cellar? @@ -504,7 +505,7 @@ class FormulaInstaller ) keep_build_test = false - keep_build_test ||= dep.test? && include_test? && Homebrew.args.include_formula_test_deps?(dependent) + keep_build_test ||= dep.test? && include_test? && args&.include_formula_test_deps?(dependent) keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed? if dep.prune_from_option?(build) @@ -582,8 +583,9 @@ class FormulaInstaller def fetch_dependency(dep) df = dep.to_formula fi = FormulaInstaller.new(df, force_bottle: false, - include_test: Homebrew.args.include_formula_test_deps?(df), - build_from_source: Homebrew.args.build_formula_from_source?(df)) + include_test: args&.include_formula_test_deps?(df), + build_from_source: args&.build_formula_from_source?(df), + args: args) fi.force = force? fi.keep_tmp = keep_tmp? @@ -623,8 +625,9 @@ class FormulaInstaller end fi = FormulaInstaller.new(df, force_bottle: false, - include_test: Homebrew.args.include_formula_test_deps?(df), - build_from_source: Homebrew.args.build_formula_from_source?(df)) + include_test: args&.include_formula_test_deps?(df), + build_from_source: args&.build_formula_from_source?(df), + args: args) fi.options |= tab.used_options fi.options |= Tab.remap_deprecated_options(df.deprecated_options, dep.options) @@ -764,7 +767,7 @@ class FormulaInstaller formula.options.each do |opt| name = opt.name[/^([^=]+)=$/, 1] - value = Homebrew.args.value(name) if name + value = args&.value(name) if name args << "--#{name}=#{value}" if value end diff --git a/Library/Homebrew/reinstall.rb b/Library/Homebrew/reinstall.rb index eaaa82a10a..30c4bb17a1 100644 --- a/Library/Homebrew/reinstall.rb +++ b/Library/Homebrew/reinstall.rb @@ -24,7 +24,7 @@ module Homebrew options &= f.options fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?, - build_from_source: args.build_from_source?) + build_from_source: args.build_from_source?, args: args) fi.options = options fi.force = args.force? fi.keep_tmp = args.keep_tmp? diff --git a/Library/Homebrew/upgrade.rb b/Library/Homebrew/upgrade.rb index 3a9a211129..0f590652a8 100644 --- a/Library/Homebrew/upgrade.rb +++ b/Library/Homebrew/upgrade.rb @@ -64,7 +64,7 @@ module Homebrew options &= f.options fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?, - build_from_source: args.build_from_source?) + build_from_source: args.build_from_source?, args: args) fi.options = options fi.force = args.force? fi.keep_tmp = args.keep_tmp?