2020-10-10 14:16:11 +02:00
|
|
|
# typed: true
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-02-27 08:18:12 +00:00
|
|
|
require "utils"
|
|
|
|
|
2018-02-20 11:13:13 -08:00
|
|
|
module OS
|
2020-08-26 03:06:19 +02:00
|
|
|
# Helper module for querying system information on Linux.
|
2019-09-13 16:48:12 +01:00
|
|
|
module Linux
|
2020-10-20 12:03:48 +02:00
|
|
|
extend T::Sig
|
|
|
|
|
2019-09-13 16:48:12 +01:00
|
|
|
module_function
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(String) }
|
2019-09-13 16:48:12 +01:00
|
|
|
def os_version
|
|
|
|
if which("lsb_release")
|
2021-03-17 15:34:20 +00:00
|
|
|
lsb_info = Utils.popen_read("lsb_release", "-a")
|
2022-01-09 21:12:52 -05:00
|
|
|
description = lsb_info[/^Description:\s*(.*)$/, 1].force_encoding("UTF-8")
|
2020-11-30 14:41:02 -06:00
|
|
|
codename = lsb_info[/^Codename:\s*(.*)$/, 1]
|
2020-12-02 11:54:59 +00:00
|
|
|
if codename.blank? || (codename == "n/a")
|
2020-11-30 14:41:02 -06:00
|
|
|
description
|
|
|
|
else
|
|
|
|
"#{description} (#{codename})"
|
|
|
|
end
|
2019-09-13 16:48:12 +01:00
|
|
|
elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable?
|
|
|
|
redhat_release.read.chomp
|
|
|
|
else
|
|
|
|
"Unknown"
|
|
|
|
end
|
|
|
|
end
|
2023-02-27 08:18:12 +00:00
|
|
|
|
|
|
|
sig { returns(T::Boolean) }
|
|
|
|
def wsl?
|
|
|
|
/-microsoft/i.match?(OS.kernel_version.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
sig { returns(Version) }
|
|
|
|
def wsl_version
|
2023-02-27 10:17:50 -06:00
|
|
|
return Version::NULL unless wsl?
|
2023-02-27 08:18:12 +00:00
|
|
|
|
2023-02-27 10:17:50 -06:00
|
|
|
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
|
2023-02-27 08:18:12 +00:00
|
|
|
end
|
2019-09-13 16:48:12 +01:00
|
|
|
end
|
|
|
|
|
2020-08-26 03:06:19 +02:00
|
|
|
# rubocop:disable Style/Documentation
|
2018-02-20 11:13:13 -08:00
|
|
|
module Mac
|
|
|
|
module_function
|
|
|
|
|
2022-06-29 11:47:57 -04:00
|
|
|
::MacOS = OS::Mac
|
|
|
|
|
2018-08-13 23:38:48 -07:00
|
|
|
raise "Loaded OS::Linux on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
|
|
|
|
2018-02-20 11:13:13 -08:00
|
|
|
def version
|
2021-09-11 00:10:24 +01:00
|
|
|
::Version::NULL
|
2018-02-20 11:13:13 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def full_version
|
2021-09-11 00:10:24 +01:00
|
|
|
::Version::NULL
|
2018-02-20 11:13:13 -08:00
|
|
|
end
|
|
|
|
|
2019-03-26 17:14:12 -04:00
|
|
|
def languages
|
2020-07-13 22:48:53 +10:00
|
|
|
@languages ||= Array(ENV["LANG"]&.slice(/[a-z]+/)).uniq
|
2019-03-26 17:14:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def language
|
|
|
|
languages.first
|
|
|
|
end
|
|
|
|
|
2020-04-07 16:43:59 +01:00
|
|
|
def sdk_root_needed?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2023-03-07 23:42:00 +00:00
|
|
|
def sdk_path_if_needed(_version = nil)
|
2020-03-10 14:59:22 +01:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2023-03-12 17:06:29 -07:00
|
|
|
def sdk_path(_version = nil)
|
2020-08-17 16:13:28 +01:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2018-02-20 11:13:13 -08:00
|
|
|
module Xcode
|
|
|
|
module_function
|
|
|
|
|
|
|
|
def version
|
2021-09-11 00:10:24 +01:00
|
|
|
::Version::NULL
|
2018-02-20 11:13:13 -08:00
|
|
|
end
|
2020-09-01 12:49:19 +01:00
|
|
|
|
|
|
|
def installed?
|
|
|
|
false
|
|
|
|
end
|
2018-02-20 11:13:13 -08:00
|
|
|
end
|
2020-04-30 16:07:55 +01:00
|
|
|
|
|
|
|
module CLT
|
|
|
|
module_function
|
|
|
|
|
|
|
|
def version
|
2021-09-11 00:10:24 +01:00
|
|
|
::Version::NULL
|
2020-04-30 16:07:55 +01:00
|
|
|
end
|
2020-09-01 12:49:19 +01:00
|
|
|
|
|
|
|
def installed?
|
|
|
|
false
|
|
|
|
end
|
2020-04-30 16:07:55 +01:00
|
|
|
end
|
2018-02-20 11:13:13 -08:00
|
|
|
end
|
2020-08-26 03:06:19 +02:00
|
|
|
# rubocop:enable Style/Documentation
|
2018-02-20 11:13:13 -08:00
|
|
|
end
|