2018-06-05 23:19:18 -04:00
|
|
|
require "diagnostic"
|
|
|
|
require "fileutils"
|
|
|
|
require "hardware"
|
|
|
|
require "development_tools"
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module Install
|
|
|
|
module_function
|
|
|
|
|
2019-01-08 19:13:46 +00:00
|
|
|
def check_cpu
|
2018-06-05 23:19:18 -04:00
|
|
|
case Hardware::CPU.type
|
|
|
|
when :ppc
|
|
|
|
abort <<~EOS
|
|
|
|
Sorry, Homebrew does not support your computer's CPU architecture.
|
2019-04-01 16:02:13 -04:00
|
|
|
For PPC support, see:
|
|
|
|
#{Formatter.url("https://github.com/mistydemeo/tigerbrew")}
|
2018-06-05 23:19:18 -04:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-06 18:38:43 +01:00
|
|
|
def attempt_directory_creation
|
2018-09-25 22:03:29 +01:00
|
|
|
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
2018-09-06 18:38:43 +01:00
|
|
|
begin
|
|
|
|
FileUtils.mkdir_p(dir) unless dir.exist?
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2018-06-05 23:19:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-21 19:23:31 +00:00
|
|
|
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
|
2018-09-06 18:38:43 +01:00
|
|
|
end
|
|
|
|
|
2019-01-21 12:39:44 +00:00
|
|
|
def perform_preinstall_checks(all_fatal: false)
|
2019-01-08 19:13:46 +00:00
|
|
|
check_cpu
|
2018-09-06 18:38:43 +01:00
|
|
|
attempt_directory_creation
|
2019-01-21 12:39:44 +00:00
|
|
|
check_cc_argv
|
|
|
|
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
|
2019-01-21 19:23:31 +00:00
|
|
|
diagnostic_checks(:fatal_preinstall_checks)
|
2018-09-06 18:38:43 +01:00
|
|
|
end
|
2018-09-28 14:01:09 -07:00
|
|
|
alias generic_perform_preinstall_checks perform_preinstall_checks
|
|
|
|
module_function :generic_perform_preinstall_checks
|
2018-09-06 18:38:43 +01:00
|
|
|
|
2019-01-21 19:23:31 +00:00
|
|
|
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
|
|
|
|
|
2019-01-21 12:39:44 +00:00
|
|
|
def diagnostic_checks(type, fatal: true)
|
2018-09-06 18:38:43 +01:00
|
|
|
@checks ||= Diagnostic::Checks.new
|
2018-07-02 10:25:04 +01:00
|
|
|
failed = false
|
2018-09-06 18:38:43 +01:00
|
|
|
@checks.public_send(type).each do |check|
|
|
|
|
out = @checks.public_send(check)
|
2018-06-05 23:19:18 -04:00
|
|
|
next if out.nil?
|
2018-09-17 02:45:00 +02:00
|
|
|
|
2019-01-21 12:39:44 +00:00
|
|
|
if fatal
|
|
|
|
failed ||= true
|
|
|
|
ofail out
|
|
|
|
else
|
|
|
|
opoo out
|
|
|
|
end
|
2018-06-05 23:19:18 -04:00
|
|
|
end
|
2019-01-21 12:39:44 +00:00
|
|
|
exit 1 if failed && fatal
|
2018-06-05 23:19:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-09-28 14:01:09 -07:00
|
|
|
|
|
|
|
require "extend/os/install"
|