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"
|
2015-04-13 18:16:27 +08:00
|
|
|
require "debrew"
|
|
|
|
require "fcntl"
|
|
|
|
require "socket"
|
2019-12-28 14:48:34 +05:30
|
|
|
require "cli/parser"
|
2020-01-13 14:57:15 +00:00
|
|
|
require "cmd/postinstall"
|
2015-04-13 18:16:27 +08:00
|
|
|
|
|
|
|
begin
|
2020-07-26 09:45:05 +02:00
|
|
|
args = Homebrew.postinstall_args.parse
|
2020-11-23 18:15:48 +01:00
|
|
|
error_pipe = UNIXSocket.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)
|
|
|
|
|
2023-03-03 18:54:49 -08:00
|
|
|
formula = args.named.to_resolved_formulae.first
|
2020-08-02 14:32:31 +02:00
|
|
|
formula.extend(Debrew::Formula) if args.debug?
|
2016-05-27 01:53:08 -04:00
|
|
|
formula.run_post_install
|
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
|