Merge pull request #8084 from reitermarkus/cli-parser
Refactor usage of global `Homebrew.args`.
This commit is contained in:
commit
8d97029b03
@ -35,13 +35,6 @@ rescue MissingEnvironmentVariables => e
|
|||||||
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
|
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_unsupported_error
|
|
||||||
$stderr.puts <<~EOS
|
|
||||||
Please create pull requests instead of asking for help on Homebrew's GitHub,
|
|
||||||
Discourse, Twitter or IRC.
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
trap("INT", std_trap) # restore default CTRL-C handler
|
trap("INT", std_trap) # restore default CTRL-C handler
|
||||||
|
|
||||||
@ -150,7 +143,12 @@ rescue BuildError => e
|
|||||||
Utils::Analytics.report_build_error(e)
|
Utils::Analytics.report_build_error(e)
|
||||||
e.dump
|
e.dump
|
||||||
|
|
||||||
output_unsupported_error if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
|
if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
|
||||||
|
$stderr.puts <<~EOS
|
||||||
|
Please create pull requests instead of asking for help on Homebrew's GitHub,
|
||||||
|
Discourse, Twitter or IRC.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
rescue RuntimeError, SystemCallError => e
|
rescue RuntimeError, SystemCallError => e
|
||||||
@ -159,8 +157,6 @@ rescue RuntimeError, SystemCallError => e
|
|||||||
onoe e
|
onoe e
|
||||||
$stderr.puts e.backtrace if Homebrew.args.debug?
|
$stderr.puts e.backtrace if Homebrew.args.debug?
|
||||||
|
|
||||||
output_unsupported_error if Homebrew.args.HEAD?
|
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
rescue MethodDeprecatedError => e
|
rescue MethodDeprecatedError => e
|
||||||
onoe e
|
onoe e
|
||||||
|
@ -97,7 +97,11 @@ class Build
|
|||||||
bottle_arch: args.bottle_arch,
|
bottle_arch: args.bottle_arch,
|
||||||
)
|
)
|
||||||
post_superenv_hacks
|
post_superenv_hacks
|
||||||
reqs.each { |req| req.modify_build_environment(args: args) }
|
reqs.each do |req|
|
||||||
|
req.modify_build_environment(
|
||||||
|
env: args.env, cc: args.cc, build_bottle: args.build_bottle?, bottle_arch: args.bottle_arch,
|
||||||
|
)
|
||||||
|
end
|
||||||
deps.each(&:modify_build_environment)
|
deps.each(&:modify_build_environment)
|
||||||
else
|
else
|
||||||
ENV.setup_build_environment(
|
ENV.setup_build_environment(
|
||||||
@ -106,7 +110,11 @@ class Build
|
|||||||
build_bottle: args.build_bottle?,
|
build_bottle: args.build_bottle?,
|
||||||
bottle_arch: args.bottle_arch,
|
bottle_arch: args.bottle_arch,
|
||||||
)
|
)
|
||||||
reqs.each { |req| req.modify_build_environment(args: args) }
|
reqs.each do |req|
|
||||||
|
req.modify_build_environment(
|
||||||
|
env: args.env, cc: args.cc, build_bottle: args.build_bottle?, bottle_arch: args.bottle_arch,
|
||||||
|
)
|
||||||
|
end
|
||||||
deps.each(&:modify_build_environment)
|
deps.each(&:modify_build_environment)
|
||||||
|
|
||||||
keg_only_deps.each do |dep|
|
keg_only_deps.each do |dep|
|
||||||
|
@ -70,24 +70,11 @@ module Homebrew
|
|||||||
named.blank?
|
named.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
# If the user passes any flags that trigger building over installing from
|
|
||||||
# a bottle, they are collected here and returned as an Array for checking.
|
|
||||||
def collect_build_args
|
|
||||||
build_flags = []
|
|
||||||
|
|
||||||
build_flags << "--HEAD" if HEAD?
|
|
||||||
build_flags << "--universal" if build_universal?
|
|
||||||
build_flags << "--build-bottle" if build_bottle?
|
|
||||||
build_flags << "--build-from-source" if build_from_source?
|
|
||||||
|
|
||||||
build_flags
|
|
||||||
end
|
|
||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
@formulae ||= (downcased_unique_named - casks).map do |name|
|
@formulae ||= (downcased_unique_named - casks).map do |name|
|
||||||
Formulary.factory(name, spec)
|
Formulary.factory(name, spec, force_bottle: force_bottle?, flags: flags_only)
|
||||||
end.uniq(&:name).freeze
|
end.uniq(&:name).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -113,7 +100,7 @@ module Homebrew
|
|||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
@resolved_formulae ||= (downcased_unique_named - casks).map do |name|
|
@resolved_formulae ||= (downcased_unique_named - casks).map do |name|
|
||||||
Formulary.resolve(name, spec: spec(nil))
|
Formulary.resolve(name, spec: spec(nil), force_bottle: force_bottle?, flags: flags_only)
|
||||||
end.uniq(&:name).freeze
|
end.uniq(&:name).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -123,7 +110,8 @@ module Homebrew
|
|||||||
casks = []
|
casks = []
|
||||||
|
|
||||||
downcased_unique_named.each do |name|
|
downcased_unique_named.each do |name|
|
||||||
resolved_formulae << Formulary.resolve(name, spec: spec(nil))
|
resolved_formulae << Formulary.resolve(name, spec: spec(nil),
|
||||||
|
force_bottle: force_bottle?, flags: flags_only)
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
begin
|
begin
|
||||||
casks << Cask::CaskLoader.load(name)
|
casks << Cask::CaskLoader.load(name)
|
||||||
@ -181,18 +169,20 @@ module Homebrew
|
|||||||
!(HEAD? || devel?)
|
!(HEAD? || devel?)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether a given formula should be built from source during the current
|
def build_from_source_formulae
|
||||||
# installation run.
|
if build_from_source? || build_bottle?
|
||||||
def build_formula_from_source?(f)
|
formulae.map(&:full_name)
|
||||||
return false if !build_from_source? && !build_bottle?
|
else
|
||||||
|
[]
|
||||||
formulae.any? { |args_f| args_f.full_name == f.full_name }
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_formula_test_deps?(f)
|
def include_test_formulae
|
||||||
return false unless include_test?
|
if include_test?
|
||||||
|
formulae.map(&:full_name)
|
||||||
formulae.any? { |args_f| args_f.full_name == f.full_name }
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def value(name)
|
def value(name)
|
||||||
|
@ -360,7 +360,7 @@ module Homebrew
|
|||||||
named_args.map do |arg|
|
named_args.map do |arg|
|
||||||
next if arg.match?(HOMEBREW_CASK_TAP_CASK_REGEX)
|
next if arg.match?(HOMEBREW_CASK_TAP_CASK_REGEX)
|
||||||
|
|
||||||
Formulary.factory(arg, spec)
|
Formulary.factory(arg, spec, flags: @args.flags_only)
|
||||||
end.compact.uniq(&:name)
|
end.compact.uniq(&:name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,13 +33,13 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def __cache
|
def __cache
|
||||||
__cache_args.parse
|
args = __cache_args.parse
|
||||||
|
|
||||||
if args.no_named?
|
if args.no_named?
|
||||||
puts HOMEBREW_CACHE
|
puts HOMEBREW_CACHE
|
||||||
elsif args.formula?
|
elsif args.formula?
|
||||||
args.named.each do |name|
|
args.named.each do |name|
|
||||||
print_formula_cache name
|
print_formula_cache name, args: args
|
||||||
end
|
end
|
||||||
elsif args.cask?
|
elsif args.cask?
|
||||||
args.named.each do |name|
|
args.named.each do |name|
|
||||||
@ -47,7 +47,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
args.named.each do |name|
|
args.named.each do |name|
|
||||||
print_formula_cache name
|
print_formula_cache name, args: args
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
begin
|
begin
|
||||||
print_cask_cache name
|
print_cask_cache name
|
||||||
@ -58,9 +58,9 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_formula_cache(name)
|
def print_formula_cache(name, args:)
|
||||||
formula = Formulary.factory name
|
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
|
puts formula.bottle.cached_download
|
||||||
else
|
else
|
||||||
puts formula.cached_download
|
puts formula.cached_download
|
||||||
|
@ -46,7 +46,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
fetch_args.parse
|
args = fetch_args.parse
|
||||||
|
|
||||||
if args.deps?
|
if args.deps?
|
||||||
bucket = []
|
bucket = []
|
||||||
@ -64,7 +64,7 @@ module Homebrew
|
|||||||
f.print_tap_action verb: "Fetching"
|
f.print_tap_action verb: "Fetching"
|
||||||
|
|
||||||
fetched_bottle = false
|
fetched_bottle = false
|
||||||
if fetch_bottle?(f)
|
if fetch_bottle?(f, args: args)
|
||||||
begin
|
begin
|
||||||
fetch_formula(f.bottle)
|
fetch_formula(f.bottle)
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
|
@ -8,6 +8,8 @@ require "socket"
|
|||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
extend Install
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def gist_logs_args
|
def gist_logs_args
|
||||||
|
@ -256,7 +256,7 @@ module Homebrew
|
|||||||
def decorate_requirements(requirements)
|
def decorate_requirements(requirements)
|
||||||
req_status = requirements.map do |req|
|
req_status = requirements.map do |req|
|
||||||
req_s = req.display_s
|
req_s = req.display_s
|
||||||
req.satisfied?(args: args) ? pretty_installed(req_s) : pretty_uninstalled(req_s)
|
req.satisfied? ? pretty_installed(req_s) : pretty_uninstalled(req_s)
|
||||||
end
|
end
|
||||||
req_status.join(", ")
|
req_status.join(", ")
|
||||||
end
|
end
|
||||||
|
@ -10,10 +10,10 @@ require "cli/parser"
|
|||||||
require "upgrade"
|
require "upgrade"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
|
||||||
|
|
||||||
extend Search
|
extend Search
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
def install_args
|
def install_args
|
||||||
Homebrew::CLI::Parser.new do
|
Homebrew::CLI::Parser.new do
|
||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
@ -115,13 +115,13 @@ module Homebrew
|
|||||||
|
|
||||||
formulae = []
|
formulae = []
|
||||||
|
|
||||||
unless Homebrew.args.casks.empty?
|
unless args.casks.empty?
|
||||||
cask_args = []
|
cask_args = []
|
||||||
cask_args << "--force" if args.force?
|
cask_args << "--force" if args.force?
|
||||||
cask_args << "--debug" if args.debug?
|
cask_args << "--debug" if args.debug?
|
||||||
cask_args << "--verbose" if args.verbose?
|
cask_args << "--verbose" if args.verbose?
|
||||||
|
|
||||||
Homebrew.args.casks.each do |c|
|
args.casks.each do |c|
|
||||||
ohai "brew cask install #{c} #{cask_args.join " "}"
|
ohai "brew cask install #{c} #{cask_args.join " "}"
|
||||||
system("#{HOMEBREW_PREFIX}/bin/brew", "cask", "install", c, *cask_args)
|
system("#{HOMEBREW_PREFIX}/bin/brew", "cask", "install", c, *cask_args)
|
||||||
end
|
end
|
||||||
@ -129,7 +129,7 @@ module Homebrew
|
|||||||
|
|
||||||
# if the user's flags will prevent bottle only-installations when no
|
# if the user's flags will prevent bottle only-installations when no
|
||||||
# developer tools are available, we need to stop them early on
|
# developer tools are available, we need to stop them early on
|
||||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
FormulaInstaller.prevent_build_flags(args)
|
||||||
|
|
||||||
args.formulae.each do |f|
|
args.formulae.each do |f|
|
||||||
# head-only without --HEAD is an error
|
# head-only without --HEAD is an error
|
||||||
@ -255,17 +255,17 @@ module Homebrew
|
|||||||
|
|
||||||
return if formulae.empty?
|
return if formulae.empty?
|
||||||
|
|
||||||
Install.perform_preinstall_checks
|
Install.perform_preinstall_checks(cc: args.cc)
|
||||||
|
|
||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f, force: args.force?)
|
||||||
install_formula(f)
|
install_formula(f, args: args)
|
||||||
Cleanup.install_formula_clean!(f)
|
Cleanup.install_formula_clean!(f)
|
||||||
end
|
end
|
||||||
|
|
||||||
check_installed_dependents(args: args)
|
check_installed_dependents(args: args)
|
||||||
|
|
||||||
Homebrew.messages.display_messages
|
Homebrew.messages.display_messages(display_times: args.display_times?)
|
||||||
rescue FormulaUnreadableError, FormulaClassUnavailableError,
|
rescue FormulaUnreadableError, FormulaClassUnavailableError,
|
||||||
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
|
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
|
||||||
# Need to rescue before `FormulaUnavailableError` (superclass of this)
|
# Need to rescue before `FormulaUnavailableError` (superclass of this)
|
||||||
@ -319,12 +319,15 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_formula(f)
|
def install_formula(f, args:)
|
||||||
f.print_tap_action
|
f.print_tap_action
|
||||||
build_options = f.build
|
build_options = f.build
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
||||||
build_from_source: args.build_from_source?)
|
include_test: args.include_test?,
|
||||||
|
include_test_formulae: args.include_test_formulae,
|
||||||
|
build_from_source: args.build_from_source?,
|
||||||
|
build_from_source_formulae: args.build_from_source_formulae)
|
||||||
fi.options = build_options.used_options
|
fi.options = build_options.used_options
|
||||||
fi.env = args.env
|
fi.env = args.env
|
||||||
fi.force = args.force?
|
fi.force = args.force?
|
||||||
|
@ -24,7 +24,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def migrate
|
def migrate
|
||||||
migrate_args.parse
|
args = migrate_args.parse
|
||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.resolved_formulae.each do |f|
|
||||||
if f.oldname
|
if f.oldname
|
||||||
@ -34,7 +34,7 @@ module Homebrew
|
|||||||
raise "#{rack} is a symlink" if rack.symlink?
|
raise "#{rack} is a symlink" if rack.symlink?
|
||||||
end
|
end
|
||||||
|
|
||||||
migrator = Migrator.new(f)
|
migrator = Migrator.new(f, force: args.force?)
|
||||||
migrator.migrate
|
migrator.migrate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
require "development_tools"
|
require "development_tools"
|
||||||
require "messages"
|
require "messages"
|
||||||
|
require "install"
|
||||||
require "reinstall"
|
require "reinstall"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "cleanup"
|
require "cleanup"
|
||||||
@ -56,7 +57,7 @@ module Homebrew
|
|||||||
def reinstall
|
def reinstall
|
||||||
args = reinstall_args.parse
|
args = reinstall_args.parse
|
||||||
|
|
||||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
FormulaInstaller.prevent_build_flags(args)
|
||||||
|
|
||||||
Install.perform_preinstall_checks
|
Install.perform_preinstall_checks
|
||||||
|
|
||||||
@ -66,14 +67,14 @@ module Homebrew
|
|||||||
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f, force: args.force?)
|
||||||
reinstall_formula(f, args: args)
|
reinstall_formula(f, args: args)
|
||||||
Cleanup.install_formula_clean!(f)
|
Cleanup.install_formula_clean!(f)
|
||||||
end
|
end
|
||||||
|
|
||||||
check_installed_dependents(args: args)
|
check_installed_dependents(args: args)
|
||||||
|
|
||||||
Homebrew.messages.display_messages
|
Homebrew.messages.display_messages(display_times: args.display_times?)
|
||||||
|
|
||||||
return if casks.blank?
|
return if casks.blank?
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def uninstall
|
def uninstall
|
||||||
uninstall_args.parse
|
args = uninstall_args.parse
|
||||||
|
|
||||||
if args.force?
|
if args.force?
|
||||||
casks = []
|
casks = []
|
||||||
@ -54,7 +54,9 @@ module Homebrew
|
|||||||
kegs_by_rack = all_kegs.group_by(&:rack)
|
kegs_by_rack = all_kegs.group_by(&:rack)
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_unsatisfied_dependents(kegs_by_rack)
|
handle_unsatisfied_dependents(kegs_by_rack,
|
||||||
|
ignore_dependencies: args.ignore_dependencies?,
|
||||||
|
named_args: args.named)
|
||||||
return if Homebrew.failed?
|
return if Homebrew.failed?
|
||||||
|
|
||||||
kegs_by_rack.each do |rack, kegs|
|
kegs_by_rack.each do |rack, kegs|
|
||||||
@ -142,40 +144,41 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_unsatisfied_dependents(kegs_by_rack)
|
def handle_unsatisfied_dependents(kegs_by_rack, ignore_dependencies: false, named_args: [])
|
||||||
return if args.ignore_dependencies?
|
return if ignore_dependencies
|
||||||
|
|
||||||
all_kegs = kegs_by_rack.values.flatten(1)
|
all_kegs = kegs_by_rack.values.flatten(1)
|
||||||
check_for_dependents all_kegs
|
check_for_dependents(all_kegs, named_args: named_args)
|
||||||
rescue MethodDeprecatedError
|
rescue MethodDeprecatedError
|
||||||
# Silently ignore deprecations when uninstalling.
|
# Silently ignore deprecations when uninstalling.
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_dependents(kegs)
|
def check_for_dependents(kegs, named_args: [])
|
||||||
return false unless result = Keg.find_some_installed_dependents(kegs)
|
return false unless result = Keg.find_some_installed_dependents(kegs)
|
||||||
|
|
||||||
if Homebrew::EnvConfig.developer?
|
if Homebrew::EnvConfig.developer?
|
||||||
DeveloperDependentsMessage.new(*result).output
|
DeveloperDependentsMessage.new(*result, named_args: named_args).output
|
||||||
else
|
else
|
||||||
NondeveloperDependentsMessage.new(*result).output
|
NondeveloperDependentsMessage.new(*result, named_args: named_args).output
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
class DependentsMessage
|
class DependentsMessage
|
||||||
attr_reader :reqs, :deps
|
attr_reader :reqs, :deps, :named_args
|
||||||
|
|
||||||
def initialize(requireds, dependents)
|
def initialize(requireds, dependents, named_args: [])
|
||||||
@reqs = requireds
|
@reqs = requireds
|
||||||
@deps = dependents
|
@deps = dependents
|
||||||
|
@named_args = named_args
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def sample_command
|
def sample_command
|
||||||
"brew uninstall --ignore-dependencies #{Array(Homebrew.args.named).join(" ")}"
|
"brew uninstall --ignore-dependencies #{named_args.join(" ")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def are_required_by_deps
|
def are_required_by_deps
|
||||||
|
@ -38,7 +38,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_report
|
def update_report
|
||||||
update_report_args.parse
|
args = update_report_args.parse
|
||||||
|
|
||||||
if !Utils::Analytics.messages_displayed? &&
|
if !Utils::Analytics.messages_displayed? &&
|
||||||
!Utils::Analytics.disabled? &&
|
!Utils::Analytics.disabled? &&
|
||||||
@ -104,7 +104,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
if reporter.updated?
|
if reporter.updated?
|
||||||
updated_taps << tap.name
|
updated_taps << tap.name
|
||||||
hub.add(reporter)
|
hub.add(reporter, preinstall: args.preinstall?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
hub.dump(updated_formula_report: !args.preinstall?)
|
hub.dump(updated_formula_report: !args.preinstall?)
|
||||||
hub.reporters.each(&:migrate_tap_migration)
|
hub.reporters.each(&:migrate_tap_migration)
|
||||||
hub.reporters.each(&:migrate_formula_rename)
|
hub.reporters.each { |r| r.migrate_formula_rename(force: args.force?) }
|
||||||
CacheStoreDatabase.use(:descriptions) do |db|
|
CacheStoreDatabase.use(:descriptions) do |db|
|
||||||
DescriptionCacheStore.new(db)
|
DescriptionCacheStore.new(db)
|
||||||
.update_from_report!(hub)
|
.update_from_report!(hub)
|
||||||
@ -186,7 +186,7 @@ class Reporter
|
|||||||
raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty?
|
raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def report
|
def report(preinstall: false)
|
||||||
return @report if @report
|
return @report if @report
|
||||||
|
|
||||||
@report = Hash.new { |h, k| h[k] = [] }
|
@report = Hash.new { |h, k| h[k] = [] }
|
||||||
@ -223,7 +223,7 @@ class Reporter
|
|||||||
name = tap.formula_file_to_name(src)
|
name = tap.formula_file_to_name(src)
|
||||||
|
|
||||||
# Skip reporting updated formulae to speed up automatic updates.
|
# Skip reporting updated formulae to speed up automatic updates.
|
||||||
if Homebrew.args.preinstall?
|
if preinstall
|
||||||
@report[:M] << name
|
@report[:M] << name
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@ -373,7 +373,7 @@ class Reporter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def migrate_formula_rename
|
def migrate_formula_rename(force:)
|
||||||
Formula.installed.each do |formula|
|
Formula.installed.each do |formula|
|
||||||
next unless Migrator.needs_migration?(formula)
|
next unless Migrator.needs_migration?(formula)
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ class Reporter
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f, force: force)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -425,9 +425,9 @@ class ReporterHub
|
|||||||
@hash.fetch(key, [])
|
@hash.fetch(key, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def add(reporter)
|
def add(reporter, preinstall: false)
|
||||||
@reporters << reporter
|
@reporters << reporter
|
||||||
report = reporter.report.delete_if { |_k, v| v.empty? }
|
report = reporter.report(preinstall: preinstall).delete_if { |_k, v| v.empty? }
|
||||||
@hash.update(report) { |_key, oldval, newval| oldval.concat(newval) }
|
@hash.update(report) { |_key, oldval, newval| oldval.concat(newval) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ module Homebrew
|
|||||||
named_formulae_specified = !formulae.empty? && casks.empty?
|
named_formulae_specified = !formulae.empty? && casks.empty?
|
||||||
named_casks_specified = !casks.empty? && formulae.empty?
|
named_casks_specified = !casks.empty? && formulae.empty?
|
||||||
|
|
||||||
upgrade_outdated_formulae(formulae) unless named_casks_specified
|
upgrade_outdated_formulae(formulae, args: args) unless named_casks_specified
|
||||||
upgrade_outdated_casks(casks) unless named_formulae_specified
|
upgrade_outdated_casks(casks) unless named_formulae_specified
|
||||||
end
|
end
|
||||||
|
|
||||||
def upgrade_outdated_formulae(formulae)
|
def upgrade_outdated_formulae(formulae, args:)
|
||||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
FormulaInstaller.prevent_build_flags(args)
|
||||||
|
|
||||||
Install.perform_preinstall_checks
|
Install.perform_preinstall_checks
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ module Homebrew
|
|||||||
|
|
||||||
check_installed_dependents(args: args)
|
check_installed_dependents(args: args)
|
||||||
|
|
||||||
Homebrew.messages.display_messages
|
Homebrew.messages.display_messages(display_times: args.display_times?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def upgrade_outdated_casks(casks)
|
def upgrade_outdated_casks(casks)
|
||||||
|
@ -127,6 +127,7 @@ module Homebrew
|
|||||||
}
|
}
|
||||||
options[:style_offenses] = style_results.file_offenses(f.path) if style_results
|
options[:style_offenses] = style_results.file_offenses(f.path) if style_results
|
||||||
options[:display_cop_names] = args.display_cop_names?
|
options[:display_cop_names] = args.display_cop_names?
|
||||||
|
options[:build_stable] = args.build_stable?
|
||||||
|
|
||||||
fa = FormulaAuditor.new(f, options)
|
fa = FormulaAuditor.new(f, options)
|
||||||
fa.audit
|
fa.audit
|
||||||
@ -207,6 +208,7 @@ module Homebrew
|
|||||||
@new_formula = options[:new_formula] && !@versioned_formula
|
@new_formula = options[:new_formula] && !@versioned_formula
|
||||||
@strict = options[:strict]
|
@strict = options[:strict]
|
||||||
@online = options[:online]
|
@online = options[:online]
|
||||||
|
@build_stable = options[:build_stable]
|
||||||
@git = options[:git]
|
@git = options[:git]
|
||||||
@display_cop_names = options[:display_cop_names]
|
@display_cop_names = options[:display_cop_names]
|
||||||
@only = options[:only]
|
@only = options[:only]
|
||||||
@ -248,7 +250,7 @@ module Homebrew
|
|||||||
unversioned_name = unversioned_formula.basename(".rb")
|
unversioned_name = unversioned_formula.basename(".rb")
|
||||||
problem "#{formula} is versioned but no #{unversioned_name} formula exists"
|
problem "#{formula} is versioned but no #{unversioned_name} formula exists"
|
||||||
end
|
end
|
||||||
elsif Homebrew.args.build_stable? && formula.stable? &&
|
elsif @build_stable && formula.stable? &&
|
||||||
!(versioned_formulae = formula.versioned_formulae).empty?
|
!(versioned_formulae = formula.versioned_formulae).empty?
|
||||||
versioned_aliases = formula.aliases.grep(/.@\d/)
|
versioned_aliases = formula.aliases.grep(/.@\d/)
|
||||||
_, last_alias_version = versioned_formulae.map(&:name).last.split("@")
|
_, last_alias_version = versioned_formulae.map(&:name).last.split("@")
|
||||||
|
@ -31,12 +31,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def man
|
def man
|
||||||
man_args.parse
|
args = man_args.parse
|
||||||
|
|
||||||
odie "`brew man --link` is now done automatically by `brew update`." if args.link?
|
odie "`brew man --link` is now done automatically by `brew update`." if args.link?
|
||||||
|
|
||||||
Commands.rebuild_internal_commands_completion_list
|
Commands.rebuild_internal_commands_completion_list
|
||||||
regenerate_man_pages
|
regenerate_man_pages(args: args)
|
||||||
|
|
||||||
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages", "completions"
|
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages", "completions"
|
||||||
puts "No changes to manpage or completions output detected."
|
puts "No changes to manpage or completions output detected."
|
||||||
@ -45,15 +45,15 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def regenerate_man_pages
|
def regenerate_man_pages(args:)
|
||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!
|
||||||
|
|
||||||
markup = build_man_page
|
markup = build_man_page
|
||||||
convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md")
|
convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md", args: args)
|
||||||
convert_man_page(markup, TARGET_MAN_PATH/"brew.1")
|
convert_man_page(markup, TARGET_MAN_PATH/"brew.1", args: args)
|
||||||
|
|
||||||
cask_markup = (SOURCE_PATH/"brew-cask.1.md").read
|
cask_markup = (SOURCE_PATH/"brew-cask.1.md").read
|
||||||
convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1")
|
convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1", args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_man_page
|
def build_man_page
|
||||||
@ -94,7 +94,7 @@ module Homebrew
|
|||||||
path.basename.to_s.sub(/\.(rb|sh)$/, "").sub(/^--/, "~~")
|
path.basename.to_s.sub(/\.(rb|sh)$/, "").sub(/^--/, "~~")
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_man_page(markup, target)
|
def convert_man_page(markup, target, args:)
|
||||||
manual = target.basename(".1")
|
manual = target.basename(".1")
|
||||||
organisation = "Homebrew"
|
organisation = "Homebrew"
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ module Homebrew
|
|||||||
|
|
||||||
def generate_cmd_manpages(cmd_paths)
|
def generate_cmd_manpages(cmd_paths)
|
||||||
man_page_lines = []
|
man_page_lines = []
|
||||||
man_args = Homebrew.args
|
|
||||||
# preserve existing manpage order
|
# preserve existing manpage order
|
||||||
cmd_paths.sort_by(&method(:sort_key_for_path))
|
cmd_paths.sort_by(&method(:sort_key_for_path))
|
||||||
.each do |cmd_path|
|
.each do |cmd_path|
|
||||||
@ -162,7 +162,7 @@ module Homebrew
|
|||||||
|
|
||||||
man_page_lines << cmd_man_page_lines
|
man_page_lines << cmd_man_page_lines
|
||||||
end
|
end
|
||||||
Homebrew.args = man_args
|
|
||||||
man_page_lines.compact.join("\n")
|
man_page_lines.compact.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,15 +32,15 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pr_automerge
|
def pr_automerge
|
||||||
pr_automerge_args.parse
|
args = pr_automerge_args.parse
|
||||||
|
|
||||||
without_labels = Homebrew.args.without_labels || ["do not merge", "new formula"]
|
without_labels = args.without_labels || ["do not merge", "new formula"]
|
||||||
tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name)
|
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
||||||
|
|
||||||
query = "is:pr is:open repo:#{tap.full_name}"
|
query = "is:pr is:open repo:#{tap.full_name}"
|
||||||
query += Homebrew.args.ignore_failures? ? " -status:pending" : " status:success"
|
query += args.ignore_failures? ? " -status:pending" : " status:success"
|
||||||
query += " review:approved" unless Homebrew.args.without_approval?
|
query += " review:approved" unless args.without_approval?
|
||||||
query += " label:\"#{args.with_label}\"" if Homebrew.args.with_label
|
query += " label:\"#{args.with_label}\"" if args.with_label
|
||||||
without_labels&.each { |label| query += " -label:\"#{label}\"" }
|
without_labels&.each { |label| query += " -label:\"#{label}\"" }
|
||||||
odebug "Searching: #{query}"
|
odebug "Searching: #{query}"
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ module Homebrew
|
|||||||
only_cops = args.only_cops
|
only_cops = args.only_cops
|
||||||
except_cops = args.except_cops
|
except_cops = args.except_cops
|
||||||
|
|
||||||
options = { fix: args.fix? }
|
options = { fix: args.fix?, display_cop_names: args.display_cop_names? }
|
||||||
if only_cops
|
if only_cops
|
||||||
options[:only_cops] = only_cops
|
options[:only_cops] = only_cops
|
||||||
elsif except_cops
|
elsif except_cops
|
||||||
|
@ -43,8 +43,8 @@ module Homebrew
|
|||||||
FileUtils.ln_sf ld_so, brew_ld_so
|
FileUtils.ln_sf ld_so, brew_ld_so
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_preinstall_checks(all_fatal: false)
|
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||||
generic_perform_preinstall_checks(all_fatal: all_fatal)
|
generic_perform_preinstall_checks(all_fatal: all_fatal, cc: cc)
|
||||||
symlink_ld_so
|
symlink_ld_so
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module Fetch
|
module Fetch
|
||||||
def fetch_bottle?(f)
|
def fetch_bottle?(f, args:)
|
||||||
return true if args.force_bottle? && f.bottle
|
return true if args.force_bottle? && f.bottle
|
||||||
return false unless f.bottle && f.pour_bottle?
|
return false unless f.bottle && f.pour_bottle?
|
||||||
return false if args.build_formula_from_source?(f)
|
return false if args.build_from_source_formulae.include?(f.full_name)
|
||||||
return false unless f.bottle.compatible_cellar?
|
return false unless f.bottle.compatible_cellar?
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -101,6 +101,10 @@ class Formula
|
|||||||
# @private
|
# @private
|
||||||
attr_reader :tap
|
attr_reader :tap
|
||||||
|
|
||||||
|
# Whether or not to force the use of a bottle.
|
||||||
|
# @private
|
||||||
|
attr_reader :force_bottle
|
||||||
|
|
||||||
# The stable (and default) {SoftwareSpec} for this {Formula}
|
# The stable (and default) {SoftwareSpec} for this {Formula}
|
||||||
# This contains all the attributes (e.g. URL, checksum) that apply to the
|
# This contains all the attributes (e.g. URL, checksum) that apply to the
|
||||||
# stable version of this formula.
|
# stable version of this formula.
|
||||||
@ -181,7 +185,7 @@ class Formula
|
|||||||
alias follow_installed_alias? follow_installed_alias
|
alias follow_installed_alias? follow_installed_alias
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def initialize(name, path, spec, alias_path: nil)
|
def initialize(name, path, spec, alias_path: nil, force_bottle: false)
|
||||||
@name = name
|
@name = name
|
||||||
@path = path
|
@path = path
|
||||||
@alias_path = alias_path
|
@alias_path = alias_path
|
||||||
@ -189,6 +193,8 @@ class Formula
|
|||||||
@revision = self.class.revision || 0
|
@revision = self.class.revision || 0
|
||||||
@version_scheme = self.class.version_scheme || 0
|
@version_scheme = self.class.version_scheme || 0
|
||||||
|
|
||||||
|
@force_bottle = force_bottle
|
||||||
|
|
||||||
@tap = if path == Formulary.core_path(name)
|
@tap = if path == Formulary.core_path(name)
|
||||||
CoreTap.instance
|
CoreTap.instance
|
||||||
else
|
else
|
||||||
@ -2372,6 +2378,16 @@ class Formula
|
|||||||
stable.build
|
stable.build
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get the `BUILD_FLAGS` from the formula's namespace set in `Formulary::load_formula`.
|
||||||
|
# @private
|
||||||
|
def build_flags
|
||||||
|
namespace = to_s.split("::")[0..-2].join("::")
|
||||||
|
return [] if namespace.empty?
|
||||||
|
|
||||||
|
mod = const_get(namespace)
|
||||||
|
mod.const_get(:BUILD_FLAGS)
|
||||||
|
end
|
||||||
|
|
||||||
# @!attribute [w] stable
|
# @!attribute [w] stable
|
||||||
# Allows adding {.depends_on} and {Patch}es just to the {.stable} {SoftwareSpec}.
|
# Allows adding {.depends_on} and {Patch}es just to the {.stable} {SoftwareSpec}.
|
||||||
# This is required instead of using a conditional.
|
# This is required instead of using a conditional.
|
||||||
@ -2385,7 +2401,7 @@ class Formula
|
|||||||
# depends_on "libffi"
|
# depends_on "libffi"
|
||||||
# end</pre>
|
# end</pre>
|
||||||
def stable(&block)
|
def stable(&block)
|
||||||
@stable ||= SoftwareSpec.new
|
@stable ||= SoftwareSpec.new(flags: build_flags)
|
||||||
return @stable unless block_given?
|
return @stable unless block_given?
|
||||||
|
|
||||||
@stable.instance_eval(&block)
|
@stable.instance_eval(&block)
|
||||||
@ -2405,7 +2421,7 @@ class Formula
|
|||||||
# end</pre>
|
# end</pre>
|
||||||
# @private
|
# @private
|
||||||
def devel(&block)
|
def devel(&block)
|
||||||
@devel ||= SoftwareSpec.new
|
@devel ||= SoftwareSpec.new(flags: build_flags)
|
||||||
return @devel unless block_given?
|
return @devel unless block_given?
|
||||||
|
|
||||||
odeprecated "'devel' blocks in formulae", "'head' blocks or @-versioned formulae"
|
odeprecated "'devel' blocks in formulae", "'head' blocks or @-versioned formulae"
|
||||||
@ -2425,7 +2441,7 @@ class Formula
|
|||||||
# or (if autodetect fails):
|
# or (if autodetect fails):
|
||||||
# <pre>head "https://hg.is.awesome.but.git.has.won.example.com/", :using => :hg</pre>
|
# <pre>head "https://hg.is.awesome.but.git.has.won.example.com/", :using => :hg</pre>
|
||||||
def head(val = nil, specs = {}, &block)
|
def head(val = nil, specs = {}, &block)
|
||||||
@head ||= HeadSoftwareSpec.new
|
@head ||= HeadSoftwareSpec.new(flags: build_flags)
|
||||||
if block_given?
|
if block_given?
|
||||||
@head.instance_eval(&block)
|
@head.instance_eval(&block)
|
||||||
elsif val
|
elsif val
|
||||||
|
@ -21,6 +21,7 @@ require "cmd/install"
|
|||||||
require "find"
|
require "find"
|
||||||
|
|
||||||
class FormulaInstaller
|
class FormulaInstaller
|
||||||
|
include Homebrew::Install
|
||||||
include FormulaCellarChecks
|
include FormulaCellarChecks
|
||||||
extend Predicable
|
extend Predicable
|
||||||
|
|
||||||
@ -39,14 +40,19 @@ class FormulaInstaller
|
|||||||
|
|
||||||
attr_reader :formula
|
attr_reader :formula
|
||||||
attr_accessor :cc, :env, :options, :build_bottle, :bottle_arch,
|
attr_accessor :cc, :env, :options, :build_bottle, :bottle_arch,
|
||||||
:installed_as_dependency, :installed_on_request, :link_keg
|
:build_from_source_formulae, :include_test_formulae,
|
||||||
|
:installed_as_dependency, :installed_on_request, :link_keg, :other_installers
|
||||||
|
|
||||||
mode_attr_accessor :show_summary_heading, :show_header
|
mode_attr_accessor :show_summary_heading, :show_header
|
||||||
mode_attr_accessor :build_from_source, :force_bottle, :include_test
|
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 :ignore_deps, :only_deps, :interactive, :git, :force, :keep_tmp
|
||||||
mode_attr_accessor :verbose, :debug, :quiet
|
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, include_test_formulae: [],
|
||||||
|
build_from_source: false, build_from_source_formulae: [],
|
||||||
|
cc: nil)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@env = nil
|
@env = nil
|
||||||
@force = false
|
@force = false
|
||||||
@ -56,10 +62,12 @@ class FormulaInstaller
|
|||||||
@ignore_deps = false
|
@ignore_deps = false
|
||||||
@only_deps = false
|
@only_deps = false
|
||||||
@build_from_source = build_from_source
|
@build_from_source = build_from_source
|
||||||
|
@build_from_source_formulae = build_from_source_formulae
|
||||||
@build_bottle = false
|
@build_bottle = false
|
||||||
@bottle_arch = nil
|
@bottle_arch = nil
|
||||||
@force_bottle = force_bottle
|
@force_bottle = force_bottle
|
||||||
@include_test = include_test
|
@include_test = include_test
|
||||||
|
@include_test_formulae = include_test_formulae
|
||||||
@interactive = false
|
@interactive = false
|
||||||
@git = false
|
@git = false
|
||||||
@cc = cc
|
@cc = cc
|
||||||
@ -93,12 +101,20 @@ class FormulaInstaller
|
|||||||
|
|
||||||
# When no build tools are available and build flags are passed through ARGV,
|
# When no build tools are available and build flags are passed through ARGV,
|
||||||
# it's necessary to interrupt the user before any sort of installation
|
# it's necessary to interrupt the user before any sort of installation
|
||||||
# can proceed. Only invoked when the user has no developer tools.
|
# can proceed. Only raises when the user has no developer tools.
|
||||||
def self.prevent_build_flags
|
def self.prevent_build_flags(args)
|
||||||
build_flags = Homebrew.args.collect_build_args
|
return if DevelopmentTools.installed?
|
||||||
|
|
||||||
|
build_flags = []
|
||||||
|
|
||||||
|
build_flags << "--HEAD" if args.HEAD?
|
||||||
|
build_flags << "--universal" if args.universal?
|
||||||
|
build_flags << "--build-bottle" if args.build_bottle?
|
||||||
|
build_flags << "--build-from-source" if args.build_from_source?
|
||||||
|
|
||||||
return if build_flags.empty?
|
return if build_flags.empty?
|
||||||
|
|
||||||
all_bottled = Homebrew.args.formulae.all?(&:bottled?)
|
all_bottled = args.formulae.all?(&:bottled?)
|
||||||
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
|
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -144,7 +160,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
def install_bottle_for?(dep, build)
|
def install_bottle_for?(dep, build)
|
||||||
return pour_bottle? if dep == formula
|
return pour_bottle? if dep == formula
|
||||||
return false if Homebrew.args.build_formula_from_source?(dep)
|
return false if build_from_source_formulae.include?(dep.full_name)
|
||||||
return false unless dep.bottle && dep.pour_bottle?
|
return false unless dep.bottle && dep.pour_bottle?
|
||||||
return false unless build.used_options.empty?
|
return false unless build.used_options.empty?
|
||||||
return false unless dep.bottle.compatible_cellar?
|
return false unless dep.bottle.compatible_cellar?
|
||||||
@ -239,9 +255,7 @@ class FormulaInstaller
|
|||||||
lock
|
lock
|
||||||
|
|
||||||
start_time = Time.now
|
start_time = Time.now
|
||||||
if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
|
perform_build_from_source_checks if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
|
||||||
Homebrew::Install.perform_build_from_source_checks
|
|
||||||
end
|
|
||||||
|
|
||||||
# not in initialize so upgrade can unlink the active keg before calling this
|
# not in initialize so upgrade can unlink the active keg before calling this
|
||||||
# function but after instantiating this class so that it can avoid having to
|
# function but after instantiating this class so that it can avoid having to
|
||||||
@ -475,7 +489,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
if req.prune_from_option?(build)
|
if req.prune_from_option?(build)
|
||||||
Requirement.prune
|
Requirement.prune
|
||||||
elsif req.satisfied?(args: Homebrew.args)
|
elsif req.satisfied?(env: env, cc: cc, build_bottle: @build_bottle, bottle_arch: bottle_arch)
|
||||||
Requirement.prune
|
Requirement.prune
|
||||||
elsif (req.build? || req.test?) && !keep_build_test
|
elsif (req.build? || req.test?) && !keep_build_test
|
||||||
Requirement.prune
|
Requirement.prune
|
||||||
@ -505,7 +519,7 @@ class FormulaInstaller
|
|||||||
)
|
)
|
||||||
|
|
||||||
keep_build_test = false
|
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? && include_test_formulae.include?(dependent.full_name)
|
||||||
keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed?
|
keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed?
|
||||||
|
|
||||||
if dep.prune_from_option?(build)
|
if dep.prune_from_option?(build)
|
||||||
@ -583,8 +597,8 @@ class FormulaInstaller
|
|||||||
def fetch_dependency(dep)
|
def fetch_dependency(dep)
|
||||||
df = dep.to_formula
|
df = dep.to_formula
|
||||||
fi = FormulaInstaller.new(df, force_bottle: false,
|
fi = FormulaInstaller.new(df, force_bottle: false,
|
||||||
include_test: Homebrew.args.include_formula_test_deps?(df),
|
include_test: include_test_formulae.include?(df.full_name),
|
||||||
build_from_source: Homebrew.args.build_formula_from_source?(df))
|
build_from_source: build_from_source_formulae.include?(df.full_name))
|
||||||
|
|
||||||
fi.force = force?
|
fi.force = force?
|
||||||
fi.keep_tmp = keep_tmp?
|
fi.keep_tmp = keep_tmp?
|
||||||
@ -624,8 +638,8 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
fi = FormulaInstaller.new(df, force_bottle: false,
|
fi = FormulaInstaller.new(df, force_bottle: false,
|
||||||
include_test: Homebrew.args.include_formula_test_deps?(df),
|
include_test: include_test_formulae.include?(df.full_name),
|
||||||
build_from_source: Homebrew.args.build_formula_from_source?(df))
|
build_from_source: build_from_source_formulae.include?(df.full_name))
|
||||||
|
|
||||||
fi.options |= tab.used_options
|
fi.options |= tab.used_options
|
||||||
fi.options |= Tab.remap_deprecated_options(df.deprecated_options, dep.options)
|
fi.options |= Tab.remap_deprecated_options(df.deprecated_options, dep.options)
|
||||||
@ -763,12 +777,6 @@ class FormulaInstaller
|
|||||||
args << "--devel"
|
args << "--devel"
|
||||||
end
|
end
|
||||||
|
|
||||||
formula.options.each do |opt|
|
|
||||||
name = opt.name[/^([^=]+)=$/, 1]
|
|
||||||
value = Homebrew.args.value(name) if name
|
|
||||||
args << "--#{name}=#{value}" if value
|
|
||||||
end
|
|
||||||
|
|
||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,12 +27,16 @@ module Formulary
|
|||||||
cache.fetch(path)
|
cache.fetch(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_formula(name, path, contents, namespace)
|
def self.load_formula(name, path, contents, namespace, flags:)
|
||||||
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if Homebrew::EnvConfig.disable_load_formula?
|
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if Homebrew::EnvConfig.disable_load_formula?
|
||||||
|
|
||||||
mod = Module.new
|
mod = Module.new
|
||||||
const_set(namespace, mod)
|
const_set(namespace, mod)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
# Set `BUILD_FLAGS` in the formula's namespace so we can
|
||||||
|
# access them from within the formula's class scope.
|
||||||
|
mod.const_set(:BUILD_FLAGS, flags)
|
||||||
mod.module_eval(contents, path)
|
mod.module_eval(contents, path)
|
||||||
rescue NameError, ArgumentError, ScriptError => e
|
rescue NameError, ArgumentError, ScriptError => e
|
||||||
$stderr.puts e.backtrace if Homebrew::EnvConfig.developer?
|
$stderr.puts e.backtrace if Homebrew::EnvConfig.developer?
|
||||||
@ -51,16 +55,16 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_formula_from_path(name, path)
|
def self.load_formula_from_path(name, path, flags:)
|
||||||
contents = path.open("r") { |f| ensure_utf8_encoding(f).read }
|
contents = path.open("r") { |f| ensure_utf8_encoding(f).read }
|
||||||
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(path.to_s)}"
|
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(path.to_s)}"
|
||||||
klass = load_formula(name, path, contents, namespace)
|
klass = load_formula(name, path, contents, namespace, flags: flags)
|
||||||
cache[path] = klass
|
cache[path] = klass
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.resolve(name, spec: nil)
|
def self.resolve(name, spec: nil, force_bottle: false, flags: [])
|
||||||
if name.include?("/") || File.exist?(name)
|
if name.include?("/") || File.exist?(name)
|
||||||
f = factory(name, *spec)
|
f = factory(name, *spec, force_bottle: force_bottle, flags: flags)
|
||||||
if f.any_version_installed?
|
if f.any_version_installed?
|
||||||
tab = Tab.for_formula(f)
|
tab = Tab.for_formula(f)
|
||||||
resolved_spec = spec || tab.spec
|
resolved_spec = spec || tab.spec
|
||||||
@ -73,8 +77,8 @@ module Formulary
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
rack = to_rack(name)
|
rack = to_rack(name)
|
||||||
alias_path = factory(name).alias_path
|
alias_path = factory(name, force_bottle: force_bottle, flags: flags).alias_path
|
||||||
f = from_rack(rack, *spec, alias_path: alias_path)
|
f = from_rack(rack, *spec, alias_path: alias_path, force_bottle: force_bottle, flags: flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
# If this formula was installed with an alias that has since changed,
|
# If this formula was installed with an alias that has since changed,
|
||||||
@ -121,22 +125,23 @@ module Formulary
|
|||||||
#
|
#
|
||||||
# `alias_path` can be overridden here in case an alias was used to refer to
|
# `alias_path` can be overridden here in case an alias was used to refer to
|
||||||
# a formula that was loaded in another way.
|
# a formula that was loaded in another way.
|
||||||
def get_formula(spec, alias_path: nil)
|
def get_formula(spec, alias_path: nil, force_bottle: false, flags: [])
|
||||||
klass.new(name, path, spec, alias_path: alias_path || self.alias_path)
|
alias_path ||= self.alias_path
|
||||||
|
klass(flags: flags).new(name, path, spec, alias_path: alias_path, force_bottle: force_bottle)
|
||||||
end
|
end
|
||||||
|
|
||||||
def klass
|
def klass(flags:)
|
||||||
load_file unless Formulary.formula_class_defined?(path)
|
load_file(flags: flags) unless Formulary.formula_class_defined?(path)
|
||||||
Formulary.formula_class_get(path)
|
Formulary.formula_class_get(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_file
|
def load_file(flags:)
|
||||||
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{path}" if Homebrew.args.debug?
|
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{path}" if Homebrew.args.debug?
|
||||||
raise FormulaUnavailableError, name unless path.file?
|
raise FormulaUnavailableError, name unless path.file?
|
||||||
|
|
||||||
Formulary.load_formula_from_path(name, path)
|
Formulary.load_formula_from_path(name, path, flags: flags)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,10 +166,10 @@ module Formulary
|
|||||||
super name, Formulary.path(full_name)
|
super name, Formulary.path(full_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_formula(spec, **)
|
def get_formula(spec, force_bottle: false, flags: [], **)
|
||||||
contents = Utils::Bottles.formula_contents @bottle_filename, name: name
|
contents = Utils::Bottles.formula_contents @bottle_filename, name: name
|
||||||
formula = begin
|
formula = begin
|
||||||
Formulary.from_contents name, @bottle_filename, contents, spec
|
Formulary.from_contents(name, @bottle_filename, contents, spec, force_bottle: force_bottle, flags: flags)
|
||||||
rescue FormulaUnreadableError => e
|
rescue FormulaUnreadableError => e
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
Unreadable formula in #{@bottle_filename}:
|
Unreadable formula in #{@bottle_filename}:
|
||||||
@ -205,7 +210,7 @@ module Formulary
|
|||||||
super formula, HOMEBREW_CACHE_FORMULA/File.basename(uri.path)
|
super formula, HOMEBREW_CACHE_FORMULA/File.basename(uri.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_file
|
def load_file(flags:)
|
||||||
if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb}
|
if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb}
|
||||||
formula_name = Regexp.last_match(2)
|
formula_name = Regexp.last_match(2)
|
||||||
odeprecated "Installation of #{formula_name} from a GitHub commit URL",
|
odeprecated "Installation of #{formula_name} from a GitHub commit URL",
|
||||||
@ -270,7 +275,7 @@ module Formulary
|
|||||||
[name, path]
|
[name, path]
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_formula(spec, alias_path: nil)
|
def get_formula(spec, alias_path: nil, force_bottle: false, flags: [])
|
||||||
super
|
super
|
||||||
rescue FormulaUnreadableError => e
|
rescue FormulaUnreadableError => e
|
||||||
raise TapFormulaUnreadableError.new(tap, name, e.formula_error), "", e.backtrace
|
raise TapFormulaUnreadableError.new(tap, name, e.formula_error), "", e.backtrace
|
||||||
@ -280,7 +285,7 @@ module Formulary
|
|||||||
raise TapFormulaUnavailableError.new(tap, name), "", e.backtrace
|
raise TapFormulaUnavailableError.new(tap, name), "", e.backtrace
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_file
|
def load_file(flags:)
|
||||||
super
|
super
|
||||||
rescue MethodDeprecatedError => e
|
rescue MethodDeprecatedError => e
|
||||||
e.issues_url = tap.issues_url || tap.to_s
|
e.issues_url = tap.issues_url || tap.to_s
|
||||||
@ -308,10 +313,10 @@ module Formulary
|
|||||||
super name, path
|
super name, path
|
||||||
end
|
end
|
||||||
|
|
||||||
def klass
|
def klass(flags:)
|
||||||
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{path}" if Homebrew.args.debug?
|
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{path}" if Homebrew.args.debug?
|
||||||
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(contents)}"
|
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(contents.to_s)}"
|
||||||
Formulary.load_formula(name, path, contents, namespace)
|
Formulary.load_formula(name, path, contents, namespace, flags: flags)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -322,7 +327,7 @@ module Formulary
|
|||||||
# * a formula pathname
|
# * a formula pathname
|
||||||
# * a formula URL
|
# * a formula URL
|
||||||
# * a local bottle reference
|
# * a local bottle reference
|
||||||
def self.factory(ref, spec = :stable, alias_path: nil, from: nil)
|
def self.factory(ref, spec = :stable, alias_path: nil, from: nil, force_bottle: false, flags: [])
|
||||||
raise ArgumentError, "Formulae must have a ref!" unless ref
|
raise ArgumentError, "Formulae must have a ref!" unless ref
|
||||||
|
|
||||||
cache_key = "#{ref}-#{spec}-#{alias_path}-#{from}"
|
cache_key = "#{ref}-#{spec}-#{alias_path}-#{from}"
|
||||||
@ -331,7 +336,8 @@ module Formulary
|
|||||||
return cache[:formulary_factory][cache_key]
|
return cache[:formulary_factory][cache_key]
|
||||||
end
|
end
|
||||||
|
|
||||||
formula = loader_for(ref, from: from).get_formula(spec, alias_path: alias_path)
|
formula = loader_for(ref, from: from).get_formula(spec, alias_path: alias_path,
|
||||||
|
force_bottle: force_bottle, flags: flags)
|
||||||
if factory_cached?
|
if factory_cached?
|
||||||
cache[:formulary_factory] ||= {}
|
cache[:formulary_factory] ||= {}
|
||||||
cache[:formulary_factory][cache_key] ||= formula
|
cache[:formulary_factory][cache_key] ||= formula
|
||||||
@ -345,14 +351,15 @@ module Formulary
|
|||||||
# The :alias_path option will be used if the formula is found not to be
|
# The :alias_path option will be used if the formula is found not to be
|
||||||
# installed, and discarded if it is installed because the alias_path used
|
# installed, and discarded if it is installed because the alias_path used
|
||||||
# to install the formula will be set instead.
|
# to install the formula will be set instead.
|
||||||
def self.from_rack(rack, spec = nil, alias_path: nil)
|
def self.from_rack(rack, spec = nil, alias_path: nil, force_bottle: false, flags: [])
|
||||||
kegs = rack.directory? ? rack.subdirs.map { |d| Keg.new(d) } : []
|
kegs = rack.directory? ? rack.subdirs.map { |d| Keg.new(d) } : []
|
||||||
keg = kegs.find(&:linked?) || kegs.find(&:optlinked?) || kegs.max_by(&:version)
|
keg = kegs.find(&:linked?) || kegs.find(&:optlinked?) || kegs.max_by(&:version)
|
||||||
|
|
||||||
if keg
|
if keg
|
||||||
from_keg(keg, spec, alias_path: alias_path)
|
from_keg(keg, spec, alias_path: alias_path)
|
||||||
else
|
else
|
||||||
factory(rack.basename.to_s, spec || :stable, alias_path: alias_path, from: :rack)
|
factory(rack.basename.to_s, spec || :stable, alias_path: alias_path, from: :rack,
|
||||||
|
force_bottle: force_bottle, flags: flags)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -365,19 +372,22 @@ module Formulary
|
|||||||
|
|
||||||
# Return a Formula instance for the given keg.
|
# Return a Formula instance for the given keg.
|
||||||
# It will auto resolve formula's spec when requested spec is nil
|
# It will auto resolve formula's spec when requested spec is nil
|
||||||
def self.from_keg(keg, spec = nil, alias_path: nil)
|
def self.from_keg(keg, spec = nil, alias_path: nil, force_bottle: false, flags: [])
|
||||||
tab = Tab.for_keg(keg)
|
tab = Tab.for_keg(keg)
|
||||||
tap = tab.tap
|
tap = tab.tap
|
||||||
spec ||= tab.spec
|
spec ||= tab.spec
|
||||||
|
|
||||||
f = if tap.nil?
|
f = if tap.nil?
|
||||||
factory(keg.rack.basename.to_s, spec, alias_path: alias_path, from: :keg)
|
factory(keg.rack.basename.to_s, spec, alias_path: alias_path, from: :keg,
|
||||||
|
force_bottle: force_bottle, flags: flags)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
factory("#{tap}/#{keg.rack.basename}", spec, alias_path: alias_path, from: :keg)
|
factory("#{tap}/#{keg.rack.basename}", spec, alias_path: alias_path, from: :keg,
|
||||||
|
force_bottle: force_bottle, flags: flags)
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
# formula may be migrated to different tap. Try to search in core and all taps.
|
# formula may be migrated to different tap. Try to search in core and all taps.
|
||||||
factory(keg.rack.basename.to_s, spec, alias_path: alias_path, from: :keg)
|
factory(keg.rack.basename.to_s, spec, alias_path: alias_path, from: :keg,
|
||||||
|
force_bottle: force_bottle, flags: flags)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
f.build = tab
|
f.build = tab
|
||||||
@ -387,8 +397,9 @@ module Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Return a Formula instance directly from contents
|
# Return a Formula instance directly from contents
|
||||||
def self.from_contents(name, path, contents, spec = :stable)
|
def self.from_contents(name, path, contents, spec = :stable, alias_path: nil, force_bottle: false, flags: [])
|
||||||
FormulaContentsLoader.new(name, path, contents).get_formula(spec)
|
FormulaContentsLoader.new(name, path, contents)
|
||||||
|
.get_formula(spec, alias_path: alias_path, force_bottle: force_bottle, flags: flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.to_rack(ref)
|
def self.to_rack(ref)
|
||||||
|
@ -39,20 +39,20 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_cc_argv
|
def check_cc_argv(cc)
|
||||||
return unless Homebrew.args.cc
|
return unless cc
|
||||||
|
|
||||||
@checks ||= Diagnostic::Checks.new
|
@checks ||= Diagnostic::Checks.new
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
You passed `--cc=#{Homebrew.args.cc}`.
|
You passed `--cc=#{cc}`.
|
||||||
#{@checks.please_create_pull_requests}
|
#{@checks.please_create_pull_requests}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_preinstall_checks(all_fatal: false)
|
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||||
check_cpu
|
check_cpu
|
||||||
attempt_directory_creation
|
attempt_directory_creation
|
||||||
check_cc_argv
|
check_cc_argv(cc)
|
||||||
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
|
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
|
||||||
diagnostic_checks(:fatal_preinstall_checks)
|
diagnostic_checks(:fatal_preinstall_checks)
|
||||||
end
|
end
|
||||||
|
@ -20,9 +20,9 @@ class Messages
|
|||||||
@install_times.push(formula: f.name, time: elapsed_time)
|
@install_times.push(formula: f.name, time: elapsed_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_messages
|
def display_messages(display_times: false)
|
||||||
display_caveats
|
display_caveats
|
||||||
display_install_times if Homebrew.args.display_times?
|
display_install_times if display_times
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_caveats
|
def display_caveats
|
||||||
|
@ -97,18 +97,18 @@ class Migrator
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.migrate_if_needed(formula)
|
def self.migrate_if_needed(formula, force:)
|
||||||
return unless Migrator.needs_migration?(formula)
|
return unless Migrator.needs_migration?(formula)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
migrator = Migrator.new(formula)
|
migrator = Migrator.new(formula, force: force)
|
||||||
migrator.migrate
|
migrator.migrate
|
||||||
rescue => e
|
rescue => e
|
||||||
onoe e
|
onoe e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(formula, force: Homebrew.args.force?)
|
def initialize(formula, force: false)
|
||||||
@oldname = formula.oldname
|
@oldname = formula.oldname
|
||||||
@newname = formula.name
|
@newname = formula.name
|
||||||
raise MigratorNoOldnameError, formula unless oldname
|
raise MigratorNoOldnameError, formula unless oldname
|
||||||
|
@ -159,6 +159,10 @@ class ExternalPatch
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue ErrorDuringExecution => e
|
||||||
|
f = resource.owner.owner
|
||||||
|
cmd, *args = e.cmd
|
||||||
|
raise BuildError.new(f, cmd, args, ENV.to_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
|
@ -10,13 +10,13 @@ require "cli/parser"
|
|||||||
require "cmd/postinstall"
|
require "cmd/postinstall"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Homebrew.postinstall_args.parse
|
args = Homebrew.postinstall_args.parse
|
||||||
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
|
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
|
||||||
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
||||||
|
|
||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = Homebrew.args.resolved_formulae.first
|
formula = args.resolved_formulae.first
|
||||||
formula.extend(Debrew::Formula) if Homebrew.args.debug?
|
formula.extend(Debrew::Formula) if Homebrew.args.debug?
|
||||||
formula.run_post_install
|
formula.run_post_install
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
|
@ -18,13 +18,14 @@ module Homebrew
|
|||||||
backup keg
|
backup keg
|
||||||
end
|
end
|
||||||
|
|
||||||
build_options = BuildOptions.new(Options.create(Homebrew.args.flags_only), f.options)
|
build_options = BuildOptions.new(Options.create(args.flags_only), f.options)
|
||||||
options = build_options.used_options
|
options = build_options.used_options
|
||||||
options |= f.build.used_options
|
options |= f.build.used_options
|
||||||
options &= f.options
|
options &= f.options
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, include_test: args.include_test?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
||||||
build_from_source: args.build_from_source?)
|
build_from_source: args.build_from_source?,
|
||||||
|
build_from_source_formulae: args.build_from_source_formulae)
|
||||||
fi.options = options
|
fi.options = options
|
||||||
fi.force = args.force?
|
fi.force = args.force?
|
||||||
fi.keep_tmp = args.keep_tmp?
|
fi.keep_tmp = args.keep_tmp?
|
||||||
|
@ -53,11 +53,14 @@ class Requirement
|
|||||||
|
|
||||||
# Overriding {#satisfied?} is unsupported.
|
# Overriding {#satisfied?} is unsupported.
|
||||||
# Pass a block or boolean to the satisfy DSL method instead.
|
# Pass a block or boolean to the satisfy DSL method instead.
|
||||||
def satisfied?(args: nil)
|
def satisfied?(env: nil, cc: nil, build_bottle: false, bottle_arch: nil)
|
||||||
satisfy = self.class.satisfy
|
satisfy = self.class.satisfy
|
||||||
return true unless satisfy
|
return true unless satisfy
|
||||||
|
|
||||||
@satisfied_result = satisfy.yielder(args: args) { |p| instance_eval(&p) }
|
@satisfied_result =
|
||||||
|
satisfy.yielder(env: env, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch) do |p|
|
||||||
|
instance_eval(&p)
|
||||||
|
end
|
||||||
return false unless @satisfied_result
|
return false unless @satisfied_result
|
||||||
|
|
||||||
true
|
true
|
||||||
@ -81,8 +84,8 @@ class Requirement
|
|||||||
|
|
||||||
# Overriding {#modify_build_environment} is unsupported.
|
# Overriding {#modify_build_environment} is unsupported.
|
||||||
# Pass a block to the env DSL method instead.
|
# Pass a block to the env DSL method instead.
|
||||||
def modify_build_environment(args:)
|
def modify_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil)
|
||||||
satisfied?(args: args)
|
satisfied?(env: env, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch)
|
||||||
instance_eval(&env_proc) if env_proc
|
instance_eval(&env_proc) if env_proc
|
||||||
|
|
||||||
# XXX If the satisfy block returns a Pathname, then make sure that it
|
# XXX If the satisfy block returns a Pathname, then make sure that it
|
||||||
@ -185,13 +188,13 @@ class Requirement
|
|||||||
@proc = block
|
@proc = block
|
||||||
end
|
end
|
||||||
|
|
||||||
def yielder(args:)
|
def yielder(env: nil, cc: nil, build_bottle: false, bottle_arch: nil)
|
||||||
if instance_variable_defined?(:@satisfied)
|
if instance_variable_defined?(:@satisfied)
|
||||||
@satisfied
|
@satisfied
|
||||||
elsif @options[:build_env]
|
elsif @options[:build_env]
|
||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
ENV.with_build_environment(
|
ENV.with_build_environment(
|
||||||
env: args.env, cc: args.cc, build_bottle: args.build_bottle?, bottle_arch: args.bottle_arch,
|
env: env, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
|
||||||
) do
|
) do
|
||||||
yield @proc
|
yield @proc
|
||||||
end
|
end
|
||||||
|
@ -28,14 +28,14 @@ class SoftwareSpec
|
|||||||
:cached_download, :clear_cache, :checksum, :mirrors, :specs, :using, :version, :mirror,
|
:cached_download, :clear_cache, :checksum, :mirrors, :specs, :using, :version, :mirror,
|
||||||
:downloader, *Checksum::TYPES
|
:downloader, *Checksum::TYPES
|
||||||
|
|
||||||
def initialize
|
def initialize(flags: [])
|
||||||
@resource = Resource.new
|
@resource = Resource.new
|
||||||
@resources = {}
|
@resources = {}
|
||||||
@dependency_collector = DependencyCollector.new
|
@dependency_collector = DependencyCollector.new
|
||||||
@bottle_specification = BottleSpecification.new
|
@bottle_specification = BottleSpecification.new
|
||||||
@patches = []
|
@patches = []
|
||||||
@options = Options.new
|
@options = Options.new
|
||||||
@flags = Homebrew.args.flags_only
|
@flags = flags
|
||||||
@deprecated_flags = []
|
@deprecated_flags = []
|
||||||
@deprecated_options = []
|
@deprecated_options = []
|
||||||
@build = BuildOptions.new(Options.create(@flags), options)
|
@build = BuildOptions.new(Options.create(@flags), options)
|
||||||
@ -87,7 +87,7 @@ class SoftwareSpec
|
|||||||
|
|
||||||
def bottled?
|
def bottled?
|
||||||
bottle_specification.tag?(Utils::Bottles.tag) && \
|
bottle_specification.tag?(Utils::Bottles.tag) && \
|
||||||
(bottle_specification.compatible_cellar? || Homebrew.args.force_bottle?)
|
(bottle_specification.compatible_cellar? || owner.force_bottle)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle(disable_type = nil, disable_reason = nil, &block)
|
def bottle(disable_type = nil, disable_reason = nil, &block)
|
||||||
@ -234,7 +234,7 @@ class SoftwareSpec
|
|||||||
end
|
end
|
||||||
|
|
||||||
class HeadSoftwareSpec < SoftwareSpec
|
class HeadSoftwareSpec < SoftwareSpec
|
||||||
def initialize
|
def initialize(flags: [])
|
||||||
super
|
super
|
||||||
@resource.version = Version.create("HEAD")
|
@resource.version = Version.create("HEAD")
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ module Homebrew
|
|||||||
check_style_impl(files, :json, **options)
|
check_style_impl(files, :json, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_style_impl(files, output_type, fix: false, except_cops: nil, only_cops: nil)
|
def check_style_impl(files, output_type, fix: false, except_cops: nil, only_cops: nil, display_cop_names: false)
|
||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!
|
||||||
require "rubocop"
|
require "rubocop"
|
||||||
require "rubocops"
|
require "rubocops"
|
||||||
@ -78,7 +78,7 @@ module Homebrew
|
|||||||
case output_type
|
case output_type
|
||||||
when :print
|
when :print
|
||||||
args << "--debug" if Homebrew.args.debug?
|
args << "--debug" if Homebrew.args.debug?
|
||||||
args << "--display-cop-names" if Homebrew.args.display_cop_names?
|
args << "--display-cop-names" if display_cop_names
|
||||||
args << "--format" << "simple" if files.present?
|
args << "--format" << "simple" if files.present?
|
||||||
system(cache_env, "rubocop", *args)
|
system(cache_env, "rubocop", *args)
|
||||||
rubocop_success = $CHILD_STATUS.success?
|
rubocop_success = $CHILD_STATUS.success?
|
||||||
|
@ -28,7 +28,7 @@ describe Homebrew do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:opts) { { dependency.rack => [Keg.new(dependency.installed_prefix)] } }
|
let(:kegs_by_rack) { { dependency.rack => [Keg.new(dependency.installed_prefix)] } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
[dependency, dependent].each do |f|
|
[dependency, dependent].each do |f|
|
||||||
@ -53,7 +53,7 @@ describe Homebrew do
|
|||||||
ENV["HOMEBREW_DEVELOPER"] = "1"
|
ENV["HOMEBREW_DEVELOPER"] = "1"
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
described_class.handle_unsatisfied_dependents(opts)
|
described_class.handle_unsatisfied_dependents(kegs_by_rack)
|
||||||
}.to output(/Warning/).to_stderr
|
}.to output(/Warning/).to_stderr
|
||||||
|
|
||||||
expect(described_class).not_to have_failed
|
expect(described_class).not_to have_failed
|
||||||
@ -61,19 +61,15 @@ describe Homebrew do
|
|||||||
|
|
||||||
specify "when not developer" do
|
specify "when not developer" do
|
||||||
expect {
|
expect {
|
||||||
described_class.handle_unsatisfied_dependents(opts)
|
described_class.handle_unsatisfied_dependents(kegs_by_rack)
|
||||||
}.to output(/Error/).to_stderr
|
}.to output(/Error/).to_stderr
|
||||||
|
|
||||||
expect(described_class).to have_failed
|
expect(described_class).to have_failed
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "when not developer and --ignore-dependencies is specified" do
|
specify "when not developer and `ignore_dependencies` is true" do
|
||||||
described_class.args = described_class.args.dup if described_class.args.frozen?
|
|
||||||
expect(described_class.args).to receive(:ignore_dependencies?).and_return(true)
|
|
||||||
described_class.args.freeze
|
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
described_class.handle_unsatisfied_dependents(opts)
|
described_class.handle_unsatisfied_dependents(kegs_by_rack, ignore_dependencies: true)
|
||||||
}.not_to output.to_stderr
|
}.not_to output.to_stderr
|
||||||
|
|
||||||
expect(described_class).not_to have_failed
|
expect(described_class).not_to have_failed
|
||||||
|
@ -16,7 +16,7 @@ describe Formulary do
|
|||||||
bottle do
|
bottle do
|
||||||
cellar :any_skip_relocation
|
cellar :any_skip_relocation
|
||||||
root_url "file://#{bottle_dir}"
|
root_url "file://#{bottle_dir}"
|
||||||
sha256 "d48bbbe583dcfbfa608579724fc6f0328b3cd316935c6ea22f134610aaf2952f" => :#{Utils::Bottles.tag}
|
sha256 "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149" => :#{Utils::Bottles.tag}
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
|
@ -41,16 +41,14 @@ describe JavaRequirement do
|
|||||||
describe "#satisfied?" do
|
describe "#satisfied?" do
|
||||||
subject { described_class.new(%w[1.8]) }
|
subject { described_class.new(%w[1.8]) }
|
||||||
|
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
it "returns false if no `java` executable can be found" do
|
it "returns false if no `java` executable can be found" do
|
||||||
allow(File).to receive(:executable?).and_return(false)
|
allow(File).to receive(:executable?).and_return(false)
|
||||||
expect(subject).not_to be_satisfied(args: args)
|
expect(subject).not_to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if #preferred_java returns a path" do
|
it "returns true if #preferred_java returns a path" do
|
||||||
allow(subject).to receive(:preferred_java).and_return(Pathname.new("/usr/bin/java"))
|
allow(subject).to receive(:preferred_java).and_return(Pathname.new("/usr/bin/java"))
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when #possible_javas contains paths" do
|
context "when #possible_javas contains paths" do
|
||||||
@ -74,17 +72,17 @@ describe JavaRequirement do
|
|||||||
|
|
||||||
it "returns false if all are lower" do
|
it "returns false if all are lower" do
|
||||||
setup_java_with_version "1.6.0_5"
|
setup_java_with_version "1.6.0_5"
|
||||||
expect(subject).not_to be_satisfied(args: args)
|
expect(subject).not_to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if one is equal" do
|
it "returns true if one is equal" do
|
||||||
setup_java_with_version "1.7.0_5"
|
setup_java_with_version "1.7.0_5"
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if all are higher" do
|
it "returns false if all are higher" do
|
||||||
setup_java_with_version "1.8.0_5"
|
setup_java_with_version "1.8.0_5"
|
||||||
expect(subject).not_to be_satisfied(args: args)
|
expect(subject).not_to be_satisfied
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,17 +91,17 @@ describe JavaRequirement do
|
|||||||
|
|
||||||
it "returns false if all are lower" do
|
it "returns false if all are lower" do
|
||||||
setup_java_with_version "1.6.0_5"
|
setup_java_with_version "1.6.0_5"
|
||||||
expect(subject).not_to be_satisfied(args: args)
|
expect(subject).not_to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if one is equal" do
|
it "returns true if one is equal" do
|
||||||
setup_java_with_version "1.7.0_5"
|
setup_java_with_version "1.7.0_5"
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if one is higher" do
|
it "returns true if one is higher" do
|
||||||
setup_java_with_version "1.8.0_5"
|
setup_java_with_version "1.8.0_5"
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -72,27 +72,20 @@ describe Messages do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Homebrew.args OpenStruct usage cannot use verified doubles.
|
context "when the `display_times` argument is true" do
|
||||||
# rubocop:disable RSpec/VerifiedDoubles
|
context "when `install_times` is empty" do
|
||||||
context "when the --display-times argument is present" do
|
it "doesn't print anything" do
|
||||||
before do
|
expect { messages.display_messages(display_times: true) }.not_to output.to_stdout
|
||||||
allow(Homebrew).to receive(:args).and_return \
|
|
||||||
double(display_times?: true, flags_only: ["--display-times"])
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when install_times is empty" do
|
|
||||||
it "doesn't print any output" do
|
|
||||||
expect { messages.display_messages }.not_to output.to_stdout
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when install_times is present" do
|
context "when `install_times` is present" do
|
||||||
before do
|
before do
|
||||||
messages.formula_installed(test_formula, elapsed_time)
|
messages.formula_installed(test_formula, elapsed_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints installation times" do
|
it "prints installation times" do
|
||||||
expect { messages.display_messages }.to output(
|
expect { messages.display_messages(display_times: true) }.to output(
|
||||||
<<~EOS,
|
<<~EOS,
|
||||||
==> Installation times
|
==> Installation times
|
||||||
foo 1.100 s
|
foo 1.100 s
|
||||||
@ -102,15 +95,10 @@ describe Messages do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the --display-times argument isn't present" do
|
context "when the `display_times` argument isn't specified" do
|
||||||
before do
|
|
||||||
allow(Homebrew).to receive(:args).and_return(double(display_times?: false))
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't print installation times" do
|
it "doesn't print installation times" do
|
||||||
expect { messages.display_messages }.not_to output.to_stdout
|
expect { messages.display_messages }.not_to output.to_stdout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable RSpec/VerifiedDoubles
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,8 +9,6 @@ describe JavaRequirement do
|
|||||||
|
|
||||||
let(:java_home) { mktmpdir }
|
let(:java_home) { mktmpdir }
|
||||||
|
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
FileUtils.mkdir java_home/"bin"
|
FileUtils.mkdir java_home/"bin"
|
||||||
FileUtils.touch java_home/"bin/java"
|
FileUtils.touch java_home/"bin/java"
|
||||||
@ -18,23 +16,23 @@ describe JavaRequirement do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "Apple Java environment" do
|
specify "Apple Java environment" do
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
|
|
||||||
expect(ENV).to receive(:prepend_path)
|
expect(ENV).to receive(:prepend_path)
|
||||||
expect(ENV).to receive(:append_to_cflags)
|
expect(ENV).to receive(:append_to_cflags)
|
||||||
|
|
||||||
subject.modify_build_environment(args: args)
|
subject.modify_build_environment
|
||||||
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "Oracle Java environment" do
|
specify "Oracle Java environment" do
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
|
|
||||||
FileUtils.mkdir java_home/"include"
|
FileUtils.mkdir java_home/"include"
|
||||||
expect(ENV).to receive(:prepend_path)
|
expect(ENV).to receive(:prepend_path)
|
||||||
expect(ENV).to receive(:append_to_cflags).twice
|
expect(ENV).to receive(:append_to_cflags).twice
|
||||||
|
|
||||||
subject.modify_build_environment(args: args)
|
subject.modify_build_environment
|
||||||
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -149,7 +149,7 @@ describe "patching" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
f.brew { |formula, _staging| formula.patch }
|
f.brew { |formula, _staging| formula.patch }
|
||||||
}.to raise_error(ErrorDuringExecution)
|
}.to raise_error(BuildError)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "single_patch_dsl_with_incorrect_strip_with_apply" do
|
specify "single_patch_dsl_with_incorrect_strip_with_apply" do
|
||||||
@ -163,7 +163,7 @@ describe "patching" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
f.brew { |formula, _staging| formula.patch }
|
f.brew { |formula, _staging| formula.patch }
|
||||||
}.to raise_error(ErrorDuringExecution)
|
}.to raise_error(BuildError)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "patch_p0_dsl" do
|
specify "patch_p0_dsl" do
|
||||||
@ -219,7 +219,7 @@ describe "patching" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
f.brew { |formula, _staging| formula.patch }
|
f.brew { |formula, _staging| formula.patch }
|
||||||
}.to raise_error(ErrorDuringExecution)
|
}.to raise_error(BuildError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ describe Requirement do
|
|||||||
|
|
||||||
let(:klass) { Class.new(described_class) }
|
let(:klass) { Class.new(described_class) }
|
||||||
|
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
describe "#tags" do
|
describe "#tags" do
|
||||||
subject { described_class.new(tags) }
|
subject { described_class.new(tags) }
|
||||||
|
|
||||||
@ -67,7 +65,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to be_satisfied(args: args) }
|
it { is_expected.to be_satisfied }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy with block and build_env returns false" do
|
describe "#satisfy with block and build_env returns false" do
|
||||||
@ -79,7 +77,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to be_satisfied(args: args) }
|
it { is_expected.not_to be_satisfied }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy returns true" do
|
describe "#satisfy returns true" do
|
||||||
@ -89,7 +87,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to be_satisfied(args: args) }
|
it { is_expected.to be_satisfied }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy returns false" do
|
describe "#satisfy returns false" do
|
||||||
@ -99,7 +97,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to be_satisfied(args: args) }
|
it { is_expected.not_to be_satisfied }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy with block returning true and without :build_env" do
|
describe "#satisfy with block returning true and without :build_env" do
|
||||||
@ -113,7 +111,7 @@ describe Requirement do
|
|||||||
|
|
||||||
it "sets up build environment" do
|
it "sets up build environment" do
|
||||||
expect(ENV).to receive(:with_build_environment).and_call_original
|
expect(ENV).to receive(:with_build_environment).and_call_original
|
||||||
subject.satisfied?(args: args)
|
subject.satisfied?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -128,7 +126,7 @@ describe Requirement do
|
|||||||
|
|
||||||
it "skips setting up build environment" do
|
it "skips setting up build environment" do
|
||||||
expect(ENV).not_to receive(:with_build_environment)
|
expect(ENV).not_to receive(:with_build_environment)
|
||||||
subject.satisfied?(args: args)
|
subject.satisfied?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -143,8 +141,8 @@ describe Requirement do
|
|||||||
|
|
||||||
it "infers path from #satisfy result" do
|
it "infers path from #satisfy result" do
|
||||||
expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar"))
|
expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar"))
|
||||||
subject.satisfied?(args: args)
|
subject.satisfied?
|
||||||
subject.modify_build_environment(args: args)
|
subject.modify_build_environment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -182,7 +180,7 @@ describe Requirement do
|
|||||||
let(:klass) { Class.new(described_class) }
|
let(:klass) { Class.new(described_class) }
|
||||||
|
|
||||||
it "returns nil" do
|
it "returns nil" do
|
||||||
expect(subject.modify_build_environment(args: args)).to be nil
|
expect(subject.modify_build_environment).to be nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,10 +7,8 @@ describe LinuxRequirement do
|
|||||||
subject(:requirement) { described_class.new }
|
subject(:requirement) { described_class.new }
|
||||||
|
|
||||||
describe "#satisfied?" do
|
describe "#satisfied?" do
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
it "returns true on Linux" do
|
it "returns true on Linux" do
|
||||||
expect(requirement.satisfied?(args: args)).to eq(OS.linux?)
|
expect(requirement.satisfied?).to eq(OS.linux?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,20 +7,18 @@ describe MacOSRequirement do
|
|||||||
subject(:requirement) { described_class.new }
|
subject(:requirement) { described_class.new }
|
||||||
|
|
||||||
describe "#satisfied?" do
|
describe "#satisfied?" do
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
it "returns true on macOS" do
|
it "returns true on macOS" do
|
||||||
expect(requirement.satisfied?(args: args)).to eq OS.mac?
|
expect(requirement.satisfied?).to eq OS.mac?
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports version symbols", :needs_macos do
|
it "supports version symbols", :needs_macos do
|
||||||
requirement = described_class.new([MacOS.version.to_sym])
|
requirement = described_class.new([MacOS.version.to_sym])
|
||||||
expect(requirement).to be_satisfied(args: args)
|
expect(requirement).to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports maximum versions", :needs_macos do
|
it "supports maximum versions", :needs_macos do
|
||||||
requirement = described_class.new([:catalina], comparator: "<=")
|
requirement = described_class.new([:catalina], comparator: "<=")
|
||||||
expect(requirement.satisfied?(args: args)).to eq MacOS.version <= :catalina
|
expect(requirement.satisfied?).to eq MacOS.version <= :catalina
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,23 +22,21 @@ describe OsxfuseRequirement do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#modify_build_environment", :needs_macos do
|
describe "#modify_build_environment", :needs_macos do
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
it "adds the fuse directories to PKG_CONFIG_PATH" do
|
it "adds the fuse directories to PKG_CONFIG_PATH" do
|
||||||
allow(ENV).to receive(:append_path)
|
allow(ENV).to receive(:append_path)
|
||||||
requirement.modify_build_environment(args: args)
|
requirement.modify_build_environment
|
||||||
expect(ENV).to have_received(:append_path).with("PKG_CONFIG_PATH", any_args)
|
expect(ENV).to have_received(:append_path).with("PKG_CONFIG_PATH", any_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds the fuse directories to HOMEBREW_LIBRARY_PATHS" do
|
it "adds the fuse directories to HOMEBREW_LIBRARY_PATHS" do
|
||||||
allow(ENV).to receive(:append_path)
|
allow(ENV).to receive(:append_path)
|
||||||
requirement.modify_build_environment(args: args)
|
requirement.modify_build_environment
|
||||||
expect(ENV).to have_received(:append_path).with("HOMEBREW_LIBRARY_PATHS", any_args)
|
expect(ENV).to have_received(:append_path).with("HOMEBREW_LIBRARY_PATHS", any_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds the fuse directories to HOMEBREW_INCLUDE_PATHS" do
|
it "adds the fuse directories to HOMEBREW_INCLUDE_PATHS" do
|
||||||
allow(ENV).to receive(:append_path)
|
allow(ENV).to receive(:append_path)
|
||||||
requirement.modify_build_environment(args: args)
|
requirement.modify_build_environment
|
||||||
expect(ENV).to have_received(:append_path).with("HOMEBREW_INCLUDE_PATHS", any_args)
|
expect(ENV).to have_received(:append_path).with("HOMEBREW_INCLUDE_PATHS", any_args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,8 @@ describe "RuboCop" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "loads all Formula cops without errors" do
|
it "loads all Formula cops without errors" do
|
||||||
_, _, status = Open3.capture3("rubocop", TEST_FIXTURE_DIR/"testball.rb")
|
stdout, _, status = Open3.capture3("rubocop", TEST_FIXTURE_DIR/"testball.rb")
|
||||||
|
expect(stdout).to include("no offenses detected")
|
||||||
expect(status).to be_a_success
|
expect(status).to be_a_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Binary file not shown.
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Failball < Formula
|
class Failball < Formula
|
||||||
def initialize(name = "failball", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil)
|
def initialize(name = "failball", path = Pathname.new(__FILE__).expand_path, spec = :stable,
|
||||||
|
alias_path: nil, force_bottle: false)
|
||||||
self.class.instance_eval do
|
self.class.instance_eval do
|
||||||
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
||||||
stable.sha256 TESTBALL_SHA256
|
stable.sha256 TESTBALL_SHA256
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil)
|
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable,
|
||||||
|
alias_path: nil, force_bottle: false)
|
||||||
self.class.instance_eval do
|
self.class.instance_eval do
|
||||||
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
||||||
stable.sha256 TESTBALL_SHA256
|
stable.sha256 TESTBALL_SHA256
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class TestballBottle < Formula
|
class TestballBottle < Formula
|
||||||
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil)
|
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable,
|
||||||
|
alias_path: nil, force_bottle: false)
|
||||||
self.class.instance_eval do
|
self.class.instance_eval do
|
||||||
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
||||||
stable.sha256 TESTBALL_SHA256
|
stable.sha256 TESTBALL_SHA256
|
||||||
stable.bottle do
|
stable.bottle do
|
||||||
cellar :any_skip_relocation
|
cellar :any_skip_relocation
|
||||||
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
|
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
|
||||||
sha256 "d48bbbe583dcfbfa608579724fc6f0328b3cd316935c6ea22f134610aaf2952f" => Utils::Bottles.tag
|
sha256 "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149" => Utils::Bottles.tag
|
||||||
end
|
end
|
||||||
cxxstdlib_check :skip
|
cxxstdlib_check :skip
|
||||||
end
|
end
|
||||||
|
@ -6,8 +6,6 @@ require "requirements/x11_requirement"
|
|||||||
describe X11Requirement do
|
describe X11Requirement do
|
||||||
let(:default_name) { "x11" }
|
let(:default_name) { "x11" }
|
||||||
|
|
||||||
let(:args) { Homebrew::CLI::Args.new }
|
|
||||||
|
|
||||||
describe "#name" do
|
describe "#name" do
|
||||||
it "defaults to x11" do
|
it "defaults to x11" do
|
||||||
expect(subject.name).to eq(default_name)
|
expect(subject.name).to eq(default_name)
|
||||||
@ -25,7 +23,7 @@ describe X11Requirement do
|
|||||||
it "calls ENV#x11" do
|
it "calls ENV#x11" do
|
||||||
allow(subject).to receive(:satisfied?).and_return(true)
|
allow(subject).to receive(:satisfied?).and_return(true)
|
||||||
expect(ENV).to receive(:x11)
|
expect(ENV).to receive(:x11)
|
||||||
subject.modify_build_environment(args: args)
|
subject.modify_build_environment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -33,12 +31,12 @@ describe X11Requirement do
|
|||||||
it "returns true if X11 is installed" do
|
it "returns true if X11 is installed" do
|
||||||
expect(MacOS::XQuartz).to receive(:version).and_return("2.7.5")
|
expect(MacOS::XQuartz).to receive(:version).and_return("2.7.5")
|
||||||
expect(MacOS::XQuartz).to receive(:installed?).and_return(true)
|
expect(MacOS::XQuartz).to receive(:installed?).and_return(true)
|
||||||
expect(subject).to be_satisfied(args: args)
|
expect(subject).to be_satisfied
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if X11 is not installed" do
|
it "returns false if X11 is not installed" do
|
||||||
expect(MacOS::XQuartz).to receive(:installed?).and_return(false)
|
expect(MacOS::XQuartz).to receive(:installed?).and_return(false)
|
||||||
expect(subject).not_to be_satisfied(args: args)
|
expect(subject).not_to be_satisfied
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
formulae_to_install.each do |f|
|
formulae_to_install.each do |f|
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f, force: args.force?)
|
||||||
begin
|
begin
|
||||||
upgrade_formula(f, args: args)
|
upgrade_formula(f, args: args)
|
||||||
Cleanup.install_formula_clean!(f)
|
Cleanup.install_formula_clean!(f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user