| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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") | 
					
						
							| 
									
										
										
										
											2020-11-30 14:41:02 -06:00
										 |  |  |         description = lsb_info[/^Description:\s*(.*)$/, 1] | 
					
						
							|  |  |  |         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 | 
					
						
							|  |  |  |   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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-19 21:46:20 +09:00
										 |  |  |     # rubocop:disable Naming/ConstantName | 
					
						
							|  |  |  |     # rubocop:disable Style/MutableConstant | 
					
						
							| 
									
										
										
										
											2020-06-22 16:19:11 +05:30
										 |  |  |     ::MacOS = OS::Mac | 
					
						
							| 
									
										
										
										
											2019-04-19 21:46:20 +09:00
										 |  |  |     # rubocop:enable Naming/ConstantName | 
					
						
							|  |  |  |     # rubocop:enable Style/MutableConstant | 
					
						
							| 
									
										
										
										
											2018-02-20 11:13:13 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  |       Version::NULL | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def full_version | 
					
						
							|  |  |  |       Version::NULL | 
					
						
							|  |  |  |     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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-10 14:59:22 +01:00
										 |  |  |     def sdk_path_if_needed(_v = nil) | 
					
						
							|  |  |  |       nil | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-17 16:13:28 +01:00
										 |  |  |     def sdk_path | 
					
						
							|  |  |  |       nil | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 11:13:13 -08:00
										 |  |  |     module Xcode | 
					
						
							|  |  |  |       module_function | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def version | 
					
						
							|  |  |  |         Version::NULL | 
					
						
							|  |  |  |       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 | 
					
						
							|  |  |  |         Version::NULL | 
					
						
							|  |  |  |       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 |