Tweak diagnostic checks

- Make `gist-logs` perform more checks
- Don't complain about a non-/usr/local install at install time unless
  actually building from source.
- Show more checks output on a build error
- Improve naming of checks methods
This commit is contained in:
Mike McQuaid 2019-01-21 19:23:31 +00:00
parent b93dc7e84b
commit 589ed8e17c
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
5 changed files with 42 additions and 49 deletions

View File

@ -135,6 +135,7 @@ module Homebrew
raise FormulaUnspecifiedError if ARGV.resolved_formulae.length != 1 raise FormulaUnspecifiedError if ARGV.resolved_formulae.length != 1
Install.perform_preinstall_checks(all_fatal: true) Install.perform_preinstall_checks(all_fatal: true)
Install.perform_build_from_source_checks(all_fatal: true)
gistify_logs(ARGV.resolved_formulae.first) gistify_logs(ARGV.resolved_formulae.first)
end end
end end

View File

@ -73,30 +73,28 @@ module Homebrew
end end
############# END HELPERS ############# END HELPERS
def fatal_install_checks def fatal_preinstall_checks
%w[ %w[
check_access_directories check_access_directories
].freeze ].freeze
end end
def fatal_build_from_source_checks
%w[
check_for_installed_developer_tools
].freeze
end
def supported_configuration_checks def supported_configuration_checks
[].freeze [].freeze
end end
def development_tools_checks def build_from_source_checks
%w[ [].freeze
check_for_installed_developer_tools
].freeze
end
def fatal_development_tools_checks
%w[
].freeze
end end
def build_error_checks def build_error_checks
(development_tools_checks + %w[ supported_configuration_checks + build_from_source_checks
]).freeze
end end
def please_create_pull_requests(what = "unsupported configuration") def please_create_pull_requests(what = "unsupported configuration")

View File

@ -1,38 +1,31 @@
module Homebrew module Homebrew
module Diagnostic module Diagnostic
class Checks class Checks
undef supported_configuration_checks, development_tools_checks, undef fatal_build_from_source_checks, supported_configuration_checks,
fatal_development_tools_checks, build_error_checks build_from_source_checks
def supported_configuration_checks def fatal_build_from_source_checks
%w[ %w[
check_build_from_source
check_homebrew_prefix
check_for_unsupported_macos
].freeze
end
def development_tools_checks
%w[
check_for_installed_developer_tools
check_xcode_license_approved check_xcode_license_approved
check_xcode_up_to_date
check_clt_up_to_date
].freeze
end
def fatal_development_tools_checks
%w[
check_xcode_minimum_version check_xcode_minimum_version
check_clt_minimum_version check_clt_minimum_version
check_if_xcode_needs_clt_installed check_if_xcode_needs_clt_installed
].freeze ].freeze
end end
def build_error_checks def supported_configuration_checks
(development_tools_checks + %w[ %w[
check_build_from_source
check_for_unsupported_macos check_for_unsupported_macos
]).freeze ].freeze
end
def build_from_source_checks
%w[
check_for_installed_developer_tools
check_xcode_up_to_date
check_clt_up_to_date
].freeze
end end
def check_for_non_prefixed_findutils def check_for_non_prefixed_findutils
@ -198,7 +191,7 @@ module Homebrew
<<~EOS <<~EOS
You have not agreed to the Xcode license. You have not agreed to the Xcode license.
Builds will fail! Agree to the license by opening Xcode.app or running: Agree to the license by opening Xcode.app or running:
sudo xcodebuild -license sudo xcodebuild -license
EOS EOS
end end

View File

@ -209,7 +209,7 @@ class FormulaInstaller
def install def install
start_time = Time.now start_time = Time.now
if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed? if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
Homebrew::Install.perform_development_tools_checks Homebrew::Install.perform_build_from_source_checks
end 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

View File

@ -17,16 +17,6 @@ module Homebrew
end end
end end
def check_cc_argv
return unless ARGV.cc
@checks ||= Diagnostic::Checks.new
opoo <<~EOS
You passed `--cc=#{ARGV.cc}`.
#{@checks.please_create_pull_requests}
EOS
end
def attempt_directory_creation def attempt_directory_creation
Keg::MUST_EXIST_DIRECTORIES.each do |dir| Keg::MUST_EXIST_DIRECTORIES.each do |dir|
begin begin
@ -37,8 +27,14 @@ module Homebrew
end end
end end
def perform_development_tools_checks def check_cc_argv
diagnostic_checks(:fatal_development_tools_checks) return unless ARGV.cc
@checks ||= Diagnostic::Checks.new
opoo <<~EOS
You passed `--cc=#{ARGV.cc}`.
#{@checks.please_create_pull_requests}
EOS
end end
def perform_preinstall_checks(all_fatal: false) def perform_preinstall_checks(all_fatal: false)
@ -46,11 +42,16 @@ module Homebrew
attempt_directory_creation attempt_directory_creation
check_cc_argv check_cc_argv
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal) diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
diagnostic_checks(:fatal_install_checks) diagnostic_checks(:fatal_preinstall_checks)
end end
alias generic_perform_preinstall_checks perform_preinstall_checks alias generic_perform_preinstall_checks perform_preinstall_checks
module_function :generic_perform_preinstall_checks module_function :generic_perform_preinstall_checks
def perform_build_from_source_checks(all_fatal: false)
diagnostic_checks(:fatal_build_from_source_checks)
diagnostic_checks(:build_from_source_checks, fatal: all_fatal)
end
def diagnostic_checks(type, fatal: true) def diagnostic_checks(type, fatal: true)
@checks ||= Diagnostic::Checks.new @checks ||= Diagnostic::Checks.new
failed = false failed = false