81 lines
2.1 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
require "version"
2020-08-25 00:01:15 +02:00
# Helper functions for querying operating system information.
2013-10-18 12:56:51 -05:00
module OS
2024-04-22 21:05:48 +02:00
# Check whether the operating system is macOS.
2020-08-25 00:01:15 +02:00
#
# @api public
2020-11-23 17:31:17 +01:00
sig { returns(T::Boolean) }
2013-10-18 12:56:51 -05:00
def self.mac?
2016-07-26 20:30:30 -06:00
return false if ENV["HOMEBREW_TEST_GENERIC_OS"]
2018-09-17 02:45:00 +02:00
RbConfig::CONFIG["host_os"].include? "darwin"
2013-10-18 12:56:51 -05:00
end
2024-04-22 21:05:48 +02:00
# Check whether the operating system is Linux.
2020-08-25 00:01:15 +02:00
#
# @api public
2020-11-23 17:31:17 +01:00
sig { returns(T::Boolean) }
2013-10-18 12:56:51 -05:00
def self.linux?
return false if ENV["HOMEBREW_TEST_GENERIC_OS"]
2018-09-17 02:45:00 +02:00
RbConfig::CONFIG["host_os"].include? "linux"
2013-10-18 12:56:51 -05:00
end
2020-08-25 00:01:15 +02:00
# Get the kernel version.
#
# @api public
2020-11-23 17:31:17 +01:00
sig { returns(Version) }
2020-08-17 12:24:53 -07:00
def self.kernel_version
@kernel_version ||= Version.new(Utils.safe_popen_read("uname", "-r").chomp)
end
# Get the kernel name.
#
# @api public
sig { returns(String) }
def self.kernel_name
@kernel_name ||= Utils.safe_popen_read("uname", "-s").chomp
end
::OS_VERSION = ENV.fetch("HOMEBREW_OS_VERSION").freeze
# See Linux-CI.md
LINUX_CI_OS_VERSION = "Ubuntu 22.04"
LINUX_GLIBC_CI_VERSION = "2.35"
LINUX_GLIBC_NEXT_CI_VERSION = "2.35"
LINUX_GCC_CI_VERSION = "11.0"
2022-09-18 00:58:47 +01:00
LINUX_PREFERRED_GCC_COMPILER_FORMULA = "gcc@11" # https://packages.ubuntu.com/jammy/gcc
LINUX_PREFERRED_GCC_RUNTIME_FORMULA = "gcc"
if OS.mac?
require "os/mac"
require "hardware"
# Don't tell people to report issues on unsupported configurations.
if !OS::Mac.version.prerelease? &&
!OS::Mac.version.outdated_release? &&
ARGV.none? { |v| v.start_with?("--cc=") } &&
(HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX ||
(HOMEBREW_PREFIX.to_s == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX && Hardware::CPU.arm?))
ISSUES_URL = "https://docs.brew.sh/Troubleshooting"
end
PATH_OPEN = "/usr/bin/open"
elsif OS.linux?
require "os/linux"
ISSUES_URL = "https://docs.brew.sh/Troubleshooting"
PATH_OPEN = if OS::Linux.wsl? && (wslview = which("wslview").presence)
wslview.to_s
else
"xdg-open"
end.freeze
end
sig { returns(T::Boolean) }
def self.unsupported_configuration?
!defined?(OS::ISSUES_URL)
end
2013-10-18 12:56:51 -05:00
end