Merge pull request #8377 from reitermarkus/document-install
Refactor and document `Install`.
This commit is contained in:
commit
c3874580a4
@ -14,6 +14,12 @@ module Homebrew
|
||||
"/system/bin/linker64",
|
||||
"/system/bin/linker",
|
||||
].freeze
|
||||
private_constant :DYNAMIC_LINKERS
|
||||
|
||||
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||
generic_perform_preinstall_checks(all_fatal: all_fatal, cc: cc)
|
||||
symlink_ld_so
|
||||
end
|
||||
|
||||
def check_cpu
|
||||
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
||||
@ -28,6 +34,7 @@ module Homebrew
|
||||
end
|
||||
abort message
|
||||
end
|
||||
private_class_method :check_cpu
|
||||
|
||||
def symlink_ld_so
|
||||
brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so"
|
||||
@ -42,10 +49,6 @@ module Homebrew
|
||||
FileUtils.mkdir_p HOMEBREW_PREFIX/"lib"
|
||||
FileUtils.ln_sf ld_so, brew_ld_so
|
||||
end
|
||||
|
||||
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||
generic_perform_preinstall_checks(all_fatal: all_fatal, cc: cc)
|
||||
symlink_ld_so
|
||||
end
|
||||
private_class_method :symlink_ld_so
|
||||
end
|
||||
end
|
||||
|
||||
@ -21,7 +21,6 @@ require "cmd/install"
|
||||
require "find"
|
||||
|
||||
class FormulaInstaller
|
||||
include Homebrew::Install
|
||||
include FormulaCellarChecks
|
||||
extend Predicable
|
||||
|
||||
@ -261,7 +260,9 @@ class FormulaInstaller
|
||||
lock
|
||||
|
||||
start_time = Time.now
|
||||
perform_build_from_source_checks if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
|
||||
if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
|
||||
Homebrew::Install.perform_build_from_source_checks
|
||||
end
|
||||
|
||||
# not in initialize so upgrade can unlink the active keg before calling this
|
||||
# function but after instantiating this class so that it can avoid having to
|
||||
|
||||
@ -6,9 +6,27 @@ require "hardware"
|
||||
require "development_tools"
|
||||
|
||||
module Homebrew
|
||||
# Helper module for performing (pre-)install checks.
|
||||
#
|
||||
# @api private
|
||||
module Install
|
||||
module_function
|
||||
|
||||
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||
check_cpu
|
||||
attempt_directory_creation
|
||||
check_cc_argv(cc)
|
||||
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
|
||||
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 check_cpu
|
||||
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
||||
|
||||
@ -24,6 +42,7 @@ module Homebrew
|
||||
end
|
||||
abort message
|
||||
end
|
||||
private_class_method :check_cpu
|
||||
|
||||
def attempt_directory_creation
|
||||
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
||||
@ -38,6 +57,7 @@ module Homebrew
|
||||
nil
|
||||
end
|
||||
end
|
||||
private_class_method :attempt_directory_creation
|
||||
|
||||
def check_cc_argv(cc)
|
||||
return unless cc
|
||||
@ -48,21 +68,7 @@ module Homebrew
|
||||
#{@checks.please_create_pull_requests}
|
||||
EOS
|
||||
end
|
||||
|
||||
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||
check_cpu
|
||||
attempt_directory_creation
|
||||
check_cc_argv(cc)
|
||||
diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
|
||||
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
|
||||
private_class_method :check_cc_argv
|
||||
|
||||
def diagnostic_checks(type, fatal: true)
|
||||
@checks ||= Diagnostic::Checks.new
|
||||
@ -80,6 +86,7 @@ module Homebrew
|
||||
end
|
||||
exit 1 if failed && fatal
|
||||
end
|
||||
private_class_method :diagnostic_checks
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user