Module: OS::Linux Private

Extended by:
Utils::Output::Mixin
Defined in:
os/linux.rb,
extend/os/linux/keg.rb,
extend/os/linux/search.rb,
extend/os/linux/cleaner.rb,
extend/os/linux/cleanup.rb,
extend/os/linux/formula.rb,
extend/os/linux/install.rb,
extend/os/linux/sandbox.rb,
extend/os/linux/cmd/info.rb,
extend/os/linux/test_bot.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/linkage_checker.rb,
extend/os/linux/simulate_system.rb,
extend/os/linux/cask/utils/trash.rb,
extend/os/linux/extend/ENV/super.rb,
extend/os/linux/development_tools.rb,
extend/os/linux/extend/ENV/shared.rb,
extend/os/linux/extend/pathname/os.rb,
extend/os/linux/cask/artifact/moved.rb,
extend/os/linux/dev-cmd/update-test.rb,
extend/os/linux/bottle_specification.rb,
extend/os/linux/bundle/brew_services.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/glibc.rb,
os/linux/elf/os.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: BottleSpecification, Bundle, Cask, Cleaner, Cleanup, Cmd, CompilerSelector, DependencyCollector, DevCmd, DevelopmentTools, Diagnostic, Elf, Formula, FormulaCellarChecks, Glibc, Hardware, Install, Keg, Kernel, Ld, Libstdcxx, LinkageChecker, Pathname, Sandbox, Search, SharedEnvExtension, SimulateSystem, Stdenv, Superenv, SystemConfig, TestBot

Class Method Summary collapse

Methods included from Utils::Output::Mixin

issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning

Class Method Details

.inside_docker?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)


52
53
54
55
56
57
58
# File 'os/linux.rb', line 52

def self.inside_docker?
  return true if File.file?("/.dockerenv")
  return true if File.file?("/run/.containerenv")
  return false unless File.file?("/proc/1/cgroup")

  File.read("/proc/1/cgroup").match?(/azpl_job|actions_job|docker|garden|kubepods/)
end

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



97
98
99
# File 'os/linux.rb', line 97

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:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'os/linux.rb', line 78

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:



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

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)


47
48
49
# File 'os/linux.rb', line 47

def self.wsl?
  OS.wsl?
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:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'os/linux.rb', line 61

def self.wsl_version
  return Version::NULL unless wsl?

  kernel = OS.kernel_version.to_s
  kernel_version = kernel[/^([0-9.]*)-.*/, 1]
  if kernel_version && Version.new(kernel_version) > 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