Module: OS::Linux::SystemConfig::ClassMethods Private
- Includes:
- SystemCommand::Mixin
- Defined in:
- extend/os/linux/system_config.rb
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.
Constant Summary collapse
- HOST_RUBY_PATH =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"/usr/bin/ruby"
Instance Method Summary collapse
- #dump_verbose_config(out = $stdout) ⇒ void private
- #formula_linked_version(formula) ⇒ String, PkgVersion private
- #host_gcc_version ⇒ String private
- #host_glibc_version ⇒ String, Version private
- #host_libstdcxx_version ⇒ String, Version private
- #host_ruby_version ⇒ String private
- #windows_registry_values(cmd) ⇒ Hash{String => String} private
- #windows_registry_version(cmd) ⇒ String? private
- #windows_version ⇒ String? private
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Instance Method Details
#dump_verbose_config(out = $stdout) ⇒ void
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 returns an undefined value.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'extend/os/linux/system_config.rb', line 107 def dump_verbose_config(out = $stdout) kernel = Utils.safe_popen_read("uname", "-mors").chomp super out.puts "Kernel: #{kernel}" out.puts "OS: #{OS::Linux.os_version}" if OS.wsl? out.puts "WSL: #{OS::Linux.wsl_version}" windows = windows_version out.puts "Windows: #{windows}" if windows end out.puts "Host glibc: #{host_glibc_version}" out.puts "Host libstdc++: #{host_libstdcxx_version}" out.puts "#{::DevelopmentTools.host_gcc_path}: #{host_gcc_version}" out.puts "/usr/bin/ruby: #{host_ruby_version}" if RUBY_PATH != HOST_RUBY_PATH ["glibc", ::CompilerSelector.preferred_gcc, OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA, "xorg"].each do |f| out.puts "#{f}: #{formula_linked_version(f)}" end end |
#formula_linked_version(formula) ⇒ String, PkgVersion
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.
42 43 44 45 46 47 48 |
# File 'extend/os/linux/system_config.rb', line 42 def formula_linked_version(formula) return "N/A" if Homebrew::EnvConfig.no_install_from_api? && !CoreTap.instance.installed? Formulary.factory(formula).any_installed_version || "N/A" rescue FormulaUnavailableError "N/A" end |
#host_gcc_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.
34 35 36 37 38 39 |
# File 'extend/os/linux/system_config.rb', line 34 def host_gcc_version gcc = ::DevelopmentTools.host_gcc_path return "N/A" unless gcc.executable? Utils.popen_read(gcc, "--version")[/ (\d+\.\d+\.\d+)/, 1] || "N/A" end |
#host_glibc_version ⇒ String, Version
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.
18 19 20 21 22 23 |
# File 'extend/os/linux/system_config.rb', line 18 def host_glibc_version version = OS::Linux::Glibc.system_version return "N/A" if version.null? version end |
#host_libstdcxx_version ⇒ String, Version
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 |
# File 'extend/os/linux/system_config.rb', line 26 def host_libstdcxx_version version = OS::Linux::Libstdcxx.system_version return "N/A" if version.null? version end |
#host_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.
51 52 53 54 55 56 |
# File 'extend/os/linux/system_config.rb', line 51 def host_ruby_version out, _, status = system_command(HOST_RUBY_PATH, args: ["-e", "puts RUBY_VERSION"], print_stderr: false).to_a return "N/A" unless status.success? out end |
#windows_registry_values(cmd) ⇒ Hash{String => 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.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'extend/os/linux/system_config.rb', line 89 def windows_registry_values(cmd) output = Utils.popen_read(cmd, "/d", "/c", "reg", "query", "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", err: :close) output.each_line.with_object({}) do |line, values| match = line.delete("\r").match(/^\s*(\S+)\s+REG_\S+\s+(.+?)\s*$/) next if match.nil? key = match[1] value = match[2] next if key.nil? || value.nil? values[key] = value.start_with?("0x") ? value.to_i(16).to_s : value end end |
#windows_registry_version(cmd) ⇒ 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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'extend/os/linux/system_config.rb', line 73 def windows_registry_version(cmd) values = windows_registry_values(cmd) product_name = values["ProductName"] build = values["CurrentBuildNumber"] return if product_name.blank? || build.blank? product_name = product_name.sub(/\AWindows 10\b/, "Windows 11") if build.to_i >= 22_000 build += ".#{values["UBR"]}" if values["UBR"].present? version = values["DisplayVersion"] || values["ReleaseId"] return "#{product_name} [#{build}]" if version.blank? "#{product_name} (#{version}) [#{build}]" end |
#windows_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.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'extend/os/linux/system_config.rb', line 59 def windows_version return unless OS.wsl? cmd = Kernel.which("cmd.exe", ORIGINAL_PATHS) || ::Pathname.new("/mnt/c/Windows/System32/cmd.exe") return unless cmd.executable? windows_registry_version(cmd) || Utils.popen_read(cmd, "/d", "/c", "ver", err: :close) .delete("\r") .lines .map(&:strip) .find { |line| line.start_with?("Microsoft Windows") } end |