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/linker64",
|
||||||
"/system/bin/linker",
|
"/system/bin/linker",
|
||||||
].freeze
|
].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
|
def check_cpu
|
||||||
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
||||||
@ -28,6 +34,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
abort message
|
abort message
|
||||||
end
|
end
|
||||||
|
private_class_method :check_cpu
|
||||||
|
|
||||||
def symlink_ld_so
|
def symlink_ld_so
|
||||||
brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so"
|
brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so"
|
||||||
@ -42,10 +49,6 @@ module Homebrew
|
|||||||
FileUtils.mkdir_p HOMEBREW_PREFIX/"lib"
|
FileUtils.mkdir_p HOMEBREW_PREFIX/"lib"
|
||||||
FileUtils.ln_sf ld_so, brew_ld_so
|
FileUtils.ln_sf ld_so, brew_ld_so
|
||||||
end
|
end
|
||||||
|
private_class_method :symlink_ld_so
|
||||||
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
|
||||||
generic_perform_preinstall_checks(all_fatal: all_fatal, cc: cc)
|
|
||||||
symlink_ld_so
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require "cmd/install"
|
|||||||
require "find"
|
require "find"
|
||||||
|
|
||||||
class FormulaInstaller
|
class FormulaInstaller
|
||||||
include Homebrew::Install
|
|
||||||
include FormulaCellarChecks
|
include FormulaCellarChecks
|
||||||
extend Predicable
|
extend Predicable
|
||||||
|
|
||||||
@ -261,7 +260,9 @@ class FormulaInstaller
|
|||||||
lock
|
lock
|
||||||
|
|
||||||
start_time = Time.now
|
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
|
# 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
|
# function but after instantiating this class so that it can avoid having to
|
||||||
|
|||||||
@ -6,9 +6,27 @@ require "hardware"
|
|||||||
require "development_tools"
|
require "development_tools"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
# Helper module for performing (pre-)install checks.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
module Install
|
module Install
|
||||||
module_function
|
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
|
def check_cpu
|
||||||
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
||||||
|
|
||||||
@ -24,6 +42,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
abort message
|
abort message
|
||||||
end
|
end
|
||||||
|
private_class_method :check_cpu
|
||||||
|
|
||||||
def attempt_directory_creation
|
def attempt_directory_creation
|
||||||
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
||||||
@ -38,6 +57,7 @@ module Homebrew
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
private_class_method :attempt_directory_creation
|
||||||
|
|
||||||
def check_cc_argv(cc)
|
def check_cc_argv(cc)
|
||||||
return unless cc
|
return unless cc
|
||||||
@ -48,21 +68,7 @@ module Homebrew
|
|||||||
#{@checks.please_create_pull_requests}
|
#{@checks.please_create_pull_requests}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
private_class_method :check_cc_argv
|
||||||
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 diagnostic_checks(type, fatal: true)
|
def diagnostic_checks(type, fatal: true)
|
||||||
@checks ||= Diagnostic::Checks.new
|
@checks ||= Diagnostic::Checks.new
|
||||||
@ -80,6 +86,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
exit 1 if failed && fatal
|
exit 1 if failed && fatal
|
||||||
end
|
end
|
||||||
|
private_class_method :diagnostic_checks
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user