Module: OS::Linux Private

Defined in:
os/linux.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: Elf, Glibc, Kernel, Ld

Class Method Summary collapse

Class Method Details

.os_versionString

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.

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'os/linux.rb', line 13

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.

Returns:

  • (Boolean)


33
34
35
# File 'os/linux.rb', line 33

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:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'os/linux.rb', line 38

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