diff --git a/Library/Homebrew/extend/os/install.rb b/Library/Homebrew/extend/os/install.rb new file mode 100644 index 0000000000..a98faed821 --- /dev/null +++ b/Library/Homebrew/extend/os/install.rb @@ -0,0 +1 @@ +require "extend/os/linux/install" if OS.linux? diff --git a/Library/Homebrew/extend/os/linux/install.rb b/Library/Homebrew/extend/os/linux/install.rb new file mode 100644 index 0000000000..91f043ac25 --- /dev/null +++ b/Library/Homebrew/extend/os/linux/install.rb @@ -0,0 +1,34 @@ +module Homebrew + module Install + module_function + + 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 + + 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 + + def perform_preinstall_checks + generic_perform_preinstall_checks + symlink_ld_so + end + end +end diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index c451acd15e..ee647a995f 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -36,6 +36,8 @@ module Homebrew attempt_directory_creation fatal_checks(:fatal_install_checks) end + alias generic_perform_preinstall_checks perform_preinstall_checks + module_function :generic_perform_preinstall_checks def fatal_checks(type) @checks ||= Diagnostic::Checks.new @@ -51,3 +53,5 @@ module Homebrew end end end + +require "extend/os/install"