Module: Homebrew::Install

Defined in:
brew/Library/Homebrew/install.rb,
brew/Library/Homebrew/extend/os/linux/install.rb

Constant Summary collapse

DYNAMIC_LINKERS =
[
  "/lib64/ld-linux-x86-64.so.2",
  "/lib/ld-linux.so.3",
  "/lib/ld-linux.so.2",
  "/lib/ld-linux-aarch64.so.1",
  "/lib/ld-linux-armhf.so.3",
  "/system/bin/linker64",
  "/system/bin/linker",
].freeze

Class Method Summary collapse

Class Method Details

.attempt_directory_creationObject



23
24
25
26
27
28
29
30
31
# File 'brew/Library/Homebrew/install.rb', line 23

def attempt_directory_creation
  Keg::MUST_EXIST_DIRECTORIES.each do |dir|
    begin
      FileUtils.mkdir_p(dir) unless dir.exist?
    rescue
      nil
    end
  end
end

.check_cc_argvObject



33
34
35
36
37
38
39
40
41
# File 'brew/Library/Homebrew/install.rb', line 33

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

.check_cpuObject



12
13
14
15
16
17
18
19
20
21
# File 'brew/Library/Homebrew/install.rb', line 12

def check_cpu
  case Hardware::CPU.type
  when :ppc
    abort <<~EOS
      Sorry, Homebrew does not support your computer's CPU architecture.
      For PPC support, see:
        #{Formatter.url("https://github.com/mistydemeo/tigerbrew")}
    EOS
  end
end

.diagnostic_checks(type, fatal: true) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'brew/Library/Homebrew/install.rb', line 58

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?

    if fatal
      failed ||= true
      ofail out
    else
      opoo out
    end
  end
  exit 1 if failed && fatal
end

.generic_perform_preinstall_checksObject



50
# File 'brew/Library/Homebrew/install.rb', line 50

alias generic_perform_preinstall_checks perform_preinstall_checks

.perform_build_from_source_checks(all_fatal: false) ⇒ Object



53
54
55
56
# File 'brew/Library/Homebrew/install.rb', line 53

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

.perform_preinstall_checks(all_fatal: false) ⇒ Object



43
44
45
46
47
48
49
# File 'brew/Library/Homebrew/install.rb', line 43

def perform_preinstall_checks(all_fatal: false)
  check_cpu
  attempt_directory_creation
  check_cc_argv
  diagnostic_checks(:supported_configuration_checks, fatal: all_fatal)
  diagnostic_checks(:fatal_preinstall_checks)
end


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'brew/Library/Homebrew/extend/os/linux/install.rb', line 17

def symlink_ld_so
  brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so"
  return if brew_ld_so.readable?

  ld_so = HOMEBREW_PREFIX/"opt/glibc/lib/ld-linux-x86-64.so.2"
  unless ld_so.readable?
    ld_so = DYNAMIC_LINKERS.find { |s| File.executable? s }
    raise "Unable to locate the system's dynamic linker" unless ld_so
  end

  FileUtils.mkdir_p HOMEBREW_PREFIX/"lib"
  FileUtils.ln_sf ld_so, brew_ld_so
end