Module: SystemConfig Private
- Extended by:
- SystemCommand::Mixin
- Includes:
- SystemCommand::Mixin
- Defined in:
- Library/Homebrew/system_config.rb,
Library/Homebrew/extend/os/mac/system_config.rb,
Library/Homebrew/extend/os/linux/system_config.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helper module for querying information about the system configuration.
Constant Summary collapse
- HOST_RUBY_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"/usr/bin/ruby"
Class Method Summary collapse
- .clang ⇒ Object private
- .clang_build ⇒ Object private
- .clt ⇒ Object private
- .core_tap_branch ⇒ Object private
- .core_tap_config(f = $stdout) ⇒ Object private
- .core_tap_head ⇒ Object private
- .core_tap_last_commit ⇒ Object private
- .core_tap_origin ⇒ Object private
- .describe_clang ⇒ Object private
- .describe_curl ⇒ Object private
- .describe_git ⇒ Object private
- .describe_homebrew_ruby ⇒ Object private
- .describe_homebrew_ruby_version ⇒ Object private
- .describe_java ⇒ Object private
- .describe_path(path) ⇒ Object private
- .dump_generic_verbose_config ⇒ Object private
- .dump_verbose_config(out = $stdout) ⇒ Object private
- .formula_linked_version(formula) ⇒ Object private
- .hardware ⇒ Object private
- .head ⇒ Object private
- .homebrew_config(f = $stdout) ⇒ Object private
- .homebrew_env_config(f = $stdout) ⇒ Object private
- .host_gcc_version ⇒ Object private
- .host_glibc_version ⇒ Object private
- .host_ruby_version ⇒ Object private
- .host_software_config(f = $stdout) ⇒ Object private
- .kernel ⇒ Object private
- .last_commit ⇒ Object private
- .origin ⇒ Object private
- .xcode ⇒ Object private
- .xquartz ⇒ Object private
Methods included from SystemCommand::Mixin
system_command, system_command!
Class Method Details
.clang ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 |
# File 'Library/Homebrew/system_config.rb', line 17 def clang @clang ||= if DevelopmentTools.installed? DevelopmentTools.clang_version else Version::NULL end end |
.clang_build ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 |
# File 'Library/Homebrew/system_config.rb', line 25 def clang_build @clang_build ||= if DevelopmentTools.installed? DevelopmentTools.clang_build_version else Version::NULL end end |
.clt ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'Library/Homebrew/extend/os/mac/system_config.rb', line 40 def clt @clt ||= MacOS::CLT.version if MacOS::CLT.installed? end |
.core_tap_branch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'Library/Homebrew/system_config.rb', line 53 def core_tap_branch CoreTap.instance.git_branch || "(none)" end |
.core_tap_config(f = $stdout) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
127 128 129 130 131 132 133 134 135 136 |
# File 'Library/Homebrew/system_config.rb', line 127 def core_tap_config(f = $stdout) if CoreTap.instance.installed? f.puts "Core tap ORIGIN: #{core_tap_origin}" f.puts "Core tap HEAD: #{core_tap_head}" f.puts "Core tap last commit: #{core_tap_last_commit}" f.puts "Core tap branch: #{core_tap_branch}" else f.puts "Core tap: N/A" end end |
.core_tap_head ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'Library/Homebrew/system_config.rb', line 45 def core_tap_head CoreTap.instance.git_head || "(none)" end |
.core_tap_last_commit ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'Library/Homebrew/system_config.rb', line 49 def core_tap_last_commit CoreTap.instance.git_last_commit || "never" end |
.core_tap_origin ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'Library/Homebrew/system_config.rb', line 57 def core_tap_origin CoreTap.instance.remote || "(none)" end |
.describe_clang ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 66 |
# File 'Library/Homebrew/system_config.rb', line 61 def describe_clang return "N/A" if clang.null? clang_build_info = clang_build.null? ? "(parse error)" : clang_build "#{clang} build #{clang_build_info}" end |
.describe_curl ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 120 121 122 123 124 125 |
# File 'Library/Homebrew/system_config.rb', line 117 def describe_curl out, = system_command(curl_executable, args: ["--version"]) if /^curl (?<curl_version>[\d.]+)/ =~ out "#{curl_version} => #{curl_executable}" else "N/A" end end |
.describe_git ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 114 115 |
# File 'Library/Homebrew/system_config.rb', line 111 def describe_git return "N/A" unless Utils::Git.available? "#{Utils::Git.version} => #{Utils::Git.path}" end |
.describe_homebrew_ruby ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 |
# File 'Library/Homebrew/system_config.rb', line 88 def describe_homebrew_ruby "#{describe_homebrew_ruby_version} => #{RUBY_PATH}" end |
.describe_homebrew_ruby_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 82 83 84 85 86 |
# File 'Library/Homebrew/system_config.rb', line 79 def describe_homebrew_ruby_version case RUBY_VERSION when /^1\.[89]/, /^2\.0/ "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" else RUBY_VERSION end end |
.describe_java ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
102 103 104 105 106 107 108 109 |
# File 'Library/Homebrew/system_config.rb', line 102 def describe_java return "N/A" unless which "java" _, err, status = system_command("java", args: ["-version"], print_stderr: false) return "N/A" unless status.success? err[/java version "([\d._]+)"/, 1] || "N/A" end |
.describe_path(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 71 72 73 74 75 76 77 |
# File 'Library/Homebrew/system_config.rb', line 68 def describe_path(path) return "N/A" if path.nil? realpath = path.realpath if realpath == path path else "#{path} => #{realpath}" end end |
.dump_generic_verbose_config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
190 191 192 193 194 195 196 |
# File 'Library/Homebrew/system_config.rb', line 190 def dump_verbose_config(f = $stdout) homebrew_config(f) core_tap_config(f) homebrew_env_config(f) f.puts hardware if hardware host_software_config(f) end |
.dump_verbose_config(out = $stdout) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
183 184 185 186 187 188 189 |
# File 'Library/Homebrew/system_config.rb', line 183 def dump_verbose_config(f = $stdout) homebrew_config(f) core_tap_config(f) homebrew_env_config(f) f.puts hardware if hardware host_software_config(f) end |
.formula_linked_version(formula) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 |
# File 'Library/Homebrew/extend/os/linux/system_config.rb', line 28 def formula_linked_version(formula) return "N/A" unless CoreTap.instance.installed? Formulary.factory(formula).linked_version || "N/A" rescue FormulaUnavailableError "N/A" end |
.hardware ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 95 96 |
# File 'Library/Homebrew/system_config.rb', line 92 def hardware return if Hardware::CPU.type == :dunno "CPU: #{Hardware.cores_as_words}-core #{Hardware::CPU.bits}-bit #{Hardware::CPU.family}" end |
.head ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'Library/Homebrew/system_config.rb', line 33 def head HOMEBREW_REPOSITORY.git_head || "(none)" end |
.homebrew_config(f = $stdout) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
138 139 140 141 142 143 |
# File 'Library/Homebrew/system_config.rb', line 138 def homebrew_config(f = $stdout) f.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}" f.puts "ORIGIN: #{origin}" f.puts "HEAD: #{head}" f.puts "Last commit: #{last_commit}" end |
.homebrew_env_config(f = $stdout) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'Library/Homebrew/system_config.rb', line 145 def homebrew_env_config(f = $stdout) f.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" { HOMEBREW_REPOSITORY: Homebrew::DEFAULT_REPOSITORY, HOMEBREW_CELLAR: Homebrew::DEFAULT_CELLAR, }.freeze.each do |key, default| value = Object.const_get(key) f.puts "#{key}: #{value}" if value.to_s != default.to_s end Homebrew::EnvConfig::ENVS.each do |env, hash| method_name = Homebrew::EnvConfig.env_method_name(env, hash) if hash[:boolean] f.puts "#{env}: set" if Homebrew::EnvConfig.send(method_name) next end value = Homebrew::EnvConfig.send(method_name) next unless value next if (default = hash[:default].presence) && value.to_s == default.to_s if ENV.sensitive?(env) f.puts "#{env}: set" else f.puts "#{env}: #{value}" end end f.puts "Homebrew Ruby: #{describe_homebrew_ruby}" end |
.host_gcc_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 26 |
# File 'Library/Homebrew/extend/os/linux/system_config.rb', line 21 def host_gcc_version gcc = Pathname.new "/usr/bin/gcc" return "N/A" unless gcc.executable? `#{gcc} --version 2>/dev/null`[/ (\d+\.\d+\.\d+)/, 1] end |
.host_glibc_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 18 19 |
# File 'Library/Homebrew/extend/os/linux/system_config.rb', line 14 def host_glibc_version version = OS::Linux::Glibc.system_version return "N/A" if version.null? version end |
.host_ruby_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 |
# File 'Library/Homebrew/extend/os/linux/system_config.rb', line 36 def host_ruby_version out, _, status = system_command(HOST_RUBY_PATH, args: ["-e", "puts RUBY_VERSION"], print_stderr: false) return "N/A" unless status.success? out end |
.host_software_config(f = $stdout) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
176 177 178 179 180 181 |
# File 'Library/Homebrew/system_config.rb', line 176 def host_software_config(f = $stdout) f.puts "Clang: #{describe_clang}" f.puts "Git: #{describe_git}" f.puts "Curl: #{describe_curl}" f.puts "Java: #{describe_java}" if describe_java != "N/A" end |
.kernel ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
98 99 100 |
# File 'Library/Homebrew/system_config.rb', line 98 def kernel `uname -m`.chomp end |
.last_commit ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'Library/Homebrew/system_config.rb', line 37 def last_commit HOMEBREW_REPOSITORY.git_last_commit || "never" end |
.origin ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'Library/Homebrew/system_config.rb', line 41 def origin HOMEBREW_REPOSITORY.git_origin || "(none)" end |
.xcode ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 |
# File 'Library/Homebrew/extend/os/mac/system_config.rb', line 32 def xcode @xcode ||= if MacOS::Xcode.installed? xcode = MacOS::Xcode.version.to_s xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix? xcode end end |
.xquartz ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'Library/Homebrew/extend/os/mac/system_config.rb', line 44 def xquartz @xquartz ||= "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" if MacOS::XQuartz.installed? end |