Make debug an installer mode

This commit is contained in:
Jack Nagel 2014-03-13 10:11:00 -05:00
parent 4d02849d43
commit ce5e2aa65c
5 changed files with 12 additions and 9 deletions

View File

@ -114,6 +114,7 @@ module Homebrew extend self
fi.interactive &&= :git if ARGV.flag? "--git" fi.interactive &&= :git if ARGV.flag? "--git"
fi.verbose = ARGV.verbose? fi.verbose = ARGV.verbose?
fi.verbose &&= :quieter if ARGV.quieter? fi.verbose &&= :quieter if ARGV.quieter?
fi.debug = ARGV.debug?
fi.prelude fi.prelude
fi.install fi.install
fi.caveats fi.caveats

View File

@ -61,6 +61,7 @@ module Homebrew extend self
installer.build_from_source = ARGV.build_from_source? installer.build_from_source = ARGV.build_from_source?
installer.verbose = ARGV.verbose? installer.verbose = ARGV.verbose?
installer.verbose &&= :quieter if ARGV.quieter? installer.verbose &&= :quieter if ARGV.quieter?
installer.debug = ARGV.debug?
installer.prelude installer.prelude
oh1 "Upgrading #{f.name}" oh1 "Upgrading #{f.name}"

View File

@ -183,7 +183,6 @@ module HomebrewArgvExtension
old_args = clone old_args = clone
flags_to_clear = %w[ flags_to_clear = %w[
--debug -d
--devel --devel
--HEAD --HEAD
] ]

View File

@ -25,7 +25,7 @@ class FormulaInstaller
mode_attr_accessor :show_summary_heading, :show_header mode_attr_accessor :show_summary_heading, :show_header
mode_attr_accessor :build_from_source, :build_bottle, :force_bottle mode_attr_accessor :build_from_source, :build_bottle, :force_bottle
mode_attr_accessor :ignore_deps, :only_deps, :interactive mode_attr_accessor :ignore_deps, :only_deps, :interactive
mode_attr_accessor :verbose mode_attr_accessor :verbose, :debug
def initialize ff def initialize ff
@f = ff @f = ff
@ -37,6 +37,7 @@ class FormulaInstaller
@force_bottle = false @force_bottle = false
@interactive = false @interactive = false
@verbose = false @verbose = false
@debug = false
@options = Options.new @options = Options.new
@@attempted ||= Set.new @@attempted ||= Set.new
@ -199,7 +200,7 @@ class FormulaInstaller
# HACK: If readline is present in the dependency tree, it will clash # HACK: If readline is present in the dependency tree, it will clash
# with the stdlib's Readline module when the debugger is loaded # with the stdlib's Readline module when the debugger is loaded
def perform_readline_hack def perform_readline_hack
if f.recursive_dependencies.any? { |d| d.name == "readline" } && ARGV.debug? if f.recursive_dependencies.any? { |d| d.name == "readline" } && debug?
ENV['HOMEBREW_NO_READLINE'] = '1' ENV['HOMEBREW_NO_READLINE'] = '1'
end end
end end
@ -346,6 +347,7 @@ class FormulaInstaller
fi.ignore_deps = true fi.ignore_deps = true
fi.build_from_source = build_from_source? fi.build_from_source = build_from_source?
fi.verbose = verbose? unless verbose == :quieter fi.verbose = verbose? unless verbose == :quieter
fi.debug = debug?
fi.prelude fi.prelude
oh1 "Installing #{f} dependency: #{Tty.green}#{dep.name}#{Tty.reset}" oh1 "Installing #{f} dependency: #{Tty.green}#{dep.name}#{Tty.reset}"
outdated_keg.unlink if outdated_keg outdated_keg.unlink if outdated_keg
@ -435,7 +437,7 @@ class FormulaInstaller
end end
args << "--verbose" if verbose? args << "--verbose" if verbose?
args << "--debug" if ARGV.debug? args << "--debug" if debug?
args << "--cc=#{ARGV.cc}" if ARGV.cc args << "--cc=#{ARGV.cc}" if ARGV.cc
args << "--env=#{ARGV.env}" if ARGV.env args << "--env=#{ARGV.env}" if ARGV.env
args << "--HEAD" if ARGV.build_head? args << "--HEAD" if ARGV.build_head?
@ -528,7 +530,7 @@ class FormulaInstaller
puts "Possible conflicting files are:" puts "Possible conflicting files are:"
mode = OpenStruct.new(:dry_run => true, :overwrite => true) mode = OpenStruct.new(:dry_run => true, :overwrite => true)
keg.link(mode) keg.link(mode)
ohai e, e.backtrace if ARGV.debug? ohai e, e.backtrace if debug?
@show_summary_heading = true @show_summary_heading = true
ignore_interrupts{ keg.unlink } ignore_interrupts{ keg.unlink }
raise unless e.kind_of? RuntimeError raise unless e.kind_of? RuntimeError
@ -555,7 +557,7 @@ class FormulaInstaller
onoe "Failed to fix install names" onoe "Failed to fix install names"
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 "formula against it." puts "formula against it."
ohai e, e.backtrace if ARGV.debug? ohai e, e.backtrace if debug?
@show_summary_heading = true @show_summary_heading = true
end end
@ -565,7 +567,7 @@ class FormulaInstaller
rescue Exception => e rescue Exception => e
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 ARGV.debug? ohai e, e.backtrace if debug?
@show_summary_heading = true @show_summary_heading = true
end end
@ -574,7 +576,7 @@ class FormulaInstaller
rescue Exception => e rescue Exception => e
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 #{f.name}`" puts "You can try again using `brew postinstall #{f.name}`"
ohai e, e.backtrace if ARGV.debug? ohai e, e.backtrace if debug?
@show_summary_heading = true @show_summary_heading = true
end end

View File

@ -49,7 +49,7 @@ class ArgvExtensionTests < Test::Unit::TestCase
end end
def test_filter_for_dependencies_clears_flags def test_filter_for_dependencies_clears_flags
@argv << "--debug" @argv << "--HEAD" << "--devel"
@argv.filter_for_dependencies { assert @argv.empty? } @argv.filter_for_dependencies { assert @argv.empty? }
end end