59 lines
1.4 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
2020-08-25 00:01:15 +02:00
# Helper functions for querying operating system information.
#
# @api private
2013-10-18 12:56:51 -05:00
module OS
2020-11-23 17:31:17 +01:00
extend T::Sig
2020-08-25 00:01:15 +02:00
# Check if the operating system is macOS.
#
# @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
2020-08-25 00:01:15 +02:00
# Check if the operating system is Linux.
#
# @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
::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]
CI_GLIBC_VERSION = "2.23"
CI_OS_VERSION = "Ubuntu 16.04"
if OS.mac?
require "os/mac"
# 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=") } &&
ENV["HOMEBREW_PREFIX"] == "/usr/local"
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 = "xdg-open"
end
2013-10-18 12:56:51 -05:00
end