Output more warnings on unsupported configurations

This commit is contained in:
Mike McQuaid 2019-01-21 12:39:44 +00:00
parent 8258ecc3ca
commit 3a0e0dca36
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
5 changed files with 55 additions and 24 deletions

View File

@ -79,6 +79,10 @@ module Homebrew
].freeze ].freeze
end end
def supported_configuration_checks
[].freeze
end
def development_tools_checks def development_tools_checks
%w[ %w[
check_for_installed_developer_tools check_for_installed_developer_tools
@ -97,11 +101,10 @@ module Homebrew
def please_create_pull_requests(what = "unsupported configuration") def please_create_pull_requests(what = "unsupported configuration")
<<~EOS <<~EOS
You may encounter build failures and other breakages. You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Please create pull requests instead of asking for help on Homebrew's GitHub,
Homebrew's GitHub, Discourse, Twitter or IRC. You are Discourse, Twitter or IRC. You are responsible for resolving any issues you
responsible for resolving any issues you experience, as experience, as you are running this #{what}.
you are running this #{what}.
EOS EOS
end end
@ -118,10 +121,8 @@ module Homebrew
return unless ENV["HOMEBREW_BUILD_FROM_SOURCE"] return unless ENV["HOMEBREW_BUILD_FROM_SOURCE"]
<<~EOS <<~EOS
You have HOMEBREW_BUILD_FROM_SOURCE set. This environment variable is You have HOMEBREW_BUILD_FROM_SOURCE set.
intended for use by Homebrew developers. If you are encountering errors, #{please_create_pull_requests}
please try unsetting this. Please do not file issues if you encounter
errors when using this environment variable.
EOS EOS
end end
@ -806,9 +807,9 @@ module Homebrew
<<~EOS <<~EOS
Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}. Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}.
You can install Homebrew anywhere you want but some bottles (binary packages) Some of Homebrew's bottles (binary packages) can only be used with the default
can only be used with a standard prefix and some formulae (packages) prefix (#{Homebrew::DEFAULT_PREFIX}).
may not build correctly with a non-standard prefix. #{please_create_pull_requests}
EOS EOS
end end

View File

@ -7,6 +7,13 @@ require "os/linux/kernel"
module Homebrew module Homebrew
module Diagnostic module Diagnostic
class Checks class Checks
def supported_configuration_checks
%w[
check_glibc_minimum_version
check_kernel_minimum_version
].freeze
end
def check_tmpdir_sticky_bit def check_tmpdir_sticky_bit
message = generic_check_tmpdir_sticky_bit message = generic_check_tmpdir_sticky_bit
return if message.nil? return if message.nil?

View File

@ -26,8 +26,8 @@ module Homebrew
FileUtils.ln_sf ld_so, brew_ld_so FileUtils.ln_sf ld_so, brew_ld_so
end end
def perform_preinstall_checks def perform_preinstall_checks(all_fatal: false)
generic_perform_preinstall_checks generic_perform_preinstall_checks(all_fatal: all_fatal)
symlink_ld_so symlink_ld_so
end end
end end

View File

@ -1,12 +1,19 @@
module Homebrew module Homebrew
module Diagnostic module Diagnostic
class Checks class Checks
undef development_tools_checks, fatal_development_tools_checks, undef supported_configuration_checks, development_tools_checks,
build_error_checks fatal_development_tools_checks, build_error_checks
def supported_configuration_checks
%w[
check_build_from_source
check_homebrew_prefix
check_for_unsupported_macos
].freeze
end
def development_tools_checks def development_tools_checks
%w[ %w[
check_for_unsupported_macos
check_for_installed_developer_tools check_for_installed_developer_tools
check_xcode_license_approved check_xcode_license_approved
check_xcode_up_to_date check_xcode_up_to_date

View File

@ -17,6 +17,16 @@ 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
@ -28,28 +38,34 @@ module Homebrew
end end
def perform_development_tools_checks def perform_development_tools_checks
fatal_checks(:fatal_development_tools_checks) diagnostic_checks(:fatal_development_tools_checks)
end end
def perform_preinstall_checks def perform_preinstall_checks(all_fatal: false)
check_cpu check_cpu
attempt_directory_creation attempt_directory_creation
fatal_checks(:fatal_install_checks) check_cc_argv
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
diagnostic_checks(:fatal_install_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 fatal_checks(type) def diagnostic_checks(type, fatal: true)
@checks ||= Diagnostic::Checks.new @checks ||= Diagnostic::Checks.new
failed = false failed = false
@checks.public_send(type).each do |check| @checks.public_send(type).each do |check|
out = @checks.public_send(check) out = @checks.public_send(check)
next if out.nil? next if out.nil?
if fatal
failed ||= true failed ||= true
ofail out ofail out
else
opoo out
end end
exit 1 if failed end
exit 1 if failed && fatal
end end
end end
end end