Merge pull request #6874 from GauthamGoli/postinstall-args

postinstall: Use CLI::Parser to parse args
This commit is contained in:
Mike McQuaid 2019-12-28 15:02:10 +00:00 committed by GitHub
commit a30109769b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

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

View File

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