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!
#describe_clang
Class Method Details
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.
.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.
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.
34
35
36
|
# File 'extend/os/mac/system_config.rb', line 34
def clt
@clt ||= MacOS::CLT.version if MacOS::CLT.installed?
end
|
.core_tap_config(out = $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.
136
137
138
|
# File 'system_config.rb', line 136
def core_tap_config(out = $stdout)
dump_tap_config(CoreTap.instance, out)
end
|
.describe_clang ⇒ 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.
53
54
55
56
57
58
59
60
61
|
# File 'system_config.rb', line 53
def describe_clang
return "N/A" if clang.null?
if clang_build.null?
clang.to_s
else
"#{clang} build #{clang_build}"
end
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.
99
100
101
102
103
104
105
106
107
108
|
# File 'system_config.rb', line 99
def describe_curl
out, = system_command(Utils::Curl.curl_executable, args: ["--version"], verbose: false)
match_data = /^curl (?<curl_version>[\d.]+)/.match(out)
if match_data
"#{match_data[:curl_version]} => #{Utils::Curl.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
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.
75
76
77
|
# File 'system_config.rb', line 75
def describe_homebrew_ruby
"#{RUBY_VERSION} => #{RUBY_PATH}"
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.
63
64
65
66
67
68
69
70
71
72
|
# File 'system_config.rb', line 63
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.
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.
.dump_tap_config(tap, out = $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.
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'system_config.rb', line 110
def dump_tap_config(tap, out = $stdout)
case tap
when CoreTap
tap_name = "Core tap"
json_file_name = "formula.jws.json"
when CoreCaskTap
tap_name = "Core cask tap"
json_file_name = "cask.jws.json"
else
raise ArgumentError, "Unknown tap: #{tap}"
end
if tap.installed?
out.puts "#{tap_name} origin: #{tap.remote}" if tap.remote != tap.default_remote
out.puts "#{tap_name} HEAD: #{tap.git_head || "(none)"}"
out.puts "#{tap_name} last commit: #{tap.git_last_commit || "never"}"
out.puts "#{tap_name} branch: #{tap.git_branch || "(none)"}" if tap.git_branch != "master"
end
if (json_file = Homebrew::API::HOMEBREW_CACHE_API/json_file_name) && json_file.exist?
out.puts "#{tap_name} JSON: #{json_file.mtime.utc.strftime("%d %b %H:%M UTC")}"
elsif !tap.installed?
out.puts "#{tap_name}: N/A"
end
end
|
.dump_verbose_config(out = $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.
.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.
38
39
40
|
# File 'system_config.rb', line 38
def head
homebrew_repo.head_ref || "(none)"
end
|
.homebrew_config(out = $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.
140
141
142
143
144
145
|
# File 'system_config.rb', line 140
def homebrew_config(out = $stdout)
out.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}"
out.puts "ORIGIN: #{origin}"
out.puts "HEAD: #{head}"
out.puts "Last commit: #{last_commit}"
end
|
.homebrew_env_config(out = $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.
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
175
176
|
# File 'system_config.rb', line 147
def homebrew_env_config(out = $stdout)
out.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)
out.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]
out.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)
out.puts "#{env}: set"
else
out.puts "#{env}: #{value}"
end
end
out.puts "Homebrew Ruby: #{describe_homebrew_ruby}"
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.
.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(out = $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.
178
179
180
181
182
|
# File 'system_config.rb', line 178
def host_software_config(out = $stdout)
out.puts "Clang: #{describe_clang}"
out.puts "Git: #{describe_git}"
out.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.
87
88
89
|
# File 'system_config.rb', line 87
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.
43
44
45
|
# File 'system_config.rb', line 43
def last_commit
homebrew_repo.last_committed || "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.
48
49
50
|
# File 'system_config.rb', line 48
def origin
homebrew_repo.origin_url || "(none)"
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.
26
27
28
29
30
31
32
|
# File 'extend/os/mac/system_config.rb', line 26
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
|