Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak diagnostic checks #5575

Merged
merged 1 commit into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/gist-logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def gist_logs
raise FormulaUnspecifiedError if ARGV.resolved_formulae.length != 1

Install.perform_preinstall_checks(all_fatal: true)
Install.perform_build_from_source_checks(all_fatal: true)
gistify_logs(ARGV.resolved_formulae.first)
end
end
20 changes: 9 additions & 11 deletions Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,28 @@ def inject_file_list(list, string)
end
############# END HELPERS

def fatal_install_checks
def fatal_preinstall_checks
%w[
check_access_directories
].freeze
end

def supported_configuration_checks
[].freeze
end

def development_tools_checks
def fatal_build_from_source_checks
%w[
check_for_installed_developer_tools
].freeze
end

def fatal_development_tools_checks
%w[
].freeze
def supported_configuration_checks
[].freeze
end

def build_from_source_checks
[].freeze
end

def build_error_checks
(development_tools_checks + %w[
]).freeze
supported_configuration_checks + build_from_source_checks
end

def please_create_pull_requests(what = "unsupported configuration")
Expand Down
33 changes: 13 additions & 20 deletions Library/Homebrew/extend/os/mac/diagnostic.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
module Homebrew
module Diagnostic
class Checks
undef supported_configuration_checks, development_tools_checks,
fatal_development_tools_checks, build_error_checks
undef fatal_build_from_source_checks, supported_configuration_checks,
build_from_source_checks

def fatal_build_from_source_checks
%w[
check_xcode_license_approved
check_xcode_minimum_version
check_clt_minimum_version
check_if_xcode_needs_clt_installed
].freeze
end

def supported_configuration_checks
%w[
check_build_from_source
check_homebrew_prefix
check_for_unsupported_macos
].freeze
end

def development_tools_checks
def build_from_source_checks
%w[
check_for_installed_developer_tools
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_clt_minimum_version
check_if_xcode_needs_clt_installed
].freeze
end

def build_error_checks
(development_tools_checks + %w[
check_for_unsupported_macos
]).freeze
end

def check_for_non_prefixed_findutils
findutils = Formula["findutils"]
return unless findutils.any_version_installed?
Expand Down Expand Up @@ -198,7 +191,7 @@ def check_xcode_license_approved

<<~EOS
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
EOS
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def build_bottle_postinstall
def install
start_time = Time.now
if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
Homebrew::Install.perform_development_tools_checks
Homebrew::Install.perform_build_from_source_checks
end

# not in initialize so upgrade can unlink the active keg before calling this
Expand Down
27 changes: 14 additions & 13 deletions Library/Homebrew/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ def check_cpu
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
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
begin
Expand All @@ -37,20 +27,31 @@ def attempt_directory_creation
end
end

def perform_development_tools_checks
diagnostic_checks(:fatal_development_tools_checks)
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 perform_preinstall_checks(all_fatal: false)
check_cpu
attempt_directory_creation
check_cc_argv
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
diagnostic_checks(:fatal_install_checks)
diagnostic_checks(:fatal_preinstall_checks)
end
alias generic_perform_preinstall_checks 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)
@checks ||= Diagnostic::Checks.new
failed = false
Expand Down