Module: OS::Linux Private

Extended by:
Utils::Output::Mixin
Defined in:
os/linux.rb,
extend/os/linux/keg.rb,
extend/os/linux/cleaner.rb,
extend/os/linux/cleanup.rb,
extend/os/linux/formula.rb,
extend/os/linux/install.rb,
extend/os/linux/compilers.rb,
extend/os/linux/diagnostic.rb,
extend/os/linux/cask/config.rb,
extend/os/linux/hardware/cpu.rb,
extend/os/linux/keg_relocate.rb,
extend/os/linux/bundle/bundle.rb,
extend/os/linux/cask/caskroom.rb,
extend/os/linux/dev-cmd/tests.rb,
extend/os/linux/system_config.rb,
extend/os/linux/bundle/skipper.rb,
extend/os/linux/cask/installer.rb,
extend/os/linux/dev-cmd/bottle.rb,
extend/os/linux/extend/ENV/std.rb,
extend/os/linux/cask/quarantine.rb,
extend/os/linux/extend/pathname.rb,
extend/os/linux/linkage_checker.rb,
extend/os/linux/simulate_system.rb,
extend/os/linux/extend/ENV/super.rb,
extend/os/linux/development_tools.rb,
extend/os/linux/extend/ENV/shared.rb,
extend/os/linux/dev-cmd/update-test.rb,
extend/os/linux/dependency_collector.rb,
extend/os/linux/formula_cellar_checks.rb,
extend/os/linux/cask/artifact/relocated.rb,
os/linux/ld.rb,
os/linux/elf.rb,
os/linux/glibc.rb,
os/linux/kernel.rb,
os/linux/libstdcxx.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: Bundle, Cask, Cleaner, Cleanup, CompilerSelector, DependencyCollector, DevCmd, DevelopmentTools, Diagnostic, Elf, Formula, FormulaCellarChecks, Glibc, Hardware, Install, Keg, Kernel, Ld, Libstdcxx, LinkageChecker, Pathname, SharedEnvExtension, SimulateSystem, Stdenv, Superenv, SystemConfig

Class Method Summary collapse

Methods included from Utils::Output::Mixin

odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, pretty_duration, pretty_installed, pretty_outdated, pretty_uninstalled

Class Method Details

.languageString?

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:



85
86
87
# File 'os/linux.rb', line 85

def self.language
  languages.first
end

.languagesArray<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.

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'os/linux.rb', line 66

def self.languages
  return @languages if @languages.present?

  locale_variables = ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort
  ctl_ret = Utils.popen_read("localectl", "list-locales")
  list = T.let([], T::Array[String])
  if ctl_ret.present?
    list = T.cast(ctl_ret.scan(/[^ \n"(),]+/), T::Array[String])
  elsif locale_variables.present?
    keys = locale_variables.select { |var| ENV.fetch(var) }
    list = keys.map { |key| ENV.fetch(key) }
  else
    list = ["en_US.utf8"]
  end

  @languages = list.map { |item| item.split(".").fetch(0).tr("_", "-") }
end

.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:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'os/linux.rb', line 24

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")

    odie "Failed to parse lsb_release output: #{lsb_info.inspect}" unless description

    codename = lsb_info[/^Codename:\s*(.*)$/, 1]
    if codename.blank? || (codename == "n/a")
      description
    else
      "#{description} (#{codename})"
    end
  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)


45
46
47
# File 'os/linux.rb', line 45

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:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'os/linux.rb', line 50

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