| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  | require "formula" | 
					
						
							| 
									
										
										
										
											2017-12-04 17:46:52 -08:00
										 |  |  | require "os/linux/glibc" | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | class SystemConfig | 
					
						
							|  |  |  |   class << self | 
					
						
							|  |  |  |     def host_os_version | 
					
						
							|  |  |  |       if which("lsb_release") | 
					
						
							|  |  |  |         description = `lsb_release -d`.chomp.sub("Description:\t", "") | 
					
						
							|  |  |  |         codename = `lsb_release -c`.chomp.sub("Codename:\t", "") | 
					
						
							|  |  |  |         "#{description} (#{codename})" | 
					
						
							|  |  |  |       elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable? | 
					
						
							|  |  |  |         redhat_release.read.chomp | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         "N/A" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 17:46:52 -08:00
										 |  |  |     def host_glibc_version | 
					
						
							|  |  |  |       version = OS::Linux::Glibc.system_version | 
					
						
							|  |  |  |       return "N/A" if version.null? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 17:46:52 -08:00
										 |  |  |       version | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |     def host_gcc_version | 
					
						
							|  |  |  |       gcc = Pathname.new "/usr/bin/gcc" | 
					
						
							|  |  |  |       return "N/A" unless gcc.executable? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |       `#{gcc} --version 2>/dev/null`[/ (\d+\.\d+\.\d+)/, 1] | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-25 12:38:34 -07:00
										 |  |  |     def formula_linked_version(formula) | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |       return "N/A" unless CoreTap.instance.installed? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-25 12:38:34 -07:00
										 |  |  |       Formulary.factory(formula).linked_version || "N/A" | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |     rescue FormulaUnavailableError | 
					
						
							| 
									
										
										
										
											2018-03-06 09:36:49 +00:00
										 |  |  |       "N/A" | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def dump_verbose_config(out = $stdout) | 
					
						
							|  |  |  |       dump_generic_verbose_config(out) | 
					
						
							|  |  |  |       out.puts "Kernel: #{`uname -mors`.chomp}" | 
					
						
							|  |  |  |       out.puts "OS: #{host_os_version}" | 
					
						
							| 
									
										
										
										
											2017-12-04 17:46:52 -08:00
										 |  |  |       out.puts "Host glibc: #{host_glibc_version}" | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |       out.puts "/usr/bin/gcc: #{host_gcc_version}" | 
					
						
							|  |  |  |       ["glibc", "gcc", "xorg"].each do |f| | 
					
						
							| 
									
										
										
										
											2017-08-25 12:38:34 -07:00
										 |  |  |         out.puts "#{f}: #{formula_linked_version f}" | 
					
						
							| 
									
										
										
										
											2017-03-13 16:56:35 -07:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |