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"
|
2015-04-13 18:16:27 +08:00
|
|
|
|
|
|
|
begin
|
2024-07-24 05:39:06 +01:00
|
|
|
ENV.delete("HOMEBREW_FORBID_PACKAGES_FROM_PATHS")
|
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)
|
|
|
|
|
2024-04-01 09:53:38 -07:00
|
|
|
formula = T.must(args.named.to_resolved_formulae.first)
|
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
|
2016-05-27 01:53:08 -04:00
|
|
|
formula.run_post_install
|
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
|
2018-08-17 22:42:37 -04:00
|
|
|
error_pipe.puts e.to_json
|
2015-04-13 18:16:27 +08:00
|
|
|
error_pipe.close
|
|
|
|
exit! 1
|
|
|
|
end
|