2015-04-13 18:16:27 +08:00
|
|
|
require "sandbox"
|
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2013-09-01 13:56:35 +01:00
|
|
|
def postinstall
|
2015-04-13 18:16:27 +08:00
|
|
|
ARGV.formulae.each { |f| run_post_install(f) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_post_install(formula)
|
|
|
|
args = %W[
|
|
|
|
nice #{RUBY_PATH}
|
|
|
|
-W0
|
|
|
|
-I #{HOMEBREW_LIBRARY_PATH}
|
|
|
|
--
|
|
|
|
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
|
|
|
|
#{formula.path}
|
|
|
|
].concat(ARGV.options_only)
|
|
|
|
|
|
|
|
Utils.safe_fork do
|
|
|
|
if Sandbox.available? && ARGV.sandbox?
|
|
|
|
sandbox = Sandbox.new
|
2015-04-25 22:07:06 -04:00
|
|
|
formula.logs.mkpath
|
|
|
|
sandbox.record_log(formula.logs/"sandbox.postinstall.log")
|
2015-04-13 18:16:27 +08:00
|
|
|
sandbox.allow_write_temp_and_cache
|
|
|
|
sandbox.allow_write_log(formula)
|
|
|
|
sandbox.allow_write_cellar(formula)
|
|
|
|
sandbox.allow_write_path HOMEBREW_PREFIX
|
2015-04-23 12:33:54 +08:00
|
|
|
sandbox.deny_write_homebrew_library
|
2015-04-13 18:16:27 +08:00
|
|
|
sandbox.exec(*args)
|
|
|
|
else
|
|
|
|
exec(*args)
|
|
|
|
end
|
|
|
|
end
|
2013-09-01 13:56:35 +01:00
|
|
|
end
|
|
|
|
end
|