Module: OS::Linux Private
- Defined in:
- os/linux.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
Class Method Summary collapse
-
.os_version ⇒ String
private
-
.wsl? ⇒ Boolean
private
-
.wsl_version ⇒ Version
private
Class Method Details
.os_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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'os/linux.rb', line 10 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.
30 31 32 |
# File 'os/linux.rb', line 30 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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'os/linux.rb', line 35 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 |