Merge pull request #6874 from GauthamGoli/postinstall-args
postinstall: Use CLI::Parser to parse args
This commit is contained in:
commit
a30109769b
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user