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

Modules: Glibc, Kernel

Class Method Summary collapse

Class Method Details

.os_versionString

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.

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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
  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.

Returns:

  • (Boolean)


28
29
30
# File 'os/linux.rb', line 28

def self.wsl?
  /-microsoft/i.match?(OS.kernel_version.to_s)
end

.wsl_versionVersion

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.

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'os/linux.rb', line 33

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