 acc9a7ca85
			
		
	
	
		acc9a7ca85
		
	
	
	
	
		
			
			Also enables sandbox for --interactive and --debug use of install and test, using automatic retention. Closes #66. Signed-off-by: Andrew Janke <andrew@apjanke.net>
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require "sandbox"
 | |
| 
 | |
| module Homebrew
 | |
|   def postinstall
 | |
|     ARGV.resolved_formulae.each { |f| run_post_install(f) if f.post_install_defined? }
 | |
|   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)
 | |
| 
 | |
|     if formula.head?
 | |
|       args << "--HEAD"
 | |
|     elsif formula.devel?
 | |
|       args << "--devel"
 | |
|     end
 | |
| 
 | |
|     if Sandbox.available? && ARGV.sandbox?
 | |
|       Sandbox.print_sandbox_message
 | |
|     end
 | |
| 
 | |
|     Utils.safe_fork do
 | |
|       if Sandbox.available? && ARGV.sandbox?
 | |
|         sandbox = Sandbox.new
 | |
|         formula.logs.mkpath
 | |
|         sandbox.record_log(formula.logs/"sandbox.postinstall.log")
 | |
|         sandbox.allow_write_temp_and_cache
 | |
|         sandbox.allow_write_log(formula)
 | |
|         sandbox.allow_write_cellar(formula)
 | |
|         sandbox.allow_write_xcode
 | |
|         sandbox.allow_write_path HOMEBREW_PREFIX
 | |
|         sandbox.deny_write_homebrew_library
 | |
|         sandbox.exec(*args)
 | |
|       else
 | |
|         exec(*args)
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |