From 3a0e0dca36aad66f61a082812c0b7b41e0737ffc Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 12:39:44 +0000 Subject: [PATCH] Output more warnings on unsupported configurations --- Library/Homebrew/diagnostic.rb | 25 ++++++++-------- .../Homebrew/extend/os/linux/diagnostic.rb | 7 +++++ Library/Homebrew/extend/os/linux/install.rb | 4 +-- Library/Homebrew/extend/os/mac/diagnostic.rb | 13 ++++++-- Library/Homebrew/install.rb | 30 ++++++++++++++----- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index c42bf31623..6d4db3f638 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -79,6 +79,10 @@ module Homebrew ].freeze end + def supported_configuration_checks + [].freeze + end + def development_tools_checks %w[ check_for_installed_developer_tools @@ -97,11 +101,10 @@ module Homebrew def please_create_pull_requests(what = "unsupported configuration") <<~EOS - You may encounter build failures and other breakages. - Please create pull requests instead of asking for help on - Homebrew's GitHub, Discourse, Twitter or IRC. You are - responsible for resolving any issues you experience, as - you are running this #{what}. + You will encounter build failures with some formulae. + Please create pull requests instead of asking for help on Homebrew's GitHub, + Discourse, Twitter or IRC. You are responsible for resolving any issues you + experience, as you are running this #{what}. EOS end @@ -118,10 +121,8 @@ module Homebrew return unless ENV["HOMEBREW_BUILD_FROM_SOURCE"] <<~EOS - You have HOMEBREW_BUILD_FROM_SOURCE set. This environment variable is - intended for use by Homebrew developers. If you are encountering errors, - please try unsetting this. Please do not file issues if you encounter - errors when using this environment variable. + You have HOMEBREW_BUILD_FROM_SOURCE set. + #{please_create_pull_requests} EOS end @@ -806,9 +807,9 @@ module Homebrew <<~EOS Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}. - You can install Homebrew anywhere you want but some bottles (binary packages) - can only be used with a standard prefix and some formulae (packages) - may not build correctly with a non-standard prefix. + Some of Homebrew's bottles (binary packages) can only be used with the default + prefix (#{Homebrew::DEFAULT_PREFIX}). + #{please_create_pull_requests} EOS end diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index 1a89f9d956..061fe64bfb 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -7,6 +7,13 @@ require "os/linux/kernel" module Homebrew module Diagnostic class Checks + def supported_configuration_checks + %w[ + check_glibc_minimum_version + check_kernel_minimum_version + ].freeze + end + def check_tmpdir_sticky_bit message = generic_check_tmpdir_sticky_bit return if message.nil? diff --git a/Library/Homebrew/extend/os/linux/install.rb b/Library/Homebrew/extend/os/linux/install.rb index 91f043ac25..84b96ac060 100644 --- a/Library/Homebrew/extend/os/linux/install.rb +++ b/Library/Homebrew/extend/os/linux/install.rb @@ -26,8 +26,8 @@ module Homebrew FileUtils.ln_sf ld_so, brew_ld_so end - def perform_preinstall_checks - generic_perform_preinstall_checks + def perform_preinstall_checks(all_fatal: false) + generic_perform_preinstall_checks(all_fatal: all_fatal) symlink_ld_so end end diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index d433127500..6bbd51e551 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -1,12 +1,19 @@ module Homebrew module Diagnostic class Checks - undef development_tools_checks, fatal_development_tools_checks, - build_error_checks + undef supported_configuration_checks, development_tools_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 %w[ - check_for_unsupported_macos check_for_installed_developer_tools check_xcode_license_approved check_xcode_up_to_date diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 7b7fb88042..e5bd6e8459 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -17,6 +17,16 @@ module Homebrew 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 @@ -28,28 +38,34 @@ module Homebrew end def perform_development_tools_checks - fatal_checks(:fatal_development_tools_checks) + diagnostic_checks(:fatal_development_tools_checks) end - def perform_preinstall_checks + def perform_preinstall_checks(all_fatal: false) check_cpu 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 alias generic_perform_preinstall_checks perform_preinstall_checks module_function :generic_perform_preinstall_checks - def fatal_checks(type) + def diagnostic_checks(type, fatal: true) @checks ||= Diagnostic::Checks.new failed = false @checks.public_send(type).each do |check| out = @checks.public_send(check) next if out.nil? - failed ||= true - ofail out + if fatal + failed ||= true + ofail out + else + opoo out + end end - exit 1 if failed + exit 1 if failed && fatal end end end