Merge pull request #8187 from reitermarkus/args-verbose-debug
Remove usages of `Homebrew.args.verbose?` and `Homebrew.args.debug?`.
This commit is contained in:
commit
56ed27af15
@ -4,6 +4,8 @@ require "utils/curl"
|
|||||||
require "json"
|
require "json"
|
||||||
|
|
||||||
class Bintray
|
class Bintray
|
||||||
|
include Context
|
||||||
|
|
||||||
API_URL = "https://api.bintray.com"
|
API_URL = "https://api.bintray.com"
|
||||||
|
|
||||||
class Error < RuntimeError
|
class Error < RuntimeError
|
||||||
@ -32,8 +34,8 @@ class Bintray
|
|||||||
end
|
end
|
||||||
|
|
||||||
curl(*args, url,
|
curl(*args, url,
|
||||||
show_output: Homebrew.args.verbose?,
|
show_output: verbose?,
|
||||||
secrets: @bintray_key)
|
secrets: key)
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload(local_file, repo:, package:, version:, remote_file:, sha256: nil)
|
def upload(local_file, repo:, package:, version:, remote_file:, sha256: nil)
|
||||||
|
@ -59,7 +59,9 @@ begin
|
|||||||
|
|
||||||
ARGV.delete_at(help_cmd_index) if help_cmd_index
|
ARGV.delete_at(help_cmd_index) if help_cmd_index
|
||||||
|
|
||||||
Homebrew.args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
|
args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
|
||||||
|
Homebrew.args = args
|
||||||
|
Context.current = args.context
|
||||||
|
|
||||||
path = PATH.new(ENV["PATH"])
|
path = PATH.new(ENV["PATH"])
|
||||||
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
|
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
|
||||||
@ -102,8 +104,8 @@ begin
|
|||||||
# - if cmd is Cask, let Cask handle the help command instead
|
# - if cmd is Cask, let Cask handle the help command instead
|
||||||
if (empty_argv || help_flag) && cmd != "cask"
|
if (empty_argv || help_flag) && cmd != "cask"
|
||||||
require "help"
|
require "help"
|
||||||
Homebrew::Help.help cmd, empty_argv: empty_argv
|
Homebrew::Help.help cmd, remaining_args: args.remaining, empty_argv: empty_argv
|
||||||
# `Homebrew.help` never returns, except for unknown commands.
|
# `Homebrew::Help.help` never returns, except for unknown commands.
|
||||||
end
|
end
|
||||||
|
|
||||||
if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd)
|
if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd)
|
||||||
@ -138,17 +140,17 @@ begin
|
|||||||
end
|
end
|
||||||
rescue UsageError => e
|
rescue UsageError => e
|
||||||
require "help"
|
require "help"
|
||||||
Homebrew::Help.help cmd, usage_error: e.message
|
Homebrew::Help.help cmd, remaining_args: args.remaining, usage_error: e.message
|
||||||
rescue SystemExit => e
|
rescue SystemExit => e
|
||||||
onoe "Kernel.exit" if Homebrew.args.debug? && !e.success?
|
onoe "Kernel.exit" if args.debug? && !e.success?
|
||||||
$stderr.puts e.backtrace if Homebrew.args.debug?
|
$stderr.puts e.backtrace if args.debug?
|
||||||
raise
|
raise
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
$stderr.puts # seemingly a newline is typical
|
$stderr.puts # seemingly a newline is typical
|
||||||
exit 130
|
exit 130
|
||||||
rescue BuildError => e
|
rescue BuildError => e
|
||||||
Utils::Analytics.report_build_error(e)
|
Utils::Analytics.report_build_error(e)
|
||||||
e.dump
|
e.dump(verbose: args.verbose?)
|
||||||
|
|
||||||
if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
|
if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
|
||||||
$stderr.puts <<~EOS
|
$stderr.puts <<~EOS
|
||||||
@ -162,7 +164,7 @@ rescue RuntimeError, SystemCallError => e
|
|||||||
raise if e.message.empty?
|
raise if e.message.empty?
|
||||||
|
|
||||||
onoe e
|
onoe e
|
||||||
$stderr.puts e.backtrace if Homebrew.args.debug?
|
$stderr.puts e.backtrace if args.debug?
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
rescue MethodDeprecatedError => e
|
rescue MethodDeprecatedError => e
|
||||||
@ -171,7 +173,7 @@ rescue MethodDeprecatedError => e
|
|||||||
$stderr.puts "If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):"
|
$stderr.puts "If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):"
|
||||||
$stderr.puts " #{Formatter.url(e.issues_url)}"
|
$stderr.puts " #{Formatter.url(e.issues_url)}"
|
||||||
end
|
end
|
||||||
$stderr.puts e.backtrace if Homebrew.args.debug?
|
$stderr.puts e.backtrace if args.debug?
|
||||||
exit 1
|
exit 1
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
onoe e
|
onoe e
|
||||||
|
@ -139,7 +139,11 @@ class Build
|
|||||||
|
|
||||||
formula.update_head_version
|
formula.update_head_version
|
||||||
|
|
||||||
formula.brew(fetch: false, keep_tmp: args.keep_tmp?, interactive: args.interactive?) do |_formula, _staging|
|
formula.brew(
|
||||||
|
fetch: false,
|
||||||
|
keep_tmp: args.keep_tmp?,
|
||||||
|
interactive: args.interactive?,
|
||||||
|
) do
|
||||||
# For head builds, HOMEBREW_FORMULA_PREFIX should include the commit,
|
# For head builds, HOMEBREW_FORMULA_PREFIX should include the commit,
|
||||||
# which is not known until after the formula has been staged.
|
# which is not known until after the formula has been staged.
|
||||||
ENV["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
|
ENV["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
|
||||||
@ -201,16 +205,15 @@ class Build
|
|||||||
else
|
else
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
Keg.new(path).optlink
|
Keg.new(path).optlink(verbose: args.verbose?)
|
||||||
rescue
|
rescue
|
||||||
raise "#{f.opt_prefix} not present or broken\nPlease reinstall #{f.full_name}. Sorry :("
|
raise "#{f.opt_prefix} not present or broken\nPlease reinstall #{f.full_name}. Sorry :("
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Homebrew.args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
|
|
||||||
|
|
||||||
args = Homebrew.install_args.parse
|
args = Homebrew.install_args.parse
|
||||||
|
Context.current = args.context
|
||||||
|
|
||||||
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)
|
||||||
|
@ -35,6 +35,8 @@ require "cask/cmd/internal_stanza"
|
|||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
class Cmd
|
class Cmd
|
||||||
|
include Context
|
||||||
|
|
||||||
ALIASES = {
|
ALIASES = {
|
||||||
"ls" => "list",
|
"ls" => "list",
|
||||||
"homepage" => "home",
|
"homepage" => "home",
|
||||||
@ -154,7 +156,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
rescue CaskError, MethodDeprecatedError, ArgumentError, OptionParser::InvalidOption => e
|
rescue CaskError, MethodDeprecatedError, ArgumentError, OptionParser::InvalidOption => e
|
||||||
onoe e.message
|
onoe e.message
|
||||||
$stderr.puts e.backtrace if Homebrew.args.debug?
|
$stderr.puts e.backtrace if debug?
|
||||||
exit 1
|
exit 1
|
||||||
rescue StandardError, ScriptError, NoMemoryError => e
|
rescue StandardError, ScriptError, NoMemoryError => e
|
||||||
onoe e.message
|
onoe e.message
|
||||||
|
@ -367,11 +367,10 @@ module Cask
|
|||||||
force: false,
|
force: false,
|
||||||
).install
|
).install
|
||||||
else
|
else
|
||||||
FormulaInstaller.new(cask_or_formula).yield_self do |fi|
|
FormulaInstaller.new(cask_or_formula, verbose: verbose?).yield_self do |fi|
|
||||||
fi.installed_as_dependency = true
|
fi.installed_as_dependency = true
|
||||||
fi.installed_on_request = false
|
fi.installed_on_request = false
|
||||||
fi.show_header = true
|
fi.show_header = true
|
||||||
fi.verbose = verbose?
|
|
||||||
fi.prelude
|
fi.prelude
|
||||||
fi.fetch
|
fi.fetch
|
||||||
fi.install
|
fi.install
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
# * sets permissions on executables
|
# * sets permissions on executables
|
||||||
# * removes unresolved symlinks
|
# * removes unresolved symlinks
|
||||||
class Cleaner
|
class Cleaner
|
||||||
|
include Context
|
||||||
|
|
||||||
# Create a cleaner for the given formula
|
# Create a cleaner for the given formula
|
||||||
def initialize(f)
|
def initialize(f)
|
||||||
@f = f
|
@f = f
|
||||||
@ -58,7 +60,7 @@ class Cleaner
|
|||||||
# actual files gets removed correctly.
|
# actual files gets removed correctly.
|
||||||
dirs.reverse_each do |d|
|
dirs.reverse_each do |d|
|
||||||
if d.children.empty?
|
if d.children.empty?
|
||||||
puts "rmdir: #{d} (empty)" if Homebrew.args.verbose?
|
puts "rmdir: #{d} (empty)" if verbose?
|
||||||
d.rmdir
|
d.rmdir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -109,7 +111,7 @@ class Cleaner
|
|||||||
else
|
else
|
||||||
0444
|
0444
|
||||||
end
|
end
|
||||||
if Homebrew.args.debug?
|
if debug?
|
||||||
old_perms = path.stat.mode & 0777
|
old_perms = path.stat.mode & 0777
|
||||||
odebug "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms
|
odebug "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms
|
||||||
end
|
end
|
||||||
|
@ -188,6 +188,10 @@ module Homebrew
|
|||||||
flag_with_value.delete_prefix(arg_prefix)
|
flag_with_value.delete_prefix(arg_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def context
|
||||||
|
Context::ContextStruct.new(debug: debug?, quiet: quiet?, verbose: verbose?)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def option_to_name(option)
|
def option_to_name(option)
|
||||||
|
@ -88,9 +88,7 @@ module Homebrew
|
|||||||
def env?(env)
|
def env?(env)
|
||||||
return false if env.blank?
|
return false if env.blank?
|
||||||
|
|
||||||
Homebrew::EnvConfig.send("#{env}?")
|
Homebrew::EnvConfig.try(:"#{env}?")
|
||||||
rescue NoMethodError
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def usage_banner(text)
|
def usage_banner(text)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
require "help"
|
require "help"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def help(cmd = nil, flags = {})
|
def help
|
||||||
Help.help(cmd, flags)
|
Help.help
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -325,7 +325,8 @@ module Homebrew
|
|||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
||||||
include_test_formulae: args.include_test_formulae,
|
include_test_formulae: args.include_test_formulae,
|
||||||
build_from_source_formulae: args.build_from_source_formulae)
|
build_from_source_formulae: args.build_from_source_formulae,
|
||||||
|
debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?)
|
||||||
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?
|
||||||
|
@ -31,10 +31,11 @@ module Homebrew
|
|||||||
def link
|
def link
|
||||||
args = link_args.parse
|
args = link_args.parse
|
||||||
|
|
||||||
mode = OpenStruct.new
|
options = {
|
||||||
|
overwrite: args.overwrite?,
|
||||||
mode.overwrite = true if args.overwrite?
|
dry_run: args.dry_run?,
|
||||||
mode.dry_run = true if args.dry_run?
|
verbose: args.verbose?,
|
||||||
|
}
|
||||||
|
|
||||||
args.kegs.each do |keg|
|
args.kegs.each do |keg|
|
||||||
keg_only = Formulary.keg_only?(keg.rack)
|
keg_only = Formulary.keg_only?(keg.rack)
|
||||||
@ -53,13 +54,13 @@ module Homebrew
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
if mode.dry_run
|
if args.dry_run?
|
||||||
if mode.overwrite
|
if args.overwrite?
|
||||||
puts "Would remove:"
|
puts "Would remove:"
|
||||||
else
|
else
|
||||||
puts "Would link:"
|
puts "Would link:"
|
||||||
end
|
end
|
||||||
keg.link(mode)
|
keg.link(**options)
|
||||||
puts_keg_only_path_message(keg) if keg_only
|
puts_keg_only_path_message(keg) if keg_only
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@ -89,7 +90,7 @@ module Homebrew
|
|||||||
puts if args.verbose?
|
puts if args.verbose?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
n = keg.link(mode)
|
n = keg.link(**options)
|
||||||
rescue Keg::LinkError
|
rescue Keg::LinkError
|
||||||
puts
|
puts
|
||||||
raise
|
raise
|
||||||
|
@ -94,7 +94,7 @@ module Homebrew
|
|||||||
if formula_or_cask.is_a?(Formula)
|
if formula_or_cask.is_a?(Formula)
|
||||||
f = formula_or_cask
|
f = formula_or_cask
|
||||||
|
|
||||||
if verbose? args: args
|
if verbose?
|
||||||
outdated_kegs = f.outdated_kegs(fetch_head: args.fetch_HEAD?)
|
outdated_kegs = f.outdated_kegs(fetch_head: args.fetch_HEAD?)
|
||||||
|
|
||||||
current_version = if f.alias_changed?
|
current_version = if f.alias_changed?
|
||||||
@ -122,7 +122,7 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
c = formula_or_cask
|
c = formula_or_cask
|
||||||
|
|
||||||
puts c.outdated_info(args.greedy?, verbose?(args: args), false)
|
puts c.outdated_info(args.greedy?, verbose?, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -147,13 +147,13 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
c = formula_or_cask
|
c = formula_or_cask
|
||||||
|
|
||||||
c.outdated_info(args.greedy?, verbose?(args: args), true)
|
c.outdated_info(args.greedy?, verbose?, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def verbose?(args:)
|
def verbose?
|
||||||
($stdout.tty? || args.verbose?) && !args.quiet?
|
($stdout.tty? || super) && !quiet?
|
||||||
end
|
end
|
||||||
|
|
||||||
def json_version(version)
|
def json_version(version)
|
||||||
|
@ -24,7 +24,7 @@ module Homebrew
|
|||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.resolved_formulae.each do |f|
|
||||||
ohai "Postinstalling #{f}"
|
ohai "Postinstalling #{f}"
|
||||||
fi = FormulaInstaller.new(f)
|
fi = FormulaInstaller.new(f, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?)
|
||||||
fi.post_install
|
fi.post_install
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ module Homebrew
|
|||||||
|
|
||||||
# Link new version, if not keg-only
|
# Link new version, if not keg-only
|
||||||
if Formulary.keg_only?(rack)
|
if Formulary.keg_only?(rack)
|
||||||
keg.optlink
|
keg.optlink(verbose: args.verbose?)
|
||||||
puts "Opt link created for #{keg}"
|
puts "Opt link created for #{keg}"
|
||||||
else
|
else
|
||||||
puts "#{keg.link} links created for #{keg}"
|
puts "#{keg.link} links created for #{keg}"
|
||||||
|
@ -26,20 +26,19 @@ module Homebrew
|
|||||||
def unlink
|
def unlink
|
||||||
args = unlink_args.parse
|
args = unlink_args.parse
|
||||||
|
|
||||||
mode = OpenStruct.new
|
options = { dry_run: args.dry_run?, verbose: args.verbose? }
|
||||||
mode.dry_run = true if args.dry_run?
|
|
||||||
|
|
||||||
args.kegs.each do |keg|
|
args.kegs.each do |keg|
|
||||||
if mode.dry_run
|
if args.dry_run?
|
||||||
puts "Would remove:"
|
puts "Would remove:"
|
||||||
keg.unlink(mode)
|
keg.unlink(**options)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
keg.lock do
|
keg.lock do
|
||||||
print "Unlinking #{keg}... "
|
print "Unlinking #{keg}... "
|
||||||
puts if args.verbose?
|
puts if args.verbose?
|
||||||
puts "#{keg.unlink(mode)} symlinks removed"
|
puts "#{keg.unlink(**options)} symlinks removed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -120,7 +120,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 { |r| r.migrate_formula_rename(force: args.force?) }
|
hub.reporters.each { |r| r.migrate_formula_rename(force: args.force?, verbose: args.verbose?) }
|
||||||
CacheStoreDatabase.use(:descriptions) do |db|
|
CacheStoreDatabase.use(:descriptions) do |db|
|
||||||
DescriptionCacheStore.new(db)
|
DescriptionCacheStore.new(db)
|
||||||
.update_from_report!(hub)
|
.update_from_report!(hub)
|
||||||
@ -371,7 +371,7 @@ class Reporter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def migrate_formula_rename(force:)
|
def migrate_formula_rename(force:, verbose:)
|
||||||
Formula.installed.each do |formula|
|
Formula.installed.each do |formula|
|
||||||
next unless Migrator.needs_migration?(formula)
|
next unless Migrator.needs_migration?(formula)
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "compat/dependencies_helpers"
|
||||||
|
require "compat/cli/parser"
|
||||||
require "compat/extend/nil"
|
require "compat/extend/nil"
|
||||||
require "compat/extend/string"
|
require "compat/extend/string"
|
||||||
require "compat/formula"
|
require "compat/formula"
|
||||||
|
32
Library/Homebrew/compat/cli/parser.rb
Normal file
32
Library/Homebrew/compat/cli/parser.rb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Homebrew
|
||||||
|
module CLI
|
||||||
|
class Parser
|
||||||
|
module Compat
|
||||||
|
module DeprecatedArgs
|
||||||
|
def respond_to_missing?(*)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def method_missing(method, *)
|
||||||
|
if ![:debug?, :quiet?, :verbose?, :value].include?(method) && !@printed_args_warning
|
||||||
|
odeprecated "Homebrew.args", "`args = <command>_args.parse` and pass `args` along the call chain"
|
||||||
|
@printed_args_warning = true
|
||||||
|
end
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse(*)
|
||||||
|
args = super
|
||||||
|
Homebrew.args = args.dup.extend(DeprecatedArgs)
|
||||||
|
args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
prepend Compat
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
17
Library/Homebrew/compat/dependencies_helpers.rb
Normal file
17
Library/Homebrew/compat/dependencies_helpers.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
|
|
||||||
|
module DependenciesHelpers
|
||||||
|
module Compat
|
||||||
|
def argv_includes_ignores(argv = nil)
|
||||||
|
unless @printed_includes_ignores_warning
|
||||||
|
odeprecated "Homebrew.argv_includes_ignores", "Homebrew.args_includes_ignores"
|
||||||
|
@printed_includes_ignores_warning = true
|
||||||
|
end
|
||||||
|
args_includes_ignores(argv ? Homebrew::CLI::Args.new : Homebrew.args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
prepend Compat
|
||||||
|
end
|
71
Library/Homebrew/context.rb
Normal file
71
Library/Homebrew/context.rb
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "monitor"
|
||||||
|
|
||||||
|
module Context
|
||||||
|
extend MonitorMixin
|
||||||
|
|
||||||
|
def self.current=(context)
|
||||||
|
synchronize do
|
||||||
|
@current = context
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.current
|
||||||
|
if current_context = Thread.current[:context]
|
||||||
|
return current_context
|
||||||
|
end
|
||||||
|
|
||||||
|
synchronize do
|
||||||
|
@current ||= ContextStruct.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ContextStruct
|
||||||
|
def initialize(debug: nil, quiet: nil, verbose: nil)
|
||||||
|
@debug = debug
|
||||||
|
@quiet = quiet
|
||||||
|
@verbose = verbose
|
||||||
|
end
|
||||||
|
|
||||||
|
def debug?
|
||||||
|
@debug
|
||||||
|
end
|
||||||
|
|
||||||
|
def quiet?
|
||||||
|
@quiet
|
||||||
|
end
|
||||||
|
|
||||||
|
def verbose?
|
||||||
|
@verbose
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def debug?
|
||||||
|
Context.current.debug?
|
||||||
|
end
|
||||||
|
|
||||||
|
def quiet?
|
||||||
|
Context.current.quiet?
|
||||||
|
end
|
||||||
|
|
||||||
|
def verbose?
|
||||||
|
Context.current.verbose?
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_context(**options)
|
||||||
|
old_context = Thread.current[:context]
|
||||||
|
|
||||||
|
new_context = ContextStruct.new(
|
||||||
|
debug: options.fetch(:debug, old_context&.debug?),
|
||||||
|
quiet: options.fetch(:quiet, old_context&.quiet?),
|
||||||
|
verbose: options.fetch(:verbose, old_context&.verbose?),
|
||||||
|
)
|
||||||
|
|
||||||
|
Thread.current[:context] = new_context
|
||||||
|
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
Thread.current[:context] = old_context
|
||||||
|
end
|
||||||
|
end
|
@ -103,7 +103,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?, debug: args.debug?, verbose: args.verbose? }
|
||||||
|
|
||||||
if only_cops
|
if only_cops
|
||||||
options[:only_cops] = only_cops
|
options[:only_cops] = only_cops
|
||||||
|
@ -116,7 +116,7 @@ module Homebrew
|
|||||||
# git cherry-pick unfortunately has no quiet option
|
# git cherry-pick unfortunately has no quiet option
|
||||||
ohai "Cherry-picking #{commit_count} commit#{"s" unless commit_count == 1} from ##{pr}"
|
ohai "Cherry-picking #{commit_count} commit#{"s" unless commit_count == 1} from ##{pr}"
|
||||||
cherry_pick_args = "git", "-C", path, "cherry-pick", "--ff", "--allow-empty", "#{merge_base}..FETCH_HEAD"
|
cherry_pick_args = "git", "-C", path, "cherry-pick", "--ff", "--allow-empty", "#{merge_base}..FETCH_HEAD"
|
||||||
result = Homebrew.args.verbose? ? system(*cherry_pick_args) : quiet_system(*cherry_pick_args)
|
result = args.verbose? ? system(*cherry_pick_args) : quiet_system(*cherry_pick_args)
|
||||||
|
|
||||||
unless result
|
unless result
|
||||||
if args.resolve?
|
if args.resolve?
|
||||||
|
@ -50,7 +50,9 @@ 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?, display_cop_names: args.display_cop_names? }
|
options = {
|
||||||
|
fix: args.fix?, display_cop_names: args.display_cop_names?, debug: args.debug?, verbose: args.verbose?
|
||||||
|
}
|
||||||
if only_cops
|
if only_cops
|
||||||
options[:only_cops] = only_cops
|
options[:only_cops] = only_cops
|
||||||
elsif except_cops
|
elsif except_cops
|
||||||
|
@ -13,6 +13,7 @@ require "mechanize/http/content_disposition_parser"
|
|||||||
class AbstractDownloadStrategy
|
class AbstractDownloadStrategy
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
include Context
|
||||||
|
|
||||||
module Pourable
|
module Pourable
|
||||||
def stage
|
def stage
|
||||||
@ -21,9 +22,9 @@ class AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :cache, :cached_location, :url, :meta, :name, :version, :shutup
|
attr_reader :cache, :cached_location, :url, :meta, :name, :version
|
||||||
|
|
||||||
private :meta, :name, :version, :shutup
|
private :meta, :name, :version
|
||||||
|
|
||||||
def initialize(url, name, version, **meta)
|
def initialize(url, name, version, **meta)
|
||||||
@url = url
|
@url = url
|
||||||
@ -31,24 +32,18 @@ class AbstractDownloadStrategy
|
|||||||
@version = version
|
@version = version
|
||||||
@cache = meta.fetch(:cache, HOMEBREW_CACHE)
|
@cache = meta.fetch(:cache, HOMEBREW_CACHE)
|
||||||
@meta = meta
|
@meta = meta
|
||||||
@shutup = false
|
|
||||||
extend Pourable if meta[:bottle]
|
extend Pourable if meta[:bottle]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Download and cache the resource as {#cached_location}.
|
# Download and cache the resource as {#cached_location}.
|
||||||
def fetch; end
|
def fetch; end
|
||||||
|
|
||||||
# Suppress output
|
|
||||||
def shutup!
|
|
||||||
@shutup = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def puts(*args)
|
def puts(*args)
|
||||||
super(*args) unless shutup
|
super(*args) unless quiet?
|
||||||
end
|
end
|
||||||
|
|
||||||
def ohai(*args)
|
def ohai(*args)
|
||||||
super(*args) unless shutup
|
super(*args) unless quiet?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unpack {#cached_location} into the current working directory, and possibly
|
# Unpack {#cached_location} into the current working directory, and possibly
|
||||||
@ -60,7 +55,7 @@ class AbstractDownloadStrategy
|
|||||||
ref_type: @ref_type, ref: @ref)
|
ref_type: @ref_type, ref: @ref)
|
||||||
.extract_nestedly(basename: basename,
|
.extract_nestedly(basename: basename,
|
||||||
prioritise_extension: true,
|
prioritise_extension: true,
|
||||||
verbose: Homebrew.args.verbose? && !shutup)
|
verbose: verbose? && !quiet?)
|
||||||
chdir
|
chdir
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -102,9 +97,9 @@ class AbstractDownloadStrategy
|
|||||||
def system_command!(*args, **options)
|
def system_command!(*args, **options)
|
||||||
super(
|
super(
|
||||||
*args,
|
*args,
|
||||||
print_stdout: !shutup,
|
print_stdout: !quiet?,
|
||||||
print_stderr: !shutup,
|
print_stderr: !quiet?,
|
||||||
verbose: Homebrew.args.verbose? && !shutup,
|
verbose: verbose? && !quiet?,
|
||||||
env: env,
|
env: env,
|
||||||
**options,
|
**options,
|
||||||
)
|
)
|
||||||
@ -498,7 +493,7 @@ class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
|
|||||||
def stage
|
def stage
|
||||||
UnpackStrategy::Uncompressed.new(cached_location)
|
UnpackStrategy::Uncompressed.new(cached_location)
|
||||||
.extract(basename: basename,
|
.extract(basename: basename,
|
||||||
verbose: Homebrew.args.verbose? && !shutup)
|
verbose: verbose? && !quiet?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -553,7 +548,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
|||||||
# This saves on bandwidth and will have a similar effect to verifying the
|
# This saves on bandwidth and will have a similar effect to verifying the
|
||||||
# cache as it will make any changes to get the right revision.
|
# cache as it will make any changes to get the right revision.
|
||||||
args = []
|
args = []
|
||||||
args << "--quiet" unless Homebrew.args.verbose?
|
args << "--quiet" unless verbose?
|
||||||
|
|
||||||
if revision
|
if revision
|
||||||
ohai "Checking out #{@ref}"
|
ohai "Checking out #{@ref}"
|
||||||
@ -897,7 +892,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def quiet_flag
|
def quiet_flag
|
||||||
"-Q" unless Homebrew.args.verbose?
|
"-Q" unless verbose?
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone_repo
|
def clone_repo
|
||||||
|
@ -356,10 +356,10 @@ class BuildError < RuntimeError
|
|||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def dump
|
def dump(verbose: false)
|
||||||
puts
|
puts
|
||||||
|
|
||||||
if Homebrew.args.verbose?
|
if verbose
|
||||||
require "system_config"
|
require "system_config"
|
||||||
require "build_environment"
|
require "build_environment"
|
||||||
|
|
||||||
|
@ -419,6 +419,8 @@ require "extend/os/pathname"
|
|||||||
# @private
|
# @private
|
||||||
module ObserverPathnameExtension
|
module ObserverPathnameExtension
|
||||||
class << self
|
class << self
|
||||||
|
include Context
|
||||||
|
|
||||||
attr_accessor :n, :d
|
attr_accessor :n, :d
|
||||||
|
|
||||||
def reset_counts!
|
def reset_counts!
|
||||||
@ -437,8 +439,8 @@ module ObserverPathnameExtension
|
|||||||
MAXIMUM_VERBOSE_OUTPUT = 100
|
MAXIMUM_VERBOSE_OUTPUT = 100
|
||||||
|
|
||||||
def verbose?
|
def verbose?
|
||||||
return Homebrew.args.verbose? unless ENV["CI"]
|
return super unless ENV["CI"]
|
||||||
return false unless Homebrew.args.verbose?
|
return false unless super
|
||||||
|
|
||||||
if total < MAXIMUM_VERBOSE_OUTPUT
|
if total < MAXIMUM_VERBOSE_OUTPUT
|
||||||
true
|
true
|
||||||
|
@ -54,9 +54,11 @@ class Formula
|
|||||||
include Utils::Inreplace
|
include Utils::Inreplace
|
||||||
include Utils::Shebang
|
include Utils::Shebang
|
||||||
include Utils::Shell
|
include Utils::Shell
|
||||||
|
include Context
|
||||||
extend Enumerable
|
extend Enumerable
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
extend Cachable
|
extend Cachable
|
||||||
|
extend Predicable
|
||||||
|
|
||||||
# @!method inreplace(paths, before = nil, after = nil)
|
# @!method inreplace(paths, before = nil, after = nil)
|
||||||
# Actually implemented in {Utils::Inreplace.inreplace}.
|
# Actually implemented in {Utils::Inreplace.inreplace}.
|
||||||
@ -536,8 +538,10 @@ class Formula
|
|||||||
return false unless head&.downloader.is_a?(VCSDownloadStrategy)
|
return false unless head&.downloader.is_a?(VCSDownloadStrategy)
|
||||||
|
|
||||||
downloader = head.downloader
|
downloader = head.downloader
|
||||||
downloader.shutup! unless Homebrew.args.verbose?
|
|
||||||
downloader.commit_outdated?(version.version.commit)
|
with_context quiet: true do
|
||||||
|
downloader.commit_outdated?(version.version.commit)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The latest prefix for this formula. Checks for {#head}, then {#devel}
|
# The latest prefix for this formula. Checks for {#head}, then {#devel}
|
||||||
@ -1182,7 +1186,7 @@ class Formula
|
|||||||
begin
|
begin
|
||||||
yield self, staging
|
yield self, staging
|
||||||
rescue
|
rescue
|
||||||
staging.retain! if interactive || Homebrew.args.debug?
|
staging.retain! if interactive || debug?
|
||||||
raise
|
raise
|
||||||
ensure
|
ensure
|
||||||
cp Dir["config.log", "CMakeCache.txt"], logs
|
cp Dir["config.log", "CMakeCache.txt"], logs
|
||||||
@ -1831,13 +1835,13 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception # rubocop:disable Lint/RescueException
|
rescue Exception # rubocop:disable Lint/RescueException
|
||||||
staging.retain! if Homebrew.args.debug?
|
staging.retain! if debug?
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
@testpath = nil
|
|
||||||
@prefix_returns_versioned_prefix = false
|
@prefix_returns_versioned_prefix = false
|
||||||
|
@testpath = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
@ -1927,13 +1931,12 @@ class Formula
|
|||||||
# # If there is a "make", "install" available, please use it!
|
# # If there is a "make", "install" available, please use it!
|
||||||
# system "make", "install"</pre>
|
# system "make", "install"</pre>
|
||||||
def system(cmd, *args)
|
def system(cmd, *args)
|
||||||
verbose = Homebrew.args.verbose?
|
|
||||||
verbose_using_dots = Homebrew::EnvConfig.verbose_using_dots?
|
verbose_using_dots = Homebrew::EnvConfig.verbose_using_dots?
|
||||||
|
|
||||||
# remove "boring" arguments so that the important ones are more likely to
|
# remove "boring" arguments so that the important ones are more likely to
|
||||||
# be shown considering that we trim long ohai lines to the terminal width
|
# be shown considering that we trim long ohai lines to the terminal width
|
||||||
pretty_args = args.dup
|
pretty_args = args.dup
|
||||||
unless verbose
|
unless verbose?
|
||||||
case cmd
|
case cmd
|
||||||
when "./configure"
|
when "./configure"
|
||||||
pretty_args -= %w[--disable-dependency-tracking --disable-debug --disable-silent-rules]
|
pretty_args -= %w[--disable-dependency-tracking --disable-debug --disable-silent-rules]
|
||||||
@ -1961,7 +1964,7 @@ class Formula
|
|||||||
log.puts Time.now, "", cmd, args, ""
|
log.puts Time.now, "", cmd, args, ""
|
||||||
log.flush
|
log.flush
|
||||||
|
|
||||||
if verbose
|
if verbose?
|
||||||
rd, wr = IO.pipe
|
rd, wr = IO.pipe
|
||||||
begin
|
begin
|
||||||
pid = fork do
|
pid = fork do
|
||||||
@ -2004,7 +2007,7 @@ class Formula
|
|||||||
log_lines = Homebrew::EnvConfig.fail_log_lines
|
log_lines = Homebrew::EnvConfig.fail_log_lines
|
||||||
|
|
||||||
log.flush
|
log.flush
|
||||||
if !verbose || verbose_using_dots
|
if !verbose? || verbose_using_dots
|
||||||
puts "Last #{log_lines} lines from #{logfn}:"
|
puts "Last #{log_lines} lines from #{logfn}:"
|
||||||
Kernel.system "/usr/bin/tail", "-n", log_lines, logfn
|
Kernel.system "/usr/bin/tail", "-n", log_lines, logfn
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module Assertions
|
module Assertions
|
||||||
|
include Context
|
||||||
|
|
||||||
require "test/unit/assertions"
|
require "test/unit/assertions"
|
||||||
include ::Test::Unit::Assertions
|
include ::Test::Unit::Assertions
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ module Homebrew
|
|||||||
assert_equal result, $CHILD_STATUS.exitstatus
|
assert_equal result, $CHILD_STATUS.exitstatus
|
||||||
output
|
output
|
||||||
rescue Test::Unit::AssertionFailedError
|
rescue Test::Unit::AssertionFailedError
|
||||||
puts output if Homebrew.args.verbose?
|
puts output if verbose?
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ module Homebrew
|
|||||||
assert_equal result, $CHILD_STATUS.exitstatus unless result.nil?
|
assert_equal result, $CHILD_STATUS.exitstatus unless result.nil?
|
||||||
output
|
output
|
||||||
rescue Test::Unit::AssertionFailedError
|
rescue Test::Unit::AssertionFailedError
|
||||||
puts output if Homebrew.args.verbose?
|
puts output if verbose?
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,8 @@ class FormulaInstaller
|
|||||||
force_bottle: false,
|
force_bottle: false,
|
||||||
include_test_formulae: [],
|
include_test_formulae: [],
|
||||||
build_from_source_formulae: [],
|
build_from_source_formulae: [],
|
||||||
cc: nil)
|
cc: nil,
|
||||||
|
debug: false, quiet: false, verbose: false)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@env = nil
|
@env = nil
|
||||||
@force = false
|
@force = false
|
||||||
@ -68,9 +69,9 @@ class FormulaInstaller
|
|||||||
@interactive = false
|
@interactive = false
|
||||||
@git = false
|
@git = false
|
||||||
@cc = cc
|
@cc = cc
|
||||||
@verbose = Homebrew.args.verbose?
|
@verbose = verbose
|
||||||
@quiet = Homebrew.args.quiet?
|
@quiet = quiet
|
||||||
@debug = Homebrew.args.debug?
|
@debug = debug
|
||||||
@installed_as_dependency = false
|
@installed_as_dependency = false
|
||||||
@installed_on_request = true
|
@installed_on_request = true
|
||||||
@options = Options.new
|
@options = Options.new
|
||||||
@ -601,15 +602,13 @@ 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_formulae: include_test_formulae,
|
include_test_formulae: include_test_formulae,
|
||||||
build_from_source_formulae: build_from_source_formulae)
|
build_from_source_formulae: build_from_source_formulae,
|
||||||
|
debug: debug?, quiet: quiet?, verbose: verbose?)
|
||||||
|
|
||||||
fi.force = force?
|
fi.force = force?
|
||||||
fi.keep_tmp = keep_tmp?
|
fi.keep_tmp = keep_tmp?
|
||||||
fi.verbose = verbose?
|
|
||||||
fi.quiet = quiet?
|
|
||||||
fi.debug = debug?
|
|
||||||
# When fetching we don't need to recurse the dependency tree as it's already
|
# When fetching we don't need to recurse the dependency tree as it's already
|
||||||
# been done for us in `compute_dependencies` and there's no requirement to
|
# been done for us in `compute_dependencies` and there's no requirement to
|
||||||
# fetch in a particular order.
|
# fetch in a particular order.
|
||||||
@ -642,9 +641,10 @@ class FormulaInstaller
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
fi = FormulaInstaller.new(df, force_bottle: false,
|
fi = FormulaInstaller.new(df, force_bottle: false,
|
||||||
include_test_formulae: include_test_formulae,
|
include_test_formulae: include_test_formulae,
|
||||||
build_from_source_formulae: build_from_source_formulae)
|
build_from_source_formulae: build_from_source_formulae,
|
||||||
|
debug: debug?, quiet: quiet?, verbose: verbose?)
|
||||||
|
|
||||||
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)
|
||||||
@ -652,9 +652,6 @@ class FormulaInstaller
|
|||||||
fi.options &= df.options
|
fi.options &= df.options
|
||||||
fi.force = force?
|
fi.force = force?
|
||||||
fi.keep_tmp = keep_tmp?
|
fi.keep_tmp = keep_tmp?
|
||||||
fi.verbose = verbose?
|
|
||||||
fi.quiet = quiet?
|
|
||||||
fi.debug = debug?
|
|
||||||
fi.link_keg ||= keg_was_linked if keg_had_linked_keg
|
fi.link_keg ||= keg_was_linked if keg_had_linked_keg
|
||||||
fi.installed_as_dependency = true
|
fi.installed_as_dependency = true
|
||||||
fi.installed_on_request = df.any_version_installed? && tab.installed_on_request
|
fi.installed_on_request = df.any_version_installed? && tab.installed_on_request
|
||||||
@ -665,7 +662,7 @@ class FormulaInstaller
|
|||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
ignore_interrupts do
|
ignore_interrupts do
|
||||||
tmp_keg.rename(installed_keg) if tmp_keg && !installed_keg.directory?
|
tmp_keg.rename(installed_keg) if tmp_keg && !installed_keg.directory?
|
||||||
linked_keg.link if keg_was_linked
|
linked_keg.link(verbose: verbose?) if keg_was_linked
|
||||||
end
|
end
|
||||||
raise unless e.is_a? FormulaInstallationAlreadyAttemptedError
|
raise unless e.is_a? FormulaInstallationAlreadyAttemptedError
|
||||||
|
|
||||||
@ -845,7 +842,7 @@ class FormulaInstaller
|
|||||||
def link(keg)
|
def link(keg)
|
||||||
unless link_keg
|
unless link_keg
|
||||||
begin
|
begin
|
||||||
keg.optlink
|
keg.optlink(verbose: verbose?)
|
||||||
Formula.clear_cache
|
Formula.clear_cache
|
||||||
rescue Keg::LinkError => e
|
rescue Keg::LinkError => e
|
||||||
onoe "Failed to create #{formula.opt_prefix}"
|
onoe "Failed to create #{formula.opt_prefix}"
|
||||||
@ -876,7 +873,7 @@ class FormulaInstaller
|
|||||||
backup_dir = HOMEBREW_CACHE/"Backup"
|
backup_dir = HOMEBREW_CACHE/"Backup"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
keg.link
|
keg.link(verbose: verbose?)
|
||||||
rescue Keg::ConflictError => e
|
rescue Keg::ConflictError => e
|
||||||
conflict_file = e.dst
|
conflict_file = e.dst
|
||||||
if formula.link_overwrite?(conflict_file) && !link_overwrite_backup.key?(conflict_file)
|
if formula.link_overwrite?(conflict_file) && !link_overwrite_backup.key?(conflict_file)
|
||||||
@ -891,8 +888,7 @@ class FormulaInstaller
|
|||||||
puts e
|
puts e
|
||||||
puts
|
puts
|
||||||
puts "Possible conflicting files are:"
|
puts "Possible conflicting files are:"
|
||||||
mode = OpenStruct.new(dry_run: true, overwrite: true)
|
keg.link(dry_run: true, overwrite: true, verbose: verbose?)
|
||||||
keg.link(mode)
|
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
rescue Keg::LinkError => e
|
rescue Keg::LinkError => e
|
||||||
@ -939,7 +935,7 @@ class FormulaInstaller
|
|||||||
log.mkpath if formula.plist.include? log.to_s
|
log.mkpath if formula.plist.include? log.to_s
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
onoe "Failed to install plist file"
|
onoe "Failed to install plist file"
|
||||||
ohai e, e.backtrace if debug?
|
odebug e, e.backtrace
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -949,7 +945,7 @@ class FormulaInstaller
|
|||||||
onoe "Failed to fix install linkage"
|
onoe "Failed to fix install linkage"
|
||||||
puts "The formula built, but you may encounter issues using it or linking other"
|
puts "The formula built, but you may encounter issues using it or linking other"
|
||||||
puts "formulae against it."
|
puts "formulae against it."
|
||||||
ohai e, e.backtrace if debug?
|
odebug e, e.backtrace
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
@ -960,7 +956,7 @@ class FormulaInstaller
|
|||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
opoo "The cleaning step did not complete successfully"
|
opoo "The cleaning step did not complete successfully"
|
||||||
puts "Still, the installation was successful, so we will link it into your prefix"
|
puts "Still, the installation was successful, so we will link it into your prefix"
|
||||||
ohai e, e.backtrace if debug?
|
odebug e, e.backtrace
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
@ -996,7 +992,7 @@ class FormulaInstaller
|
|||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
opoo "The post-install step did not complete successfully"
|
opoo "The post-install step did not complete successfully"
|
||||||
puts "You can try again using `brew postinstall #{formula.full_name}`"
|
puts "You can try again using `brew postinstall #{formula.full_name}`"
|
||||||
ohai e, e.backtrace if debug? || Homebrew::EnvConfig.developer?
|
odebug e, e.backtrace, always_display: Homebrew::EnvConfig.developer?
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
class FormulaVersions
|
class FormulaVersions
|
||||||
|
include Context
|
||||||
|
|
||||||
IGNORED_EXCEPTIONS = [
|
IGNORED_EXCEPTIONS = [
|
||||||
ArgumentError, NameError, SyntaxError, TypeError,
|
ArgumentError, NameError, SyntaxError, TypeError,
|
||||||
FormulaSpecificationError, FormulaValidationError,
|
FormulaSpecificationError, FormulaValidationError,
|
||||||
@ -44,7 +46,7 @@ class FormulaVersions
|
|||||||
rescue *IGNORED_EXCEPTIONS => e
|
rescue *IGNORED_EXCEPTIONS => e
|
||||||
# We rescue these so that we can skip bad versions and
|
# We rescue these so that we can skip bad versions and
|
||||||
# continue walking the history
|
# continue walking the history
|
||||||
odebug "#{e} in #{name} at revision #{rev}", e.backtrace if Homebrew.args.debug?
|
odebug "#{e} in #{name} at revision #{rev}", e.backtrace if debug?
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
nil
|
nil
|
||||||
ensure
|
ensure
|
||||||
|
@ -109,6 +109,8 @@ module Formulary
|
|||||||
# A FormulaLoader returns instances of formulae.
|
# A FormulaLoader returns instances of formulae.
|
||||||
# Subclasses implement loaders for particular sources of formulae.
|
# Subclasses implement loaders for particular sources of formulae.
|
||||||
class FormulaLoader
|
class FormulaLoader
|
||||||
|
include Context
|
||||||
|
|
||||||
# The formula's name
|
# The formula's name
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
# The formula's ruby file's path or filename
|
# The formula's ruby file's path or filename
|
||||||
@ -138,7 +140,7 @@ module Formulary
|
|||||||
private
|
private
|
||||||
|
|
||||||
def load_file(flags:)
|
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 debug?
|
||||||
raise FormulaUnavailableError, name unless path.file?
|
raise FormulaUnavailableError, name unless path.file?
|
||||||
|
|
||||||
Formulary.load_formula_from_path(name, path, flags: flags)
|
Formulary.load_formula_from_path(name, path, flags: flags)
|
||||||
@ -314,7 +316,7 @@ module Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
def klass(flags:)
|
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 debug?
|
||||||
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(contents.to_s)}"
|
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(contents.to_s)}"
|
||||||
Formulary.load_formula(name, path, contents, namespace, flags: flags)
|
Formulary.load_formula(name, path, contents, namespace, flags: flags)
|
||||||
end
|
end
|
||||||
|
@ -37,7 +37,6 @@ require "config"
|
|||||||
require "os"
|
require "os"
|
||||||
require "cli/args"
|
require "cli/args"
|
||||||
require "messages"
|
require "messages"
|
||||||
require "system_command"
|
|
||||||
|
|
||||||
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
|
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
|
||||||
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
|
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
|
||||||
@ -116,6 +115,7 @@ end.compact.freeze
|
|||||||
|
|
||||||
require "set"
|
require "set"
|
||||||
|
|
||||||
|
require "context"
|
||||||
require "extend/pathname"
|
require "extend/pathname"
|
||||||
|
|
||||||
require "extend/module"
|
require "extend/module"
|
||||||
@ -125,6 +125,7 @@ require "active_support/core_ext/object/blank"
|
|||||||
require "active_support/core_ext/hash/deep_merge"
|
require "active_support/core_ext/hash/deep_merge"
|
||||||
require "active_support/core_ext/file/atomic"
|
require "active_support/core_ext/file/atomic"
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
require "exceptions"
|
require "exceptions"
|
||||||
require "utils"
|
require "utils"
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ module Homebrew
|
|||||||
module Help
|
module Help
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def help(cmd = nil, empty_argv: false, usage_error: nil)
|
def help(cmd = nil, empty_argv: false, usage_error: nil, remaining_args: [])
|
||||||
if cmd.nil?
|
if cmd.nil?
|
||||||
# Handle `brew` (no arguments).
|
# Handle `brew` (no arguments).
|
||||||
if empty_argv
|
if empty_argv
|
||||||
@ -58,7 +58,7 @@ module Homebrew
|
|||||||
|
|
||||||
# Display command-specific (or generic) help in response to `UsageError`.
|
# Display command-specific (or generic) help in response to `UsageError`.
|
||||||
if usage_error
|
if usage_error
|
||||||
$stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP
|
$stderr.puts path ? command_help(cmd, path, remaining_args: remaining_args) : HOMEBREW_HELP
|
||||||
$stderr.puts
|
$stderr.puts
|
||||||
onoe usage_error
|
onoe usage_error
|
||||||
exit 1
|
exit 1
|
||||||
@ -68,16 +68,16 @@ module Homebrew
|
|||||||
return if path.nil?
|
return if path.nil?
|
||||||
|
|
||||||
# Display help for internal command (or generic help if undocumented).
|
# Display help for internal command (or generic help if undocumented).
|
||||||
puts command_help(cmd, path)
|
puts command_help(cmd, path, remaining_args: remaining_args)
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def command_help(cmd, path)
|
def command_help(cmd, path, remaining_args:)
|
||||||
# Only some types of commands can have a parser.
|
# Only some types of commands can have a parser.
|
||||||
output = if Commands.valid_internal_cmd?(cmd) ||
|
output = if Commands.valid_internal_cmd?(cmd) ||
|
||||||
Commands.valid_internal_dev_cmd?(cmd) ||
|
Commands.valid_internal_dev_cmd?(cmd) ||
|
||||||
Commands.external_ruby_v2_cmd_path(cmd)
|
Commands.external_ruby_v2_cmd_path(cmd)
|
||||||
parser_help(path)
|
parser_help(path, remaining_args: remaining_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
output ||= comment_help(path)
|
output ||= comment_help(path)
|
||||||
@ -90,13 +90,13 @@ module Homebrew
|
|||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
def parser_help(path)
|
def parser_help(path, remaining_args:)
|
||||||
# Let OptionParser generate help text for commands which have a parser.
|
# Let OptionParser generate help text for commands which have a parser.
|
||||||
cmd_parser = CLI::Parser.from_cmd_path(path)
|
cmd_parser = CLI::Parser.from_cmd_path(path)
|
||||||
return unless cmd_parser
|
return unless cmd_parser
|
||||||
|
|
||||||
# Try parsing arguments here in order to show formula options in help output.
|
# Try parsing arguments here in order to show formula options in help output.
|
||||||
cmd_parser.parse(Homebrew.args.remaining, ignore_invalid_options: true)
|
cmd_parser.parse(remaining_args, ignore_invalid_options: true)
|
||||||
cmd_parser.generate_help_text
|
cmd_parser.generate_help_text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ class Keg
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink(mode = OpenStruct.new)
|
def unlink(**options)
|
||||||
ObserverPathnameExtension.reset_counts!
|
ObserverPathnameExtension.reset_counts!
|
||||||
|
|
||||||
dirs = []
|
dirs = []
|
||||||
@ -341,7 +341,7 @@ class Keg
|
|||||||
next unless dst.symlink?
|
next unless dst.symlink?
|
||||||
next if src != dst.resolved_path
|
next if src != dst.resolved_path
|
||||||
|
|
||||||
if mode.dry_run
|
if options[:dry_run]
|
||||||
puts dst
|
puts dst
|
||||||
Find.prune if src.directory?
|
Find.prune if src.directory?
|
||||||
next
|
next
|
||||||
@ -354,7 +354,7 @@ class Keg
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless mode.dry_run
|
unless options[:dry_run]
|
||||||
remove_linked_keg_record if linked?
|
remove_linked_keg_record if linked?
|
||||||
dirs.reverse_each(&:rmdir_if_possible)
|
dirs.reverse_each(&:rmdir_if_possible)
|
||||||
end
|
end
|
||||||
@ -436,21 +436,21 @@ class Keg
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def link(mode = OpenStruct.new)
|
def link(**options)
|
||||||
raise AlreadyLinkedError, self if linked_keg_record.directory?
|
raise AlreadyLinkedError, self if linked_keg_record.directory?
|
||||||
|
|
||||||
ObserverPathnameExtension.reset_counts!
|
ObserverPathnameExtension.reset_counts!
|
||||||
|
|
||||||
optlink(mode) unless mode.dry_run
|
optlink(**options) unless options[:dry_run]
|
||||||
|
|
||||||
# yeah indeed, you have to force anything you need in the main tree into
|
# yeah indeed, you have to force anything you need in the main tree into
|
||||||
# these dirs REMEMBER that *NOT* everything needs to be in the main tree
|
# these dirs REMEMBER that *NOT* everything needs to be in the main tree
|
||||||
link_dir("etc", mode) { :mkpath }
|
link_dir("etc", **options) { :mkpath }
|
||||||
link_dir("bin", mode) { :skip_dir }
|
link_dir("bin", **options) { :skip_dir }
|
||||||
link_dir("sbin", mode) { :skip_dir }
|
link_dir("sbin", **options) { :skip_dir }
|
||||||
link_dir("include", mode) { :link }
|
link_dir("include", **options) { :link }
|
||||||
|
|
||||||
link_dir("share", mode) do |relative_path|
|
link_dir("share", **options) do |relative_path|
|
||||||
case relative_path.to_s
|
case relative_path.to_s
|
||||||
when "locale/locale.alias" then :skip_file
|
when "locale/locale.alias" then :skip_file
|
||||||
when INFOFILE_RX then :info
|
when INFOFILE_RX then :info
|
||||||
@ -468,7 +468,7 @@ class Keg
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
link_dir("lib", mode) do |relative_path|
|
link_dir("lib", **options) do |relative_path|
|
||||||
case relative_path.to_s
|
case relative_path.to_s
|
||||||
when "charset.alias" then :skip_file
|
when "charset.alias" then :skip_file
|
||||||
# pkg-config database gets explicitly created
|
# pkg-config database gets explicitly created
|
||||||
@ -494,7 +494,7 @@ class Keg
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
link_dir("Frameworks", mode) do |relative_path|
|
link_dir("Frameworks", **options) do |relative_path|
|
||||||
# Frameworks contain symlinks pointing into a subdir, so we have to use
|
# Frameworks contain symlinks pointing into a subdir, so we have to use
|
||||||
# the :link strategy. However, for Foo.framework and
|
# the :link strategy. However, for Foo.framework and
|
||||||
# Foo.framework/Versions we have to use :mkpath so that multiple formulae
|
# Foo.framework/Versions we have to use :mkpath so that multiple formulae
|
||||||
@ -506,9 +506,9 @@ class Keg
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
make_relative_symlink(linked_keg_record, path, mode) unless mode.dry_run
|
make_relative_symlink(linked_keg_record, path, **options) unless options[:dry_run]
|
||||||
rescue LinkError
|
rescue LinkError
|
||||||
unlink
|
unlink(verbose: options[:verbose])
|
||||||
raise
|
raise
|
||||||
else
|
else
|
||||||
ObserverPathnameExtension.n
|
ObserverPathnameExtension.n
|
||||||
@ -536,19 +536,19 @@ class Keg
|
|||||||
tab.aliases || []
|
tab.aliases || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def optlink(mode = OpenStruct.new)
|
def optlink(**options)
|
||||||
opt_record.delete if opt_record.symlink? || opt_record.exist?
|
opt_record.delete if opt_record.symlink? || opt_record.exist?
|
||||||
make_relative_symlink(opt_record, path, mode)
|
make_relative_symlink(opt_record, path, **options)
|
||||||
aliases.each do |a|
|
aliases.each do |a|
|
||||||
alias_opt_record = opt_record.parent/a
|
alias_opt_record = opt_record.parent/a
|
||||||
alias_opt_record.delete if alias_opt_record.symlink? || alias_opt_record.exist?
|
alias_opt_record.delete if alias_opt_record.symlink? || alias_opt_record.exist?
|
||||||
make_relative_symlink(alias_opt_record, path, mode)
|
make_relative_symlink(alias_opt_record, path, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless oldname_opt_record
|
return unless oldname_opt_record
|
||||||
|
|
||||||
oldname_opt_record.delete
|
oldname_opt_record.delete
|
||||||
make_relative_symlink(oldname_opt_record, path, mode)
|
make_relative_symlink(oldname_opt_record, path, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_pyc_files!
|
def delete_pyc_files!
|
||||||
@ -558,7 +558,7 @@ class Keg
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def resolve_any_conflicts(dst, mode)
|
def resolve_any_conflicts(dst, **options)
|
||||||
return unless dst.symlink?
|
return unless dst.symlink?
|
||||||
|
|
||||||
src = dst.resolved_path
|
src = dst.resolved_path
|
||||||
@ -571,7 +571,7 @@ class Keg
|
|||||||
stat = src.lstat
|
stat = src.lstat
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
# dst is a broken symlink, so remove it.
|
# dst is a broken symlink, so remove it.
|
||||||
dst.unlink unless mode.dry_run
|
dst.unlink unless options[:dry_run]
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -580,25 +580,23 @@ class Keg
|
|||||||
begin
|
begin
|
||||||
keg = Keg.for(src)
|
keg = Keg.for(src)
|
||||||
rescue NotAKegError
|
rescue NotAKegError
|
||||||
if Homebrew.args.verbose?
|
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if options[:verbose]
|
||||||
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar"
|
|
||||||
end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
dst.unlink unless mode.dry_run
|
dst.unlink unless options[:dry_run]
|
||||||
keg.link_dir(src, mode) { :mkpath }
|
keg.link_dir(src, **options) { :mkpath }
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_relative_symlink(dst, src, mode)
|
def make_relative_symlink(dst, src, **options)
|
||||||
if dst.symlink? && src == dst.resolved_path
|
if dst.symlink? && src == dst.resolved_path
|
||||||
puts "Skipping; link already exists: #{dst}" if Homebrew.args.verbose?
|
puts "Skipping; link already exists: #{dst}" if options[:verbose]
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# cf. git-clean -n: list files to delete, don't really link or delete
|
# cf. git-clean -n: list files to delete, don't really link or delete
|
||||||
if mode.dry_run && mode.overwrite
|
if options[:dry_run] && options[:overwrite]
|
||||||
if dst.symlink?
|
if dst.symlink?
|
||||||
puts "#{dst} -> #{dst.resolved_path}"
|
puts "#{dst} -> #{dst.resolved_path}"
|
||||||
elsif dst.exist?
|
elsif dst.exist?
|
||||||
@ -608,12 +606,12 @@ class Keg
|
|||||||
end
|
end
|
||||||
|
|
||||||
# list all link targets
|
# list all link targets
|
||||||
if mode.dry_run
|
if options[:dry_run]
|
||||||
puts dst
|
puts dst
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
dst.delete if mode.overwrite && (dst.exist? || dst.symlink?)
|
dst.delete if options[:overwrite] && (dst.exist? || dst.symlink?)
|
||||||
dst.make_relative_symlink(src)
|
dst.make_relative_symlink(src)
|
||||||
rescue Errno::EEXIST => e
|
rescue Errno::EEXIST => e
|
||||||
raise ConflictError.new(self, src.relative_path_from(path), dst, e) if dst.exist?
|
raise ConflictError.new(self, src.relative_path_from(path), dst, e) if dst.exist?
|
||||||
@ -631,7 +629,7 @@ class Keg
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
# symlinks the contents of path+relative_dir recursively into #{HOMEBREW_PREFIX}/relative_dir
|
# symlinks the contents of path+relative_dir recursively into #{HOMEBREW_PREFIX}/relative_dir
|
||||||
def link_dir(relative_dir, mode)
|
def link_dir(relative_dir, **options)
|
||||||
root = path/relative_dir
|
root = path/relative_dir
|
||||||
return unless root.exist?
|
return unless root.exist?
|
||||||
|
|
||||||
@ -655,10 +653,10 @@ class Keg
|
|||||||
when :info
|
when :info
|
||||||
next if File.basename(src) == "dir" # skip historical local 'dir' files
|
next if File.basename(src) == "dir" # skip historical local 'dir' files
|
||||||
|
|
||||||
make_relative_symlink dst, src, mode
|
make_relative_symlink dst, src, **options
|
||||||
dst.install_info
|
dst.install_info
|
||||||
else
|
else
|
||||||
make_relative_symlink dst, src, mode
|
make_relative_symlink dst, src, **options
|
||||||
end
|
end
|
||||||
elsif src.directory?
|
elsif src.directory?
|
||||||
# if the dst dir already exists, then great! walk the rest of the tree tho
|
# if the dst dir already exists, then great! walk the rest of the tree tho
|
||||||
@ -672,10 +670,10 @@ class Keg
|
|||||||
when :skip_dir
|
when :skip_dir
|
||||||
Find.prune
|
Find.prune
|
||||||
when :mkpath
|
when :mkpath
|
||||||
dst.mkpath unless resolve_any_conflicts(dst, mode)
|
dst.mkpath unless resolve_any_conflicts(dst, **options)
|
||||||
else
|
else
|
||||||
unless resolve_any_conflicts(dst, mode)
|
unless resolve_any_conflicts(dst, **options)
|
||||||
make_relative_symlink dst, src, mode
|
make_relative_symlink dst, src, **options
|
||||||
Find.prune
|
Find.prune
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,8 @@ require "keg"
|
|||||||
require "tab"
|
require "tab"
|
||||||
|
|
||||||
class Migrator
|
class Migrator
|
||||||
|
include Context
|
||||||
|
|
||||||
class MigrationNeededError < RuntimeError
|
class MigrationNeededError < RuntimeError
|
||||||
def initialize(formula)
|
def initialize(formula)
|
||||||
super <<~EOS
|
super <<~EOS
|
||||||
@ -209,7 +211,7 @@ class Migrator
|
|||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
onoe "Error occurred while migrating."
|
onoe "Error occurred while migrating."
|
||||||
puts e
|
puts e
|
||||||
puts e.backtrace if Homebrew.args.debug?
|
puts e.backtrace if debug?
|
||||||
puts "Backing up..."
|
puts "Backing up..."
|
||||||
ignore_interrupts { backup_oldname }
|
ignore_interrupts { backup_oldname }
|
||||||
ensure
|
ensure
|
||||||
@ -267,7 +269,7 @@ class Migrator
|
|||||||
oh1 "Unlinking #{Formatter.identifier(oldname)}"
|
oh1 "Unlinking #{Formatter.identifier(oldname)}"
|
||||||
old_cellar.subdirs.each do |d|
|
old_cellar.subdirs.each do |d|
|
||||||
keg = Keg.new(d)
|
keg = Keg.new(d)
|
||||||
keg.unlink
|
keg.unlink(verbose: verbose?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -275,7 +277,7 @@ class Migrator
|
|||||||
oh1 "Temporarily unlinking #{Formatter.identifier(newname)}"
|
oh1 "Temporarily unlinking #{Formatter.identifier(newname)}"
|
||||||
new_cellar.subdirs.each do |d|
|
new_cellar.subdirs.each do |d|
|
||||||
keg = Keg.new(d)
|
keg = Keg.new(d)
|
||||||
keg.unlink
|
keg.unlink(verbose: verbose?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -288,7 +290,7 @@ class Migrator
|
|||||||
# If formula is keg-only we also optlink it.
|
# If formula is keg-only we also optlink it.
|
||||||
if formula.keg_only? || !old_linked_keg_record
|
if formula.keg_only? || !old_linked_keg_record
|
||||||
begin
|
begin
|
||||||
new_keg.optlink
|
new_keg.optlink(verbose: verbose?)
|
||||||
rescue Keg::LinkError => e
|
rescue Keg::LinkError => e
|
||||||
onoe "Failed to create #{formula.opt_prefix}"
|
onoe "Failed to create #{formula.opt_prefix}"
|
||||||
raise
|
raise
|
||||||
@ -299,15 +301,13 @@ class Migrator
|
|||||||
new_keg.remove_linked_keg_record if new_keg.linked?
|
new_keg.remove_linked_keg_record if new_keg.linked?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
mode = OpenStruct.new(overwrite: true)
|
new_keg.link(overwrite: true, verbose: verbose?)
|
||||||
new_keg.link(mode)
|
|
||||||
rescue Keg::ConflictError => e
|
rescue Keg::ConflictError => e
|
||||||
onoe "Error while executing `brew link` step on #{newname}"
|
onoe "Error while executing `brew link` step on #{newname}"
|
||||||
puts e
|
puts e
|
||||||
puts
|
puts
|
||||||
puts "Possible conflicting files are:"
|
puts "Possible conflicting files are:"
|
||||||
mode = OpenStruct.new(dry_run: true, overwrite: true)
|
new_keg.link(dry_run: true, overwrite: true, verbose: verbose?)
|
||||||
new_keg.link(mode)
|
|
||||||
raise
|
raise
|
||||||
rescue Keg::LinkError => e
|
rescue Keg::LinkError => e
|
||||||
onoe "Error while linking"
|
onoe "Error while linking"
|
||||||
@ -318,8 +318,8 @@ class Migrator
|
|||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
onoe "An unexpected error occurred during linking"
|
onoe "An unexpected error occurred during linking"
|
||||||
puts e
|
puts e
|
||||||
puts e.backtrace if Homebrew.args.debug?
|
puts e.backtrace if debug?
|
||||||
ignore_interrupts { new_keg.unlink }
|
ignore_interrupts { new_keg.unlink(verbose: verbose?) }
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -384,7 +384,7 @@ class Migrator
|
|||||||
if new_cellar.exist?
|
if new_cellar.exist?
|
||||||
new_cellar.subdirs.each do |d|
|
new_cellar.subdirs.each do |d|
|
||||||
newname_keg = Keg.new(d)
|
newname_keg = Keg.new(d)
|
||||||
newname_keg.unlink
|
newname_keg.unlink(verbose: verbose?)
|
||||||
newname_keg.uninstall if new_cellar_existed
|
newname_keg.uninstall if new_cellar_existed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -396,16 +396,16 @@ class Migrator
|
|||||||
# create a keg using its old path
|
# create a keg using its old path
|
||||||
if old_linked_keg_record
|
if old_linked_keg_record
|
||||||
begin
|
begin
|
||||||
old_linked_keg.link
|
old_linked_keg.link(verbose: verbose?)
|
||||||
rescue Keg::LinkError
|
rescue Keg::LinkError
|
||||||
old_linked_keg.unlink
|
old_linked_keg.unlink(verbose: verbose?)
|
||||||
raise
|
raise
|
||||||
rescue Keg::AlreadyLinkedError
|
rescue Keg::AlreadyLinkedError
|
||||||
old_linked_keg.unlink
|
old_linked_keg.unlink(verbose: verbose?)
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
old_linked_keg.optlink
|
old_linked_keg.optlink(verbose: verbose?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ class Keg
|
|||||||
return if file.dylib_id == id
|
return if file.dylib_id == id
|
||||||
|
|
||||||
@require_relocation = true
|
@require_relocation = true
|
||||||
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}" if Homebrew.args.debug?
|
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
|
||||||
MachO::Tools.change_dylib_id(file, id, strict: false)
|
MachO::Tools.change_dylib_id(file, id, strict: false)
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -20,7 +20,7 @@ class Keg
|
|||||||
return if old == new
|
return if old == new
|
||||||
|
|
||||||
@require_relocation = true
|
@require_relocation = true
|
||||||
odebug "Changing install name in #{file}\n from #{old}\n to #{new}" if Homebrew.args.debug?
|
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
|
||||||
MachO::Tools.change_install_name(file, old, new, strict: false)
|
MachO::Tools.change_install_name(file, old, new, strict: false)
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
|
@ -17,7 +17,7 @@ begin
|
|||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = args.resolved_formulae.first
|
formula = args.resolved_formulae.first
|
||||||
formula.extend(Debrew::Formula) if Homebrew.args.debug?
|
formula.extend(Debrew::Formula) if args.debug?
|
||||||
formula.run_post_install
|
formula.run_post_install
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
error_pipe.puts e.to_json
|
error_pipe.puts e.to_json
|
||||||
|
@ -24,7 +24,8 @@ module Homebrew
|
|||||||
options &= f.options
|
options &= f.options
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
||||||
build_from_source_formulae: args.build_from_source_formulae)
|
build_from_source_formulae: args.build_from_source_formulae,
|
||||||
|
debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?)
|
||||||
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?
|
||||||
@ -48,7 +49,7 @@ module Homebrew
|
|||||||
rescue FormulaInstallationAlreadyAttemptedError
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
nil
|
nil
|
||||||
rescue Exception # rubocop:disable Lint/RescueException
|
rescue Exception # rubocop:disable Lint/RescueException
|
||||||
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
ignore_interrupts { restore_backup(keg, keg_was_linked, verbose: args.verbose?) }
|
||||||
raise
|
raise
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -81,7 +82,7 @@ module Homebrew
|
|||||||
Pathname.new(keg).rmtree if keg.exist?
|
Pathname.new(keg).rmtree if keg.exist?
|
||||||
|
|
||||||
path.rename keg
|
path.rename keg
|
||||||
keg.link if keg_was_linked
|
keg.link(verbose: verbose) if keg_was_linked
|
||||||
end
|
end
|
||||||
|
|
||||||
def backup_path(path)
|
def backup_path(path)
|
||||||
|
@ -9,6 +9,7 @@ require "mktemp"
|
|||||||
# primary formula download, along with other declared resources, are instances
|
# primary formula download, along with other declared resources, are instances
|
||||||
# of this class.
|
# of this class.
|
||||||
class Resource
|
class Resource
|
||||||
|
include Context
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
|
||||||
attr_reader :mirrors, :specs, :using, :source_modified_time, :patches, :owner
|
attr_reader :mirrors, :specs, :using, :source_modified_time, :patches, :owner
|
||||||
@ -140,7 +141,7 @@ class Resource
|
|||||||
|
|
||||||
def verify_download_integrity(fn)
|
def verify_download_integrity(fn)
|
||||||
if fn.file?
|
if fn.file?
|
||||||
ohai "Verifying #{fn.basename} checksum" if Homebrew.args.verbose?
|
ohai "Verifying #{fn.basename} checksum" if verbose?
|
||||||
fn.verify_checksum(checksum)
|
fn.verify_checksum(checksum)
|
||||||
end
|
end
|
||||||
rescue ChecksumMissingError
|
rescue ChecksumMissingError
|
||||||
|
@ -284,9 +284,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
find_instance_call(body_node, "ARGV") do |method_node|
|
find_instance_call(body_node, "ARGV") do |_method_node|
|
||||||
next if [:debug?, :verbose?, :value].index(method_node.method_name)
|
|
||||||
|
|
||||||
problem "Use build instead of ARGV to check options"
|
problem "Use build instead of ARGV to check options"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ class HeadSoftwareSpec < SoftwareSpec
|
|||||||
end
|
end
|
||||||
|
|
||||||
def verify_download_integrity(_fn)
|
def verify_download_integrity(_fn)
|
||||||
nil
|
# no-op
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,9 @@ 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, display_cop_names: false)
|
def check_style_impl(files, output_type,
|
||||||
|
fix: false, except_cops: nil, only_cops: nil, display_cop_names: false,
|
||||||
|
debug: false, verbose: false)
|
||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!
|
||||||
require "rubocop"
|
require "rubocop"
|
||||||
require "rubocops"
|
require "rubocops"
|
||||||
@ -30,7 +32,8 @@ module Homebrew
|
|||||||
"--parallel"
|
"--parallel"
|
||||||
end
|
end
|
||||||
|
|
||||||
args += ["--extra-details", "--display-cop-names"] if Homebrew.args.verbose?
|
args += ["--extra-details"] if verbose
|
||||||
|
args += ["--display-cop-names"] if display_cop_names || verbose
|
||||||
|
|
||||||
if except_cops
|
if except_cops
|
||||||
except_cops.map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
|
except_cops.map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
|
||||||
@ -77,15 +80,13 @@ module Homebrew
|
|||||||
|
|
||||||
case output_type
|
case output_type
|
||||||
when :print
|
when :print
|
||||||
args << "--debug" if Homebrew.args.debug?
|
args << "--debug" if debug
|
||||||
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?
|
||||||
when :json
|
when :json
|
||||||
json, err, status =
|
json, err, status =
|
||||||
Open3.capture3(cache_env, "rubocop",
|
Open3.capture3(cache_env, "rubocop", "--format", "json", *args)
|
||||||
"--format", "json", *args)
|
|
||||||
# exit status of 1 just means violations were found; other numbers mean
|
# exit status of 1 just means violations were found; other numbers mean
|
||||||
# execution errors.
|
# execution errors.
|
||||||
# exitstatus can also be nil if RuboCop process crashes, e.g. due to
|
# exitstatus can also be nil if RuboCop process crashes, e.g. due to
|
||||||
|
@ -8,7 +8,6 @@ require "shellwords"
|
|||||||
require "extend/io"
|
require "extend/io"
|
||||||
require "extend/hash_validator"
|
require "extend/hash_validator"
|
||||||
using HashValidator
|
using HashValidator
|
||||||
require "extend/predicable"
|
|
||||||
|
|
||||||
module Kernel
|
module Kernel
|
||||||
def system_command(*args)
|
def system_command(*args)
|
||||||
@ -21,6 +20,7 @@ module Kernel
|
|||||||
end
|
end
|
||||||
|
|
||||||
class SystemCommand
|
class SystemCommand
|
||||||
|
include Context
|
||||||
extend Predicable
|
extend Predicable
|
||||||
|
|
||||||
attr_reader :pid
|
attr_reader :pid
|
||||||
@ -34,7 +34,7 @@ class SystemCommand
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run!
|
def run!
|
||||||
puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? || Homebrew.args.debug?
|
puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? || debug?
|
||||||
|
|
||||||
@output = []
|
@output = []
|
||||||
|
|
||||||
@ -84,7 +84,13 @@ class SystemCommand
|
|||||||
|
|
||||||
attr_reader :executable, :args, :input, :options, :env
|
attr_reader :executable, :args, :input, :options, :env
|
||||||
|
|
||||||
attr_predicate :sudo?, :print_stdout?, :print_stderr?, :verbose?, :must_succeed?
|
attr_predicate :sudo?, :print_stdout?, :print_stderr?, :must_succeed?
|
||||||
|
|
||||||
|
def verbose?
|
||||||
|
return super if @verbose.nil?
|
||||||
|
|
||||||
|
@verbose
|
||||||
|
end
|
||||||
|
|
||||||
def env_args
|
def env_args
|
||||||
set_variables = env.reject { |_, value| value.nil? }
|
set_variables = env.reject { |_, value| value.nil? }
|
||||||
@ -160,6 +166,8 @@ class SystemCommand
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Result
|
class Result
|
||||||
|
include Context
|
||||||
|
|
||||||
attr_accessor :command, :status, :exit_status
|
attr_accessor :command, :status, :exit_status
|
||||||
|
|
||||||
def initialize(command, output, status, secrets:)
|
def initialize(command, output, status, secrets:)
|
||||||
@ -222,7 +230,7 @@ class SystemCommand
|
|||||||
end
|
end
|
||||||
|
|
||||||
def warn_plist_garbage(garbage)
|
def warn_plist_garbage(garbage)
|
||||||
return unless Homebrew.args.verbose?
|
return unless verbose?
|
||||||
return unless garbage.match?(/\S/)
|
return unless garbage.match?(/\S/)
|
||||||
|
|
||||||
opoo "Received non-XML output from #{Formatter.identifier(command.first)}:"
|
opoo "Received non-XML output from #{Formatter.identifier(command.first)}:"
|
||||||
|
@ -16,9 +16,9 @@ require "dev-cmd/test"
|
|||||||
TEST_TIMEOUT_SECONDS = 5 * 60
|
TEST_TIMEOUT_SECONDS = 5 * 60
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Homebrew.args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
|
|
||||||
|
|
||||||
args = Homebrew.test_args.parse
|
args = Homebrew.test_args.parse
|
||||||
|
Context.current = args.context
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -121,7 +121,6 @@ describe GitDownloadStrategy do
|
|||||||
git_commit_all
|
git_commit_all
|
||||||
end
|
end
|
||||||
|
|
||||||
subject.shutup!
|
|
||||||
expect(subject.fetch_last_commit).to eq("f68266e")
|
expect(subject.fetch_last_commit).to eq("f68266e")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,6 @@ describe Keg do
|
|||||||
|
|
||||||
let(:dst) { HOMEBREW_PREFIX/"bin"/"helloworld" }
|
let(:dst) { HOMEBREW_PREFIX/"bin"/"helloworld" }
|
||||||
let(:nonexistent) { Pathname.new("/some/nonexistent/path") }
|
let(:nonexistent) { Pathname.new("/some/nonexistent/path") }
|
||||||
let(:mode) { OpenStruct.new }
|
|
||||||
let!(:keg) { setup_test_keg("foo", "1.0") }
|
let!(:keg) { setup_test_keg("foo", "1.0") }
|
||||||
let(:kegs) { [] }
|
let(:kegs) { [] }
|
||||||
|
|
||||||
@ -84,11 +83,11 @@ describe Keg do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "with dry run set to true" do
|
context "with dry run set to true" do
|
||||||
it "only prints what would be done" do
|
let(:options) { { dry_run: true } }
|
||||||
mode.dry_run = true
|
|
||||||
|
|
||||||
|
it "only prints what would be done" do
|
||||||
expect {
|
expect {
|
||||||
expect(keg.link(mode)).to eq(0)
|
expect(keg.link(**options)).to eq(0)
|
||||||
}.to output(<<~EOF).to_stdout
|
}.to output(<<~EOF).to_stdout
|
||||||
#{HOMEBREW_PREFIX}/bin/goodbye_cruel_world
|
#{HOMEBREW_PREFIX}/bin/goodbye_cruel_world
|
||||||
#{HOMEBREW_PREFIX}/bin/helloworld
|
#{HOMEBREW_PREFIX}/bin/helloworld
|
||||||
@ -119,27 +118,27 @@ describe Keg do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "with overwrite set to true" do
|
context "with overwrite set to true" do
|
||||||
|
let(:options) { { overwrite: true } }
|
||||||
|
|
||||||
it "overwrite existing files" do
|
it "overwrite existing files" do
|
||||||
touch dst
|
touch dst
|
||||||
mode.overwrite = true
|
expect(keg.link(**options)).to eq(3)
|
||||||
expect(keg.link(mode)).to eq(3)
|
|
||||||
expect(keg).to be_linked
|
expect(keg).to be_linked
|
||||||
end
|
end
|
||||||
|
|
||||||
it "overwrites broken symlinks" do
|
it "overwrites broken symlinks" do
|
||||||
dst.make_symlink "nowhere"
|
dst.make_symlink "nowhere"
|
||||||
mode.overwrite = true
|
expect(keg.link(**options)).to eq(3)
|
||||||
expect(keg.link(mode)).to eq(3)
|
|
||||||
expect(keg).to be_linked
|
expect(keg).to be_linked
|
||||||
end
|
end
|
||||||
|
|
||||||
it "still supports dryrun" do
|
it "still supports dryrun" do
|
||||||
touch dst
|
touch dst
|
||||||
mode.overwrite = true
|
|
||||||
mode.dry_run = true
|
options[:dry_run] = true
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
expect(keg.link(mode)).to eq(0)
|
expect(keg.link(**options)).to eq(0)
|
||||||
}.to output(<<~EOF).to_stdout
|
}.to output(<<~EOF).to_stdout
|
||||||
#{dst}
|
#{dst}
|
||||||
EOF
|
EOF
|
||||||
|
@ -821,18 +821,6 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "Using ARGV to check options" do
|
|
||||||
expect_no_offenses(<<~RUBY)
|
|
||||||
class Foo < Formula
|
|
||||||
desc "foo"
|
|
||||||
url 'https://brew.sh/foo-1.0.tgz'
|
|
||||||
def install
|
|
||||||
verbose = Homebrew.args.verbose?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
RUBY
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'man+"man8" usage' do
|
it 'man+"man8" usage' do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
|
@ -120,7 +120,7 @@ describe SystemCommand::Result do
|
|||||||
|
|
||||||
context "when verbose" do
|
context "when verbose" do
|
||||||
before do
|
before do
|
||||||
allow(Homebrew).to receive(:args).and_return(OpenStruct.new("verbose?" => true))
|
allow(Context).to receive(:current).and_return(Context::ContextStruct.new(verbose: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "warns about garbage" do
|
it "warns about garbage" do
|
||||||
@ -144,7 +144,7 @@ describe SystemCommand::Result do
|
|||||||
|
|
||||||
context "when verbose" do
|
context "when verbose" do
|
||||||
before do
|
before do
|
||||||
allow(Homebrew).to receive(:args).and_return(OpenStruct.new("verbose?" => true))
|
allow(Context).to receive(:current).and_return(Context::ContextStruct.new(verbose: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "warns about garbage" do
|
it "warns about garbage" do
|
||||||
|
@ -63,9 +63,8 @@ module Homebrew
|
|||||||
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?,
|
fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?,
|
||||||
include_test_formulae: args.include_test_formulae,
|
debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?)
|
||||||
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?
|
||||||
@ -102,7 +101,7 @@ module Homebrew
|
|||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e
|
ofail e
|
||||||
rescue BuildError => e
|
rescue BuildError => e
|
||||||
e.dump
|
e.dump(verbose: args.verbose?)
|
||||||
puts
|
puts
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
rescue DownloadError => e
|
rescue DownloadError => e
|
||||||
@ -225,7 +224,7 @@ module Homebrew
|
|||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e
|
ofail e
|
||||||
rescue BuildError => e
|
rescue BuildError => e
|
||||||
e.dump
|
e.dump(verbose: args.verbose?)
|
||||||
puts
|
puts
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
rescue DownloadError => e
|
rescue DownloadError => e
|
||||||
|
@ -16,6 +16,8 @@ require "tap_constants"
|
|||||||
require "time"
|
require "time"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
extend Context
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def _system(cmd, *args, **options)
|
def _system(cmd, *args, **options)
|
||||||
@ -34,7 +36,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def system(cmd, *args, **options)
|
def system(cmd, *args, **options)
|
||||||
if Homebrew.args.verbose?
|
if verbose?
|
||||||
puts "#{cmd} #{args * " "}".gsub(RUBY_PATH, "ruby")
|
puts "#{cmd} #{args * " "}".gsub(RUBY_PATH, "ruby")
|
||||||
.gsub($LOAD_PATH.join(File::PATH_SEPARATOR).to_s, "$LOAD_PATH")
|
.gsub($LOAD_PATH.join(File::PATH_SEPARATOR).to_s, "$LOAD_PATH")
|
||||||
end
|
end
|
||||||
@ -86,7 +88,13 @@ module Kernel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ohai_title(title)
|
def ohai_title(title)
|
||||||
title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose?
|
verbose = if respond_to?(:verbose?)
|
||||||
|
verbose?
|
||||||
|
else
|
||||||
|
Context.current.verbose?
|
||||||
|
end
|
||||||
|
|
||||||
|
title = Tty.truncate(title) if $stdout.tty? && !verbose
|
||||||
Formatter.headline(title, color: :blue)
|
Formatter.headline(title, color: :blue)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,15 +103,27 @@ module Kernel
|
|||||||
puts sput
|
puts sput
|
||||||
end
|
end
|
||||||
|
|
||||||
def odebug(title, *sput)
|
def odebug(title, *sput, always_display: false)
|
||||||
return unless Homebrew.args.debug?
|
debug = if respond_to?(:debug)
|
||||||
|
debug?
|
||||||
|
else
|
||||||
|
Context.current.debug?
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless debug || always_display
|
||||||
|
|
||||||
puts Formatter.headline(title, color: :magenta)
|
puts Formatter.headline(title, color: :magenta)
|
||||||
puts sput unless sput.empty?
|
puts sput unless sput.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def oh1(title, options = {})
|
def oh1(title, truncate: :auto)
|
||||||
title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose? && options.fetch(:truncate, :auto) == :auto
|
verbose = if respond_to?(:verbose?)
|
||||||
|
verbose?
|
||||||
|
else
|
||||||
|
Context.current.verbose?
|
||||||
|
end
|
||||||
|
|
||||||
|
title = Tty.truncate(title) if $stdout.tty? && !verbose && truncate == :auto
|
||||||
puts Formatter.headline(title, color: :green)
|
puts Formatter.headline(title, color: :green)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -369,12 +389,12 @@ module Kernel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nostdout
|
def nostdout
|
||||||
if Homebrew.args.verbose?
|
if verbose?
|
||||||
yield
|
yield
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
out = $stdout.dup
|
out = $stdout.dup
|
||||||
$stdout.reopen("/dev/null")
|
$stdout.reopen(File::NULL)
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
$stdout.reopen(out)
|
$stdout.reopen(out)
|
||||||
|
@ -5,6 +5,8 @@ require "erb"
|
|||||||
module Utils
|
module Utils
|
||||||
module Analytics
|
module Analytics
|
||||||
class << self
|
class << self
|
||||||
|
include Context
|
||||||
|
|
||||||
def report(type, metadata = {})
|
def report(type, metadata = {})
|
||||||
return if not_this_run?
|
return if not_this_run?
|
||||||
return if disabled?
|
return if disabled?
|
||||||
@ -148,7 +150,7 @@ module Utils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_analytics(json, args:)
|
def get_analytics(json, args:)
|
||||||
full_analytics = args.analytics? || Homebrew.args.verbose?
|
full_analytics = args.analytics? || verbose?
|
||||||
|
|
||||||
ohai "Analytics"
|
ohai "Analytics"
|
||||||
json["analytics"].each do |category, value|
|
json["analytics"].each do |category, value|
|
||||||
|
@ -34,7 +34,7 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
|
|||||||
|
|
||||||
unless show_output
|
unless show_output
|
||||||
args << "--fail"
|
args << "--fail"
|
||||||
args << "--progress-bar" unless Homebrew.args.verbose?
|
args << "--progress-bar" unless Context.current.verbose?
|
||||||
args << "--verbose" if Homebrew::EnvConfig.curl_verbose?
|
args << "--verbose" if Homebrew::EnvConfig.curl_verbose?
|
||||||
args << "--silent" unless $stdout.tty?
|
args << "--silent" unless $stdout.tty?
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user