| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 11:13:13 -08:00
										 |  |  | module OS | 
					
						
							| 
									
										
										
										
											2019-09-13 16:48:12 +01:00
										 |  |  |   module Linux | 
					
						
							|  |  |  |     module_function | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def os_version | 
					
						
							|  |  |  |       if which("lsb_release") | 
					
						
							|  |  |  |         description = Utils.popen_read("lsb_release -d") | 
					
						
							|  |  |  |                            .chomp | 
					
						
							|  |  |  |                            .sub("Description:\t", "") | 
					
						
							|  |  |  |         codename = Utils.popen_read("lsb_release -c") | 
					
						
							|  |  |  |                         .chomp | 
					
						
							|  |  |  |                         .sub("Codename:\t", "") | 
					
						
							|  |  |  |         "#{description} (#{codename})" | 
					
						
							|  |  |  |       elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable? | 
					
						
							|  |  |  |         redhat_release.read.chomp | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         "Unknown" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 11:13:13 -08:00
										 |  |  |   # Define OS::Mac on Linux for formula API compatibility. | 
					
						
							|  |  |  |   module Mac | 
					
						
							|  |  |  |     module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-19 21:46:20 +09:00
										 |  |  |     # rubocop:disable Naming/ConstantName | 
					
						
							|  |  |  |     # rubocop:disable Style/MutableConstant | 
					
						
							|  |  |  |     ::MacOS = self | 
					
						
							|  |  |  |     # 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 | 
					
						
							|  |  |  |       @languages ||= [ | 
					
						
							|  |  |  |         *ARGV.value("language")&.split(","), | 
					
						
							|  |  |  |         *ENV["HOMEBREW_LANGUAGES"]&.split(","), | 
					
						
							|  |  |  |         *ENV["LANG"]&.slice(/[a-z]+/), | 
					
						
							|  |  |  |       ].uniq | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def language | 
					
						
							|  |  |  |       languages.first | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 11:13:13 -08:00
										 |  |  |     module Xcode | 
					
						
							|  |  |  |       module_function | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def version | 
					
						
							|  |  |  |         Version::NULL | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |