| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  | require "diagnostic" | 
					
						
							|  |  |  | require "fileutils" | 
					
						
							|  |  |  | require "hardware" | 
					
						
							|  |  |  | require "development_tools" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							|  |  |  |   module Install | 
					
						
							|  |  |  |     module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |     def check_cpu | 
					
						
							| 
									
										
										
										
											2020-04-30 16:50:13 +10:00
										 |  |  |       return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       message = "Sorry, Homebrew does not support your computer's CPU architecture!" | 
					
						
							|  |  |  |       if Hardware::CPU.ppc? | 
					
						
							|  |  |  |         message += <<~EOS | 
					
						
							|  |  |  |           For PowerPC Mac (PPC32/PPC64BE) support, see: | 
					
						
							| 
									
										
										
										
											2019-04-01 16:02:13 -04:00
										 |  |  |             #{Formatter.url("https://github.com/mistydemeo/tigerbrew")} | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |         EOS | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2020-04-30 16:50:13 +10:00
										 |  |  |       abort message | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |     def attempt_directory_creation | 
					
						
							| 
									
										
										
										
											2018-09-25 22:03:29 +01:00
										 |  |  |       Keg::MUST_EXIST_DIRECTORIES.each do |dir| | 
					
						
							| 
									
										
										
										
											2019-10-13 10:03:26 +01:00
										 |  |  |         FileUtils.mkdir_p(dir) unless dir.exist? | 
					
						
							| 
									
										
										
										
											2019-09-17 11:06:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-13 10:03:26 +01:00
										 |  |  |         # Create these files to ensure that these directories aren't removed | 
					
						
							|  |  |  |         # by the Catalina installer. | 
					
						
							|  |  |  |         # (https://github.com/Homebrew/brew/issues/6263) | 
					
						
							|  |  |  |         keep_file = dir/".keepme" | 
					
						
							|  |  |  |         FileUtils.touch(keep_file) unless keep_file.exist? | 
					
						
							|  |  |  |       rescue | 
					
						
							|  |  |  |         nil | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 19:23:31 +00:00
										 |  |  |     def check_cc_argv | 
					
						
							| 
									
										
										
										
											2020-05-03 19:00:36 +05:30
										 |  |  |       return unless Homebrew.args.cc | 
					
						
							| 
									
										
										
										
											2019-01-21 19:23:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       @checks ||= Diagnostic::Checks.new | 
					
						
							|  |  |  |       opoo <<~EOS | 
					
						
							| 
									
										
										
										
											2020-05-03 19:00:36 +05:30
										 |  |  |         You passed `--cc=#{Homebrew.args.cc}`. | 
					
						
							| 
									
										
										
										
											2019-01-21 19:23:31 +00:00
										 |  |  |         #{@checks.please_create_pull_requests} | 
					
						
							|  |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 12:39:44 +00:00
										 |  |  |     def perform_preinstall_checks(all_fatal: false) | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |       check_cpu | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |       attempt_directory_creation | 
					
						
							| 
									
										
										
										
											2019-01-21 12:39:44 +00:00
										 |  |  |       check_cc_argv | 
					
						
							|  |  |  |       diagnostic_checks(:supported_configuration_checks, fatal: all_fatal) | 
					
						
							| 
									
										
										
										
											2019-01-21 19:23:31 +00:00
										 |  |  |       diagnostic_checks(:fatal_preinstall_checks) | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-09-28 14:01:09 -07:00
										 |  |  |     alias generic_perform_preinstall_checks perform_preinstall_checks | 
					
						
							|  |  |  |     module_function :generic_perform_preinstall_checks | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 19:23:31 +00:00
										 |  |  |     def perform_build_from_source_checks(all_fatal: false) | 
					
						
							|  |  |  |       diagnostic_checks(:fatal_build_from_source_checks) | 
					
						
							|  |  |  |       diagnostic_checks(:build_from_source_checks, fatal: all_fatal) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 12:39:44 +00:00
										 |  |  |     def diagnostic_checks(type, fatal: true) | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |       @checks ||= Diagnostic::Checks.new | 
					
						
							| 
									
										
										
										
											2018-07-02 10:25:04 +01:00
										 |  |  |       failed = false | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |       @checks.public_send(type).each do |check| | 
					
						
							|  |  |  |         out = @checks.public_send(check) | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |         next if out.nil? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 12:39:44 +00:00
										 |  |  |         if fatal | 
					
						
							|  |  |  |           failed ||= true | 
					
						
							|  |  |  |           ofail out | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           opoo out | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2019-01-21 12:39:44 +00:00
										 |  |  |       exit 1 if failed && fatal | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2018-09-28 14:01:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | require "extend/os/install" |