Module: SystemConfig
Private
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 module for querying information about the system configuration.
Constant Summary
collapse
- HOST_RUBY_PATH =
"/usr/bin/ruby"
Class Method Summary
collapse
system_command, system_command!
Class Method Details
.clang ⇒ 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.
19
20
21
22
23
24
25
|
# File 'system_config.rb', line 19
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.
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.
27
28
29
30
31
32
33
|
# File 'system_config.rb', line 27
def clang_build
@clang_build ||= if DevelopmentTools.installed?
DevelopmentTools.clang_build_version
else
Version::NULL
end
end
|
.clt ⇒ Object
37
38
39
|
# File 'extend/os/mac/system_config.rb', line 37
def clt
@clt ||= MacOS::CLT.version if MacOS::CLT.installed?
end
|
.core_tap_branch ⇒ 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.
66
67
68
|
# File 'system_config.rb', line 66
def core_tap_branch
CoreTap.instance.git_branch || "(none)"
end
|
.core_tap_config(f = $stdout) ⇒ 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.
142
143
144
145
146
147
148
149
150
151
|
# File 'system_config.rb', line 142
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 ⇒ 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.
56
57
58
|
# File 'system_config.rb', line 56
def core_tap_head
CoreTap.instance.git_head || "(none)"
end
|
.core_tap_last_commit ⇒ 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.
61
62
63
|
# File 'system_config.rb', line 61
def core_tap_last_commit
CoreTap.instance.git_last_commit || "never"
end
|
.core_tap_origin ⇒ 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.
71
72
73
|
# File 'system_config.rb', line 71
def core_tap_origin
CoreTap.instance.remote || "(none)"
end
|
.describe_clang ⇒ String
22
23
24
25
26
27
|
# File 'extend/os/mac/system_config.rb', line 22
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 ⇒ 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.
132
133
134
135
136
137
138
139
140
|
# File 'system_config.rb', line 132
def describe_curl
out, = system_command(curl_executable, args: ["--version"], verbose: false)
if /^curl (?<curl_version>[\d.]+)/ =~ out
"#{curl_version} => #{curl_path}"
else
"N/A"
end
end
|
.describe_git ⇒ 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.
.describe_homebrew_ruby ⇒ String
12
13
14
15
16
17
18
19
20
|
# File 'extend/os/mac/system_config.rb', line 12
def describe_homebrew_ruby
s = describe_homebrew_ruby_version
if RUBY_PATH.to_s.match?(%r{^/System/Library/Frameworks/Ruby\.framework/Versions/[12]\.[089]/usr/bin/ruby})
s
else
"#{s} => #{RUBY_PATH}"
end
end
|
.describe_homebrew_ruby_version ⇒ 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.
98
99
100
101
102
103
104
105
|
# File 'system_config.rb', line 98
def describe_homebrew_ruby_version
case RUBY_VERSION
when /^1\.[89]/, /^2\.0/
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
else
RUBY_VERSION
end
end
|
.describe_path(path) ⇒ 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.
86
87
88
89
90
91
92
93
94
95
|
# File 'system_config.rb', line 86
def describe_path(path)
return "N/A" if path.nil?
realpath = path.realpath
if realpath == path
path
else
"#{path} => #{realpath}"
end
end
|
.dump_verbose_config(f = $stdout) ⇒ Object
Also known as:
dump_generic_verbose_config
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.
41
42
43
44
45
46
47
|
# File 'extend/os/mac/system_config.rb', line 41
def dump_verbose_config(f = $stdout)
dump_generic_verbose_config(f)
f.puts "macOS: #{MacOS.full_version}-#{kernel}"
f.puts "CLT: #{clt || "N/A"}"
f.puts "Xcode: #{xcode || "N/A"}"
f.puts "Rosetta 2: #{Hardware::CPU.in_rosetta2?}" if Hardware::CPU.physical_cpu_arm64?
end
|
.hardware ⇒ 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.
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.
41
42
43
|
# File 'system_config.rb', line 41
def head
homebrew_repo.git_head || "(none)"
end
|
.homebrew_config(f = $stdout) ⇒ 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.
153
154
155
156
157
158
|
# File 'system_config.rb', line 153
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.
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.
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'system_config.rb', line 160
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
|
.homebrew_repo ⇒ Pathname
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.
.host_gcc_version ⇒ Object
21
22
23
24
25
26
|
# File '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
14
15
16
17
18
19
|
# File '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
36
37
38
39
40
41
|
# File '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.
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.
191
192
193
194
195
|
# File 'system_config.rb', line 191
def host_software_config(f = $stdout)
f.puts "Clang: #{describe_clang}"
f.puts "Git: #{describe_git}"
f.puts "Curl: #{describe_curl}"
end
|
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.
120
121
122
|
# File 'system_config.rb', line 120
def kernel
`uname -m`.chomp
end
|
.last_commit ⇒ 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.
46
47
48
|
# File 'system_config.rb', line 46
def last_commit
homebrew_repo.git_last_commit || "never"
end
|
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.
51
52
53
|
# File 'system_config.rb', line 51
def origin
homebrew_repo.git_origin || "(none)"
end
|
.wsl_version(kernel) ⇒ Object
43
44
45
46
47
48
49
|
# File 'extend/os/linux/system_config.rb', line 43
def wsl_version(kernel)
return unless /-microsoft/i.match?(kernel)
return "2 (Microsoft Store)" if Version.new(kernel[/Linux ([0-9.]*)-.*/, 1]) > Version.new("5.15")
return "2" if /-microsoft/.match?(kernel)
return "1" if /-Microsoft/.match?(kernel)
end
|
.xcode ⇒ Object
29
30
31
32
33
34
35
|
# File 'extend/os/mac/system_config.rb', line 29
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
|