brew/Library/Homebrew/cmd/postinstall.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

#: * `postinstall` <formula>:
#: Rerun the post-install steps for <formula>.
require "sandbox"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
def postinstall
ARGV.resolved_formulae.each do |f|
ohai "Postinstalling #{f}"
run_post_install(f)
end
end
def run_post_install(formula)
args = %W[
nice #{RUBY_PATH}
-W0
-I #{HOMEBREW_LOAD_PATH}
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
#{formula.path}
].concat(ARGV.options_only)
2015-10-10 11:19:22 +08:00
if formula.head?
args << "--HEAD"
elsif formula.devel?
args << "--devel"
end
Utils.safe_fork do
if Sandbox.formula?(formula)
sandbox = Sandbox.new
2015-04-25 22:07:06 -04:00
formula.logs.mkpath
2016-05-27 01:53:08 -04:00
sandbox.record_log(formula.logs/"postinstall.sandbox.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(formula)
sandbox.allow_write_xcode
sandbox.deny_write_homebrew_repository
sandbox.allow_write_cellar(formula)
Keg::TOP_LEVEL_DIRECTORIES.each do |dir|
sandbox.allow_write_path "#{HOMEBREW_PREFIX}/#{dir}"
end
sandbox.exec(*args)
else
exec(*args)
end
end
end
end