Module: OS::Linux Private
- Defined in:
- os/linux.rb,
extend/os/linux/cleanup.rb,
extend/os/linux/formula.rb,
extend/os/linux/cli/parser.rb,
extend/os/linux/diagnostic.rb,
extend/os/linux/cask/installer.rb,
extend/os/linux/simulate_system.rb,
extend/os/linux/development_tools.rb,
extend/os/linux/dependency_collector.rb,
os/linux/ld.rb,
os/linux/elf.rb,
os/linux/glibc.rb,
os/linux/kernel.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 module for querying system information on Linux.
Defined Under Namespace
Modules: CLI, Cask, Cleanup, DependencyCollector, DevelopmentTools, Diagnostic, Elf, Formula, Glibc, Kernel, Ld, SimulateSystem
Class Method Summary collapse
-
.os_version ⇒ String
internal
Get the OS version.
- .wsl? ⇒ Boolean private
- .wsl_version ⇒ Version private
Class Method Details
.os_version ⇒ String
This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Get the OS version.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'os/linux.rb', line 20 def self.os_version if which("lsb_release") lsb_info = Utils.popen_read("lsb_release", "-a") description = lsb_info[/^Description:\s*(.*)$/, 1].force_encoding("UTF-8") codename = lsb_info[/^Codename:\s*(.*)$/, 1] if codename.blank? || (codename == "n/a") description else "#{description} (#{codename})" end elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable? redhat_release.read.chomp elsif ::OS_VERSION.present? ::OS_VERSION else "Unknown" end end |
.wsl? ⇒ Boolean
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.
40 41 42 |
# File 'os/linux.rb', line 40 def self.wsl? /-microsoft/i.match?(OS.kernel_version.to_s) end |
.wsl_version ⇒ 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.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'os/linux.rb', line 45 def self.wsl_version return Version::NULL unless wsl? kernel = OS.kernel_version.to_s if Version.new(T.must(kernel[/^([0-9.]*)-.*/, 1])) > Version.new("5.15") Version.new("2 (Microsoft Store)") elsif kernel.include?("-microsoft") Version.new("2") elsif kernel.include?("-Microsoft") Version.new("1") else Version::NULL end end |