Module: OS::Linux::Install::ClassMethods Private
- Defined in:
- extend/os/linux/install.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Constant Summary collapse
- DYNAMIC_LINKERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
This is a list of known paths to the host dynamic linker on Linux if the host glibc is new enough. The symlink_ld_so method will fail if the host linker cannot be found in this list.
%w[ /lib64/ld-linux-x86-64.so.2 /lib64/ld64.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
- GCC_RUNTIME_LIBS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
We link GCC runtime libraries that are not specifically used for Fortran, which are linked by the GCC formula. We only use the versioned shared libraries as the other shared and static libraries are only used at build time where GCC can find its own libraries.
%w[ libatomic.so.1 libgcc_s.so.1 libgomp.so.1 libstdc++.so.6 ].freeze
Instance Method Summary collapse
- #check_cpu ⇒ Object private
- #global_post_install ⇒ Object private
- #perform_preinstall_checks(all_fatal: false) ⇒ Object private
- #setup_preferred_gcc_libs ⇒ Object private
- #symlink_ld_so ⇒ Object private
Instance Method Details
#check_cpu ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'extend/os/linux/install.rb', line 45 def check_cpu return if ::Hardware::CPU.intel? && ::Hardware::CPU.is_64_bit? return if ::Hardware::CPU.arm? = "Sorry, Homebrew does not support your computer's CPU architecture!" if ::Hardware::CPU.ppc64le? += <<~EOS For OpenPOWER Linux (PPC64LE) support, see: #{Formatter.url("https://github.com/homebrew-ppc64le/brew")} EOS end ::Kernel.abort end |
#global_post_install ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
39 40 41 42 43 |
# File 'extend/os/linux/install.rb', line 39 def global_post_install super symlink_ld_so setup_preferred_gcc_libs end |
#perform_preinstall_checks(all_fatal: false) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
33 34 35 36 37 |
# File 'extend/os/linux/install.rb', line 33 def perform_preinstall_checks(all_fatal: false) super symlink_ld_so setup_preferred_gcc_libs end |
#setup_preferred_gcc_libs ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'extend/os/linux/install.rb', line 78 def setup_preferred_gcc_libs gcc_opt_prefix = HOMEBREW_PREFIX/"opt/#{OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA}" glibc_installed = (HOMEBREW_PREFIX/"opt/glibc/bin/ld.so").readable? return unless gcc_opt_prefix.readable? if glibc_installed ld_so_conf_d = HOMEBREW_PREFIX/"etc/ld.so.conf.d" unless ld_so_conf_d.exist? ld_so_conf_d.mkpath FileUtils.chmod "go-w", ld_so_conf_d end # Add gcc to ld search paths ld_gcc_conf = ld_so_conf_d/"50-homebrew-preferred-gcc.conf" ld_gcc_conf_content = <<~EOS # This file is generated by Homebrew. Do not modify. #{gcc_opt_prefix}/lib/gcc/current EOS if !ld_gcc_conf.exist? || (ld_gcc_conf.read != ld_gcc_conf_content) ld_gcc_conf.atomic_write ld_gcc_conf_content FileUtils.chmod "u=rw,go-wx", ld_gcc_conf FileUtils.rm_f HOMEBREW_PREFIX/"etc/ld.so.cache" ::Kernel.system HOMEBREW_PREFIX/"opt/glibc/sbin/ldconfig" end else ::Kernel.odie "#{HOMEBREW_PREFIX}/lib does not exist!" unless (HOMEBREW_PREFIX/"lib").readable? end GCC_RUNTIME_LIBS.each do |library| gcc_library_symlink = HOMEBREW_PREFIX/"lib/#{library}" if glibc_installed # Remove legacy symlinks FileUtils.rm gcc_library_symlink if gcc_library_symlink.symlink? else gcc_library = gcc_opt_prefix/"lib/gcc/current/#{library}" # Skip if the link target doesn't exist. next unless gcc_library.readable? # Also skip if the symlink already exists. next if gcc_library_symlink.readable? && (gcc_library_symlink.readlink == gcc_library) FileUtils.ln_sf gcc_library, gcc_library_symlink end end end |
#symlink_ld_so ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'extend/os/linux/install.rb', line 59 def symlink_ld_so brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so" ld_so = HOMEBREW_PREFIX/"opt/glibc/bin/ld.so" unless ld_so.readable? ld_so = DYNAMIC_LINKERS.find { |s| File.executable? s } if ld_so.blank? ::Kernel.raise "Unable to locate the system's dynamic linker" unless brew_ld_so.readable? return end end return if brew_ld_so.readable? && (brew_ld_so.readlink == ld_so) FileUtils.mkdir_p HOMEBREW_PREFIX/"lib" FileUtils.ln_sf ld_so, brew_ld_so end |