| 
									
										
										
										
											2020-11-23 18:45:40 +01:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 01:40:34 +01:00
										 |  |  | raise "#{__FILE__} must not be loaded via `require`." if $PROGRAM_NAME != __FILE__ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-13 18:16:27 +08:00
										 |  |  | old_trap = trap("INT") { exit! 130 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-25 16:29:05 +00:00
										 |  |  | require_relative "global" | 
					
						
							| 
									
										
										
										
											2024-07-14 08:49:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-13 18:16:27 +08:00
										 |  |  | require "fcntl" | 
					
						
							| 
									
										
										
										
											2024-09-27 02:50:37 +01:00
										 |  |  | require "utils/socket" | 
					
						
							| 
									
										
										
										
											2019-12-28 14:48:34 +05:30
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2020-01-13 14:57:15 +00:00
										 |  |  | require "cmd/postinstall" | 
					
						
							| 
									
										
										
										
											2024-07-14 08:49:39 -04:00
										 |  |  | require "json/add/exception" | 
					
						
							| 
									
										
										
										
											2025-08-26 13:02:51 +08:00
										 |  |  | require "extend/pathname/write_mkpath_extension" | 
					
						
							| 
									
										
										
										
											2015-04-13 18:16:27 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | begin | 
					
						
							| 
									
										
										
										
											2025-08-14 19:35:11 +01:00
										 |  |  |   # Undocumented opt-out for internal use. | 
					
						
							|  |  |  |   # We need to allow formulae from paths here due to how we pass them through. | 
					
						
							|  |  |  |   ENV["HOMEBREW_INTERNAL_ALLOW_PACKAGES_FROM_PATHS"] = "1" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 09:53:38 -07:00
										 |  |  |   args = Homebrew::Cmd::Postinstall.new.args | 
					
						
							| 
									
										
										
										
											2024-09-27 02:50:37 +01:00
										 |  |  |   error_pipe = Utils::UNIXSocketExt.open(ENV.fetch("HOMEBREW_ERROR_PIPE"), &:recv_io) | 
					
						
							| 
									
										
										
										
											2015-04-13 18:16:27 +08:00
										 |  |  |   error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   trap("INT", old_trap) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-25 20:27:47 -07:00
										 |  |  |   formula = args.named.to_resolved_formulae.fetch(0) | 
					
						
							| 
									
										
										
										
											2024-07-24 06:16:18 +01:00
										 |  |  |   if args.debug? && !Homebrew::EnvConfig.disable_debrew? | 
					
						
							| 
									
										
										
										
											2023-12-06 00:01:16 +00:00
										 |  |  |     require "debrew" | 
					
						
							|  |  |  |     formula.extend(Debrew::Formula) | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2025-08-26 13:02:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Pathname.prepend WriteMkpathExtension | 
					
						
							| 
									
										
										
										
											2016-05-27 01:53:08 -04:00
										 |  |  |   formula.run_post_install | 
					
						
							| 
									
										
										
										
											2025-09-02 17:00:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-12 16:56:48 +00:00
										 |  |  | # Handle all possible exceptions. | 
					
						
							| 
									
										
										
										
											2017-10-07 00:31:28 +02:00
										 |  |  | rescue Exception => e # rubocop:disable Lint/RescueException | 
					
						
							| 
									
										
										
										
											2025-08-14 19:35:11 +01:00
										 |  |  |   error_pipe&.puts e.to_json | 
					
						
							|  |  |  |   error_pipe&.close | 
					
						
							| 
									
										
										
										
											2015-04-13 18:16:27 +08:00
										 |  |  |   exit! 1
 | 
					
						
							|  |  |  | end |