| 
									
										
										
										
											2024-07-12 14:24:03 -04:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-27 08:18:12 +00:00
										 |  |  | 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-26 22:26:29 +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? | 
					
						
							| 
									
										
										
										
											2016-07-27 22:10:34 -06:00
										 |  |  |     return false if ENV["HOMEBREW_TEST_GENERIC_OS"] | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-26 22:26:29 +02:00
										 |  |  |     RbConfig::CONFIG["host_os"].include? "linux" | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-06-03 16:59:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2024-10-31 15:01:43 +08:00
										 |  |  |     require "etc" | 
					
						
							|  |  |  |     @kernel_version ||= T.let(Version.new(Etc.uname.fetch(:release)), T.nilable(Version)) | 
					
						
							| 
									
										
										
										
											2020-08-17 12:24:53 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-09 22:39:35 +08:00
										 |  |  |   # Get the kernel name. | 
					
						
							|  |  |  |   # | 
					
						
							|  |  |  |   # @api public | 
					
						
							|  |  |  |   sig { returns(String) } | 
					
						
							| 
									
										
										
										
											2021-09-10 21:25:38 +08:00
										 |  |  |   def self.kernel_name | 
					
						
							| 
									
										
										
										
											2024-10-31 15:01:43 +08:00
										 |  |  |     require "etc" | 
					
						
							|  |  |  |     @kernel_name ||= T.let(Etc.uname.fetch(:sysname), T.nilable(String)) | 
					
						
							| 
									
										
										
										
											2021-09-09 22:39:35 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-12 14:24:03 -04:00
										 |  |  |   ::OS_VERSION = T.let(ENV.fetch("HOMEBREW_OS_VERSION").freeze, String) | 
					
						
							| 
									
										
										
										
											2016-04-04 11:46:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-21 23:13:44 -07:00
										 |  |  |   # See Linux-CI.md | 
					
						
							|  |  |  |   LINUX_CI_OS_VERSION = "Ubuntu 22.04" | 
					
						
							|  |  |  |   LINUX_GLIBC_CI_VERSION = "2.35" | 
					
						
							| 
									
										
										
										
											2025-02-04 21:18:02 +01:00
										 |  |  |   LINUX_GLIBC_NEXT_CI_VERSION = "2.39" | 
					
						
							| 
									
										
										
										
											2022-08-21 23:13:44 -07:00
										 |  |  |   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 | 
					
						
							| 
									
										
										
										
											2022-09-22 16:39:31 +08:00
										 |  |  |   LINUX_PREFERRED_GCC_RUNTIME_FORMULA = "gcc" | 
					
						
							| 
									
										
										
										
											2021-04-05 14:58:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-03 16:59:50 +02:00
										 |  |  |   if OS.mac? | 
					
						
							| 
									
										
										
										
											2015-10-16 16:41:14 +08:00
										 |  |  |     require "os/mac" | 
					
						
							| 
									
										
										
										
											2023-05-09 02:15:28 +02:00
										 |  |  |     require "hardware" | 
					
						
							| 
									
										
										
										
											2025-03-31 09:53:19 +01:00
										 |  |  |     # Don't tell people to report issues on non-Tier 1 configurations. | 
					
						
							| 
									
										
										
										
											2021-06-22 13:06:46 -04:00
										 |  |  |     if !OS::Mac.version.prerelease? && | 
					
						
							|  |  |  |        !OS::Mac.version.outdated_release? && | 
					
						
							| 
									
										
										
										
											2019-01-21 12:39:08 +00:00
										 |  |  |        ARGV.none? { |v| v.start_with?("--cc=") } && | 
					
						
							| 
									
										
										
										
											2023-02-02 19:58:03 -08:00
										 |  |  |        (HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX || | 
					
						
							|  |  |  |        (HOMEBREW_PREFIX.to_s == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX && Hardware::CPU.arm?)) | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  |       ISSUES_URL = "https://docs.brew.sh/Troubleshooting" | 
					
						
							| 
									
										
										
										
											2016-11-05 10:58:19 -04:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  |     PATH_OPEN = "/usr/bin/open" | 
					
						
							| 
									
										
										
										
											2014-06-03 16:59:50 +02:00
										 |  |  |   elsif OS.linux? | 
					
						
							| 
									
										
										
										
											2018-02-20 11:13:13 -08:00
										 |  |  |     require "os/linux" | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  |     ISSUES_URL = "https://docs.brew.sh/Troubleshooting" | 
					
						
							| 
									
										
										
										
											2023-03-02 15:54:37 +00:00
										 |  |  |     PATH_OPEN = if OS::Linux.wsl? && (wslview = which("wslview").presence) | 
					
						
							|  |  |  |       wslview.to_s | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       "xdg-open" | 
					
						
							|  |  |  |     end.freeze | 
					
						
							| 
									
										
										
										
											2014-06-03 16:59:50 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2023-02-02 14:49:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T::Boolean) } | 
					
						
							| 
									
										
										
										
											2025-03-31 09:53:19 +01:00
										 |  |  |   def self.not_tier_one_configuration? | 
					
						
							| 
									
										
										
										
											2023-02-02 14:49:33 +00:00
										 |  |  |     !defined?(OS::ISSUES_URL) | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  | end |