Module: OS::Linux::Ld Private
- Defined in:
- os/linux/ld.rb
Overview
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.
Helper functions for querying ld
information.
Class Method Summary collapse
- .brewed_ld_so_diagnostics ⇒ String private
- .library_paths(conf_path = Pathname(sysconfdir)/"ld.so.conf") ⇒ Array<String> private
- .sysconfdir ⇒ String private
- .system_dirs ⇒ Array<String> private
Class Method Details
.brewed_ld_so_diagnostics ⇒ String
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.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'os/linux/ld.rb', line 9 def self.brewed_ld_so_diagnostics @brewed_ld_so_diagnostics ||= T.let({}, T.nilable(T::Hash[Pathname, String])) brewed_ld_so = HOMEBREW_PREFIX/"lib/ld.so" return "" unless brewed_ld_so.exist? brewed_ld_so_target = brewed_ld_so.readlink @brewed_ld_so_diagnostics[brewed_ld_so_target] ||= begin ld_so_output = Utils.popen_read(brewed_ld_so, "--list-diagnostics") ld_so_output if $CHILD_STATUS.success? end @brewed_ld_so_diagnostics[brewed_ld_so_target].to_s end |
.library_paths(conf_path = Pathname(sysconfdir)/"ld.so.conf") ⇒ Array<String>
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.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'os/linux/ld.rb', line 49 def self.library_paths(conf_path = Pathname(sysconfdir)/"ld.so.conf") conf_file = Pathname(conf_path) return [] unless conf_file.exist? paths = Set.new directory = conf_file.realpath.dirname conf_file.readlines.each do |line| # Remove comments and leading/trailing whitespace line.strip! line.sub!(/\s*#.*$/, "") if line.start_with?(/\s*include\s+/) include_path = Pathname(line.sub(/^\s*include\s+/, "")). wildcard = include_path.absolute? ? include_path : directory/include_path Dir.glob(wildcard.to_s).each do |include_file| paths += library_paths(include_file) end elsif line.empty? next else paths << line end end paths.to_a end |
.sysconfdir ⇒ String
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.
25 26 27 28 29 30 31 32 |
# File 'os/linux/ld.rb', line 25 def self.sysconfdir fallback_sysconfdir = "/etc" match = brewed_ld_so_diagnostics.match(/path.sysconfdir="(.+)"/) return fallback_sysconfdir unless match match.captures.compact.first || fallback_sysconfdir end |
.system_dirs ⇒ Array<String>
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.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'os/linux/ld.rb', line 35 def self.system_dirs dirs = [] brewed_ld_so_diagnostics.split("\n").each do |line| match = line.match(/path.system_dirs\[0x.*\]="(.*)"/) next unless match dirs << match.captures.compact.first end dirs end |