postinstall: Use CLI::Parser to parse args

This commit is contained in:
Gautham Goli 2019-12-28 14:48:34 +05:30
parent b7ee5a9239
commit 073685284f
2 changed files with 12 additions and 9 deletions

View File

@ -914,13 +914,7 @@ class FormulaInstaller
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
#{formula.path}
].concat(ARGV.options_only) - ["--HEAD", "--devel"]
if formula.head?
args << "--HEAD"
elsif formula.devel?
args << "--devel"
end
]
Utils.safe_fork do
if Sandbox.formula?(formula)

View File

@ -6,15 +6,24 @@ require "global"
require "debrew"
require "fcntl"
require "socket"
require "cli/parser"
def postinstall_args
Homebrew::CLI::Parser.new do
switch :force
switch :verbose
switch :debug
end
end
begin
postinstall_args.parse
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
trap("INT", old_trap)
formula = ARGV.resolved_formulae.first
formula.extend(Debrew::Formula) if ARGV.debug?
formula = Homebrew.args.resolved_formulae.first
formula.run_post_install
rescue Exception => e # rubocop:disable Lint/RescueException
error_pipe.puts e.to_json