mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
brew test, install, update-test: add --keep-tmp option
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>
This commit is contained in:
parent
0e8140b012
commit
acc9a7ca85
@ -105,7 +105,8 @@ class Build
|
|||||||
|
|
||||||
formula.extend(Debrew::Formula) if ARGV.debug?
|
formula.extend(Debrew::Formula) if ARGV.debug?
|
||||||
|
|
||||||
formula.brew do
|
formula.brew do |_formula, staging|
|
||||||
|
staging.retain! if ARGV.keep_tmp?
|
||||||
formula.patch
|
formula.patch
|
||||||
|
|
||||||
if ARGV.git?
|
if ARGV.git?
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#: * `install` [`--debug`] [`--env=`<std>|<super>] [`--ignore-dependencies`] [`--only-dependencies`] [`--cc=`<compiler>] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] <formula>:
|
#: * `install` [`--debug`] [`--env=`<std>|<super>] [`--ignore-dependencies`] [`--only-dependencies`] [`--cc=`<compiler>] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] [`--keep-tmp`] <formula>:
|
||||||
#: Install <formula>.
|
#: Install <formula>.
|
||||||
#:
|
#:
|
||||||
#: <formula> is usually the name of the formula to install, but it can be specified
|
#: <formula> is usually the name of the formula to install, but it can be specified
|
||||||
@ -35,6 +35,9 @@
|
|||||||
#: If `--HEAD` is passed, and <formula> defines it, install the HEAD version,
|
#: If `--HEAD` is passed, and <formula> defines it, install the HEAD version,
|
||||||
#: aka master, trunk, unstable.
|
#: aka master, trunk, unstable.
|
||||||
#:
|
#:
|
||||||
|
#: If `--keep-tmp` is passed, the temporary files created for the test are
|
||||||
|
#: not deleted.
|
||||||
|
#:
|
||||||
#: To install a newer version of HEAD use
|
#: To install a newer version of HEAD use
|
||||||
#: `brew rm <foo> && brew install --HEAD <foo>`.
|
#: `brew rm <foo> && brew install --HEAD <foo>`.
|
||||||
#:
|
#:
|
||||||
|
@ -22,15 +22,11 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
if Sandbox.auto_disable?
|
Sandbox.print_sandbox_message
|
||||||
Sandbox.print_autodisable_warning
|
|
||||||
else
|
|
||||||
Sandbox.print_sandbox_message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox? && !Sandbox.auto_disable?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
formula.logs.mkpath
|
formula.logs.mkpath
|
||||||
sandbox.record_log(formula.logs/"sandbox.postinstall.log")
|
sandbox.record_log(formula.logs/"sandbox.postinstall.log")
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
# --verbose: Print test step output in realtime. Has the side effect of passing output
|
# --verbose: Print test step output in realtime. Has the side effect of passing output
|
||||||
# as raw bytes instead of re-encoding in UTF-8.
|
# as raw bytes instead of re-encoding in UTF-8.
|
||||||
# --fast: Don't install any packages, but run e.g. audit anyway.
|
# --fast: Don't install any packages, but run e.g. audit anyway.
|
||||||
|
# --keep-tmp: Keep temporary files written by main installs and tests that are run.
|
||||||
#
|
#
|
||||||
# --ci-master: Shortcut for Homebrew master branch CI options.
|
# --ci-master: Shortcut for Homebrew master branch CI options.
|
||||||
# --ci-pr: Shortcut for Homebrew pull request CI options.
|
# --ci-pr: Shortcut for Homebrew pull request CI options.
|
||||||
@ -532,7 +533,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
test "brew", "fetch", "--retry", *fetch_args
|
test "brew", "fetch", "--retry", *fetch_args
|
||||||
test "brew", "uninstall", "--force", formula_name if formula.installed?
|
test "brew", "uninstall", "--force", formula_name if formula.installed?
|
||||||
install_args = ["--verbose"]
|
|
||||||
|
# shared_*_args are applied to both the main and --devel spec
|
||||||
|
shared_install_args = ["--verbose"]
|
||||||
|
shared_install_args << "--keep-tmp" if ARGV.keep_tmp?
|
||||||
|
# install_args is just for the main (stable, or devel if in a devel-only tap) spec
|
||||||
|
install_args = []
|
||||||
install_args << "--build-bottle" if !ARGV.include?("--fast") && !ARGV.include?("--no-bottle") && !formula.bottle_disabled?
|
install_args << "--build-bottle" if !ARGV.include?("--fast") && !ARGV.include?("--no-bottle") && !formula.bottle_disabled?
|
||||||
install_args << "--HEAD" if ARGV.include? "--HEAD"
|
install_args << "--HEAD" if ARGV.include? "--HEAD"
|
||||||
|
|
||||||
@ -548,6 +554,7 @@ module Homebrew
|
|||||||
formula_bottled = formula.bottled?
|
formula_bottled = formula.bottled?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
install_args.concat(shared_install_args)
|
||||||
install_args << formula_name
|
install_args << formula_name
|
||||||
# Don't care about e.g. bottle failures for dependencies.
|
# Don't care about e.g. bottle failures for dependencies.
|
||||||
install_passed = false
|
install_passed = false
|
||||||
@ -582,7 +589,9 @@ module Homebrew
|
|||||||
test "brew", "install", bottle_filename
|
test "brew", "install", bottle_filename
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
test "brew", "test", "--verbose", formula_name if formula.test_defined?
|
shared_test_args = ["--verbose"]
|
||||||
|
shared_test_args << "--keep-tmp" if ARGV.keep_tmp?
|
||||||
|
test "brew", "test", formula_name, *shared_test_args if formula.test_defined?
|
||||||
testable_dependents.each do |dependent|
|
testable_dependents.each do |dependent|
|
||||||
unless dependent.installed?
|
unless dependent.installed?
|
||||||
test "brew", "fetch", "--retry", dependent.name
|
test "brew", "fetch", "--retry", dependent.name
|
||||||
@ -607,11 +616,13 @@ module Homebrew
|
|||||||
&& !ARGV.include?("--HEAD") && !ARGV.include?("--fast") \
|
&& !ARGV.include?("--HEAD") && !ARGV.include?("--fast") \
|
||||||
&& satisfied_requirements?(formula, :devel)
|
&& satisfied_requirements?(formula, :devel)
|
||||||
test "brew", "fetch", "--retry", "--devel", *fetch_args
|
test "brew", "fetch", "--retry", "--devel", *fetch_args
|
||||||
run_as_not_developer { test "brew", "install", "--devel", "--verbose", formula_name }
|
run_as_not_developer do
|
||||||
|
test "brew", "install", "--devel", formula_name, *shared_install_args
|
||||||
|
end
|
||||||
devel_install_passed = steps.last.passed?
|
devel_install_passed = steps.last.passed?
|
||||||
test "brew", "audit", "--devel", *audit_args
|
test "brew", "audit", "--devel", *audit_args
|
||||||
if devel_install_passed
|
if devel_install_passed
|
||||||
test "brew", "test", "--devel", "--verbose", formula_name if formula.test_defined?
|
test "brew", "test", "--devel", formula_name, *shared_test_args if formula.test_defined?
|
||||||
test "brew", "uninstall", "--devel", "--force", formula_name
|
test "brew", "uninstall", "--devel", "--force", formula_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#: * `test` [`--devel`|`--HEAD`] [`--debug`] <formula>:
|
#: * `test` [`--devel`|`--HEAD`] [`--debug`] [`--keep-tmp`] <formula>:
|
||||||
#: A few formulae provide a test method. `brew test` <formula> runs this
|
#: A few formulae provide a test method. `brew test` <formula> runs this
|
||||||
#: test method. There is no standard output or return code, but it should
|
#: test method. There is no standard output or return code, but it should
|
||||||
#: generally indicate to the user if something is wrong with the installed
|
#: generally indicate to the user if something is wrong with the installed
|
||||||
@ -10,6 +10,9 @@
|
|||||||
#: If `--debug` is passed and the test fails, an interactive debugger will be
|
#: If `--debug` is passed and the test fails, an interactive debugger will be
|
||||||
#: launched with access to IRB or a shell inside the temporary test directory.
|
#: launched with access to IRB or a shell inside the temporary test directory.
|
||||||
#:
|
#:
|
||||||
|
#: If `--keep-tmp` is passed, the temporary files created for the test are
|
||||||
|
#: not deleted.
|
||||||
|
#:
|
||||||
#: Example: `brew install jruby && brew test jruby`
|
#: Example: `brew install jruby && brew test jruby`
|
||||||
|
|
||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
@ -55,15 +58,11 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Sandbox.available? && !ARGV.no_sandbox?
|
if Sandbox.available? && !ARGV.no_sandbox?
|
||||||
if Sandbox.auto_disable?
|
Sandbox.print_sandbox_message
|
||||||
Sandbox.print_autodisable_warning
|
|
||||||
else
|
|
||||||
Sandbox.print_sandbox_message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && !ARGV.no_sandbox? && !Sandbox.auto_disable?
|
if Sandbox.available? && !ARGV.no_sandbox?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
f.logs.mkpath
|
f.logs.mkpath
|
||||||
sandbox.record_log(f.logs/"sandbox.test.log")
|
sandbox.record_log(f.logs/"sandbox.test.log")
|
||||||
|
@ -5,6 +5,8 @@ module Homebrew
|
|||||||
# brew update-test --commit=<sha1> # using <sha1> as start commit
|
# brew update-test --commit=<sha1> # using <sha1> as start commit
|
||||||
# brew update-test --before=<date> # using commit at <date> as start commit
|
# brew update-test --before=<date> # using commit at <date> as start commit
|
||||||
#
|
#
|
||||||
|
# Options:
|
||||||
|
# --keep-tmp Retain temporary directory containing the new clone
|
||||||
def update_test
|
def update_test
|
||||||
cd HOMEBREW_REPOSITORY
|
cd HOMEBREW_REPOSITORY
|
||||||
start_sha1 = if commit = ARGV.value("commit")
|
start_sha1 = if commit = ARGV.value("commit")
|
||||||
@ -19,7 +21,8 @@ module Homebrew
|
|||||||
puts "Start commit: #{start_sha1}"
|
puts "Start commit: #{start_sha1}"
|
||||||
puts "End commit: #{end_sha1}"
|
puts "End commit: #{end_sha1}"
|
||||||
|
|
||||||
mktemp do
|
mktemp("update-test") do |staging|
|
||||||
|
staging.retain! if ARGV.keep_tmp?
|
||||||
curdir = Pathname.new(Dir.pwd)
|
curdir = Pathname.new(Dir.pwd)
|
||||||
|
|
||||||
oh1 "Setup test environment..."
|
oh1 "Setup test environment..."
|
||||||
|
@ -17,7 +17,9 @@ class AbstractDownloadStrategy
|
|||||||
def fetch
|
def fetch
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unpack {#cached_location} into the current working directory.
|
# Unpack {#cached_location} into the current working directory, and possibly
|
||||||
|
# chdir into the newly-unpacked directory.
|
||||||
|
# Unlike {Resource#stage}, this does not take a block.
|
||||||
def stage
|
def stage
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -120,6 +120,10 @@ module HomebrewArgvExtension
|
|||||||
include?("--dry-run") || switch?("n")
|
include?("--dry-run") || switch?("n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def keep_tmp?
|
||||||
|
include? "--keep-tmp"
|
||||||
|
end
|
||||||
|
|
||||||
def git?
|
def git?
|
||||||
flag? "--git"
|
flag? "--git"
|
||||||
end
|
end
|
||||||
|
@ -6,43 +6,84 @@ require "etc"
|
|||||||
# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API
|
# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API
|
||||||
module FileUtils
|
module FileUtils
|
||||||
# Create a temporary directory then yield. When the block returns,
|
# Create a temporary directory then yield. When the block returns,
|
||||||
# recursively delete the temporary directory.
|
# recursively delete the temporary directory. Passing opts[:retain]
|
||||||
def mktemp(prefix = name)
|
# or calling `do |staging| ... staging.retain!` in the block will skip
|
||||||
prev = pwd
|
# the deletion and retain the temporary directory's contents.
|
||||||
tmp = Dir.mktmpdir(prefix, HOMEBREW_TEMP)
|
def mktemp(prefix = name, opts = {})
|
||||||
|
Mktemp.new(prefix, opts).run do |staging|
|
||||||
# Make sure files inside the temporary directory have the same group as the
|
yield staging
|
||||||
# brew instance.
|
|
||||||
#
|
|
||||||
# Reference from `man 2 open`
|
|
||||||
# > When a new file is created, it is given the group of the directory which
|
|
||||||
# contains it.
|
|
||||||
group_id = if HOMEBREW_BREW_FILE.grpowned?
|
|
||||||
HOMEBREW_BREW_FILE.stat.gid
|
|
||||||
else
|
|
||||||
Process.gid
|
|
||||||
end
|
|
||||||
begin
|
|
||||||
# group_id.to_s makes OS X 10.6.7 (ruby-1.8.7-p174) and earlier happy.
|
|
||||||
chown(nil, group_id.to_s, tmp)
|
|
||||||
rescue Errno::EPERM
|
|
||||||
opoo "Failed setting group \"#{Etc.getgrgid(group_id).name}\" on #{tmp}"
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
cd(tmp)
|
|
||||||
|
|
||||||
begin
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
cd(prev)
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
ignore_interrupts { rm_rf(tmp) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function :mktemp
|
module_function :mktemp
|
||||||
|
|
||||||
|
# Performs mktemp's functionality, and tracks the results.
|
||||||
|
# Each instance is only intended to be used once.
|
||||||
|
class Mktemp
|
||||||
|
include FileUtils
|
||||||
|
|
||||||
|
# Path to the tmpdir used in this run, as a Pathname.
|
||||||
|
attr_reader :tmpdir
|
||||||
|
|
||||||
|
def initialize(prefix = name, opts = {})
|
||||||
|
@prefix = prefix
|
||||||
|
@retain = opts[:retain]
|
||||||
|
@quiet = false
|
||||||
|
end
|
||||||
|
|
||||||
|
# Instructs this Mktemp to retain the staged files
|
||||||
|
def retain!
|
||||||
|
@retain = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# True if the staged temporary files should be retained
|
||||||
|
def retain?
|
||||||
|
@retain
|
||||||
|
end
|
||||||
|
|
||||||
|
# Instructs this Mktemp to not emit messages when retention is triggered
|
||||||
|
def quiet!
|
||||||
|
@quiet = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"[Mktemp: #{tmpdir} retain=#{@retain} quiet=#{@quiet}]"
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
@tmpdir = Pathname.new(Dir.mktmpdir("#{@prefix}-", HOMEBREW_TEMP))
|
||||||
|
|
||||||
|
# Make sure files inside the temporary directory have the same group as the
|
||||||
|
# brew instance.
|
||||||
|
#
|
||||||
|
# Reference from `man 2 open`
|
||||||
|
# > When a new file is created, it is given the group of the directory which
|
||||||
|
# contains it.
|
||||||
|
group_id = if HOMEBREW_BREW_FILE.grpowned?
|
||||||
|
HOMEBREW_BREW_FILE.stat.gid
|
||||||
|
else
|
||||||
|
Process.gid
|
||||||
|
end
|
||||||
|
begin
|
||||||
|
# group_id.to_s makes OS X 10.6.7 (ruby-1.8.7-p174) and earlier happy.
|
||||||
|
chown(nil, group_id.to_s, tmpdir)
|
||||||
|
rescue Errno::EPERM
|
||||||
|
opoo "Failed setting group \"#{Etc.getgrgid(group_id).name}\" on #{tmp}"
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
Dir.chdir(tmpdir) { yield self }
|
||||||
|
ensure
|
||||||
|
ignore_interrupts { rm_rf(tmpdir) } unless retain?
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
if retain? && !@tmpdir.nil? && !@quiet
|
||||||
|
ohai "Kept temporary files"
|
||||||
|
puts "Temporary files retained at #{@tmpdir}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
alias_method :old_mkdir, :mkdir
|
alias_method :old_mkdir, :mkdir
|
||||||
|
|
||||||
|
@ -920,14 +920,19 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# yields self with current working directory set to the uncompressed tarball
|
# yields |self,staging| with current working directory set to the uncompressed tarball
|
||||||
|
# where staging is a Mktemp staging context
|
||||||
# @private
|
# @private
|
||||||
def brew
|
def brew
|
||||||
stage do
|
stage do |staging|
|
||||||
|
staging.retain! if ARGV.keep_tmp?
|
||||||
prepare_patches
|
prepare_patches
|
||||||
|
|
||||||
begin
|
begin
|
||||||
yield self
|
yield self, staging
|
||||||
|
rescue StandardError
|
||||||
|
staging.retain! if ARGV.interactive? || ARGV.debug?
|
||||||
|
raise
|
||||||
ensure
|
ensure
|
||||||
cp Dir["config.log", "CMakeCache.txt"], logs
|
cp Dir["config.log", "CMakeCache.txt"], logs
|
||||||
end
|
end
|
||||||
@ -1320,11 +1325,17 @@ class Formula
|
|||||||
def run_test
|
def run_test
|
||||||
old_home = ENV["HOME"]
|
old_home = ENV["HOME"]
|
||||||
build, self.build = self.build, Tab.for_formula(self)
|
build, self.build = self.build, Tab.for_formula(self)
|
||||||
mktemp do
|
mktemp("#{name}-test") do |staging|
|
||||||
@testpath = Pathname.pwd
|
staging.retain! if ARGV.keep_tmp?
|
||||||
|
@testpath = staging.tmpdir
|
||||||
ENV["HOME"] = @testpath
|
ENV["HOME"] = @testpath
|
||||||
setup_home @testpath
|
setup_home @testpath
|
||||||
test
|
begin
|
||||||
|
test
|
||||||
|
rescue Exception
|
||||||
|
staging.retain! if ARGV.debug?
|
||||||
|
raise
|
||||||
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
@testpath = nil
|
@testpath = nil
|
||||||
@ -1537,7 +1548,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
active_spec.stage do
|
active_spec.stage do |_resource, staging|
|
||||||
@source_modified_time = active_spec.source_modified_time
|
@source_modified_time = active_spec.source_modified_time
|
||||||
@buildpath = Pathname.pwd
|
@buildpath = Pathname.pwd
|
||||||
env_home = buildpath/".brew_home"
|
env_home = buildpath/".brew_home"
|
||||||
@ -1547,7 +1558,7 @@ class Formula
|
|||||||
setup_home env_home
|
setup_home env_home
|
||||||
|
|
||||||
begin
|
begin
|
||||||
yield
|
yield staging
|
||||||
ensure
|
ensure
|
||||||
@buildpath = nil
|
@buildpath = nil
|
||||||
ENV["HOME"] = old_home
|
ENV["HOME"] = old_home
|
||||||
|
@ -523,6 +523,7 @@ class FormulaInstaller
|
|||||||
args << "--debug" if debug?
|
args << "--debug" if debug?
|
||||||
args << "--cc=#{ARGV.cc}" if ARGV.cc
|
args << "--cc=#{ARGV.cc}" if ARGV.cc
|
||||||
args << "--default-fortran-flags" if ARGV.include? "--default-fortran-flags"
|
args << "--default-fortran-flags" if ARGV.include? "--default-fortran-flags"
|
||||||
|
args << "--keep-tmp" if ARGV.keep_tmp?
|
||||||
|
|
||||||
if ARGV.env
|
if ARGV.env
|
||||||
args << "--env=#{ARGV.env}"
|
args << "--env=#{ARGV.env}"
|
||||||
@ -567,18 +568,14 @@ class FormulaInstaller
|
|||||||
].concat(build_argv)
|
].concat(build_argv)
|
||||||
|
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
if Sandbox.auto_disable?
|
Sandbox.print_sandbox_message
|
||||||
Sandbox.print_autodisable_warning
|
|
||||||
else
|
|
||||||
Sandbox.print_sandbox_message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
# Invalidate the current sudo timestamp in case a build script calls sudo
|
# Invalidate the current sudo timestamp in case a build script calls sudo
|
||||||
system "/usr/bin/sudo", "-k"
|
system "/usr/bin/sudo", "-k"
|
||||||
|
|
||||||
if Sandbox.available? && ARGV.sandbox? && !Sandbox.auto_disable?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
formula.logs.mkpath
|
formula.logs.mkpath
|
||||||
sandbox.record_log(formula.logs/"sandbox.build.log")
|
sandbox.record_log(formula.logs/"sandbox.build.log")
|
||||||
|
@ -72,6 +72,10 @@ class Resource
|
|||||||
downloader.clear_cache
|
downloader.clear_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Verifies download and unpacks it
|
||||||
|
# The block may call `|resource,staging| staging.retain!` to retain the staging
|
||||||
|
# directory. Subclasses that override stage should implement the tmp
|
||||||
|
# dir using FileUtils.mktemp so that works with all subtypes.
|
||||||
def stage(target = nil, &block)
|
def stage(target = nil, &block)
|
||||||
unless target || block
|
unless target || block
|
||||||
raise ArgumentError, "target directory or block is required"
|
raise ArgumentError, "target directory or block is required"
|
||||||
@ -81,15 +85,16 @@ class Resource
|
|||||||
unpack(target, &block)
|
unpack(target, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# If a target is given, unpack there; else unpack to a temp folder
|
# If a target is given, unpack there; else unpack to a temp folder.
|
||||||
# If block is given, yield to that block
|
# If block is given, yield to that block with |self, staging|, where staging
|
||||||
# A target or a block must be given, but not both
|
# is a staging context that responds to retain!().
|
||||||
|
# A target or a block must be given, but not both.
|
||||||
def unpack(target = nil)
|
def unpack(target = nil)
|
||||||
mktemp(download_name) do
|
mktemp(download_name) do |staging|
|
||||||
downloader.stage
|
downloader.stage
|
||||||
@source_modified_time = downloader.source_modified_time
|
@source_modified_time = downloader.source_modified_time
|
||||||
if block_given?
|
if block_given?
|
||||||
yield self
|
yield self, staging
|
||||||
elsif target
|
elsif target
|
||||||
target = Pathname.new(target) unless target.is_a? Pathname
|
target = Pathname.new(target) unless target.is_a? Pathname
|
||||||
target.install Dir["*"]
|
target.install Dir["*"]
|
||||||
|
@ -8,18 +8,6 @@ class Sandbox
|
|||||||
OS.mac? && File.executable?(SANDBOX_EXEC)
|
OS.mac? && File.executable?(SANDBOX_EXEC)
|
||||||
end
|
end
|
||||||
|
|
||||||
# there are times the sandbox cannot be used.
|
|
||||||
def self.auto_disable?
|
|
||||||
@auto_disable ||= ARGV.interactive? || ARGV.debug?
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.print_autodisable_warning
|
|
||||||
unless @printed_autodisable_warning
|
|
||||||
opoo "The sandbox cannot be used in debug or interactive mode."
|
|
||||||
@printed_autodisable_warning = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.print_sandbox_message
|
def self.print_sandbox_message
|
||||||
unless @printed_sandbox_message
|
unless @printed_sandbox_message
|
||||||
ohai "Using the sandbox"
|
ohai "Using the sandbox"
|
||||||
|
@ -122,7 +122,7 @@ class PatchingTests < Homebrew::TestCase
|
|||||||
url PATCH_URL_A
|
url PATCH_URL_A
|
||||||
sha256 PATCH_A_SHA256
|
sha256 PATCH_A_SHA256
|
||||||
end
|
end
|
||||||
end.brew(&:patch)
|
end.brew { |f, _staging| f.patch }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -136,7 +136,7 @@ class PatchingTests < Homebrew::TestCase
|
|||||||
sha256 TESTBALL_PATCHES_SHA256
|
sha256 TESTBALL_PATCHES_SHA256
|
||||||
apply APPLY_A
|
apply APPLY_A
|
||||||
end
|
end
|
||||||
end.brew(&:patch)
|
end.brew { |f, _staging| f.patch }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -234,7 +234,7 @@ class PatchingTests < Homebrew::TestCase
|
|||||||
sha256 TESTBALL_PATCHES_SHA256
|
sha256 TESTBALL_PATCHES_SHA256
|
||||||
apply "patches/#{APPLY_A}"
|
apply "patches/#{APPLY_A}"
|
||||||
end
|
end
|
||||||
end.brew(&:patch)
|
end.brew { |f, _staging| f.patch }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -172,8 +172,7 @@ def interactive_shell(f = nil)
|
|||||||
if $?.success?
|
if $?.success?
|
||||||
return
|
return
|
||||||
elsif $?.exited?
|
elsif $?.exited?
|
||||||
puts "Aborting due to non-zero exit status"
|
raise "Aborted due to non-zero exit status (#{$?.exitstatus})"
|
||||||
exit $?.exitstatus
|
|
||||||
else
|
else
|
||||||
raise $?.inspect
|
raise $?.inspect
|
||||||
end
|
end
|
||||||
|
@ -155,7 +155,7 @@ information on all installed formulae.</p>
|
|||||||
|
|
||||||
<p>See the docs for examples of using the JSON:
|
<p>See the docs for examples of using the JSON:
|
||||||
<a href="https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Querying-Brew.md" data-bare-link="true">https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Querying-Brew.md</a></p></dd>
|
<a href="https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Querying-Brew.md" data-bare-link="true">https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Querying-Brew.md</a></p></dd>
|
||||||
<dt><code>install</code> [<code>--debug</code>] [<code>--env=</code><var>std</var>|<var>super</var>] [<code>--ignore-dependencies</code>] [<code>--only-dependencies</code>] [<code>--cc=</code><var>compiler</var>] [<code>--build-from-source</code>|<code>--force-bottle</code>] [<code>--devel</code>|<code>--HEAD</code>] <var>formula</var></dt><dd><p>Install <var>formula</var>.</p>
|
<dt><code>install</code> [<code>--debug</code>] [<code>--env=</code><var>std</var>|<var>super</var>] [<code>--ignore-dependencies</code>] [<code>--only-dependencies</code>] [<code>--cc=</code><var>compiler</var>] [<code>--build-from-source</code>|<code>--force-bottle</code>] [<code>--devel</code>|<code>--HEAD</code>] [<code>--keep-tmp</code>] <var>formula</var></dt><dd><p>Install <var>formula</var>.</p>
|
||||||
|
|
||||||
<p><var>formula</var> is usually the name of the formula to install, but it can be specified
|
<p><var>formula</var> is usually the name of the formula to install, but it can be specified
|
||||||
several different ways. See <a href="#SPECIFYING-FORMULAE" title="SPECIFYING FORMULAE" data-bare-link="true">SPECIFYING FORMULAE</a>.</p>
|
several different ways. See <a href="#SPECIFYING-FORMULAE" title="SPECIFYING FORMULAE" data-bare-link="true">SPECIFYING FORMULAE</a>.</p>
|
||||||
@ -191,6 +191,9 @@ for the current version of OS X, even if custom options are given.</p>
|
|||||||
<p>If <code>--HEAD</code> is passed, and <var>formula</var> defines it, install the HEAD version,
|
<p>If <code>--HEAD</code> is passed, and <var>formula</var> defines it, install the HEAD version,
|
||||||
aka master, trunk, unstable.</p>
|
aka master, trunk, unstable.</p>
|
||||||
|
|
||||||
|
<p>If <code>--keep-tmp</code> is passed, the temporary files created for the test are
|
||||||
|
not deleted.</p>
|
||||||
|
|
||||||
<p>To install a newer version of HEAD use
|
<p>To install a newer version of HEAD use
|
||||||
<code>brew rm <foo> && brew install --HEAD <foo></code>.</p></dd>
|
<code>brew rm <foo> && brew install --HEAD <foo></code>.</p></dd>
|
||||||
<dt><code>install</code> <code>--interactive</code> [<code>--git</code>] <var>formula</var></dt><dd><p>Download and patch <var>formula</var>, then open a shell. This allows the user to
|
<dt><code>install</code> <code>--interactive</code> [<code>--git</code>] <var>formula</var></dt><dd><p>Download and patch <var>formula</var>, then open a shell. This allows the user to
|
||||||
@ -321,7 +324,7 @@ for <var>version</var> is <code>v1</code>.</p>
|
|||||||
<dt><code>tap-pin</code> <var>tap</var></dt><dd><p>Pin <var>tap</var>, prioritizing its formulae over core when formula names are supplied
|
<dt><code>tap-pin</code> <var>tap</var></dt><dd><p>Pin <var>tap</var>, prioritizing its formulae over core when formula names are supplied
|
||||||
by the user. See also <code>tap-unpin</code>.</p></dd>
|
by the user. See also <code>tap-unpin</code>.</p></dd>
|
||||||
<dt><code>tap-unpin</code> <var>tap</var></dt><dd><p>Unpin <var>tap</var> so its formulae are no longer prioritized. See also <code>tap-pin</code>.</p></dd>
|
<dt><code>tap-unpin</code> <var>tap</var></dt><dd><p>Unpin <var>tap</var> so its formulae are no longer prioritized. See also <code>tap-pin</code>.</p></dd>
|
||||||
<dt><code>test</code> [<code>--devel</code>|<code>--HEAD</code>] [<code>--debug</code>] <var>formula</var></dt><dd><p>A few formulae provide a test method. <code>brew test</code> <var>formula</var> runs this
|
<dt><code>test</code> [<code>--devel</code>|<code>--HEAD</code>] [<code>--debug</code>] [<code>--keep-tmp</code>] <var>formula</var></dt><dd><p>A few formulae provide a test method. <code>brew test</code> <var>formula</var> runs this
|
||||||
test method. There is no standard output or return code, but it should
|
test method. There is no standard output or return code, but it should
|
||||||
generally indicate to the user if something is wrong with the installed
|
generally indicate to the user if something is wrong with the installed
|
||||||
formula.</p>
|
formula.</p>
|
||||||
@ -332,6 +335,9 @@ formula.</p>
|
|||||||
<p>If <code>--debug</code> is passed and the test fails, an interactive debugger will be
|
<p>If <code>--debug</code> is passed and the test fails, an interactive debugger will be
|
||||||
launched with access to IRB or a shell inside the temporary test directory.</p>
|
launched with access to IRB or a shell inside the temporary test directory.</p>
|
||||||
|
|
||||||
|
<p>If <code>--keep-tmp</code> is passed, the temporary files created for the test are
|
||||||
|
not deleted.</p>
|
||||||
|
|
||||||
<p>Example: <code>brew install jruby && brew test jruby</code></p></dd>
|
<p>Example: <code>brew install jruby && brew test jruby</code></p></dd>
|
||||||
<dt><code>uninstall</code>, <code>rm</code>, <code>remove</code> [<code>--force</code>] <var>formula</var></dt><dd><p>Uninstall <var>formula</var>.</p>
|
<dt><code>uninstall</code>, <code>rm</code>, <code>remove</code> [<code>--force</code>] <var>formula</var></dt><dd><p>Uninstall <var>formula</var>.</p>
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to
|
|||||||
See the docs for examples of using the JSON: \fIhttps://github\.com/Homebrew/brew/blob/master/share/doc/homebrew/Querying\-Brew\.md\fR
|
See the docs for examples of using the JSON: \fIhttps://github\.com/Homebrew/brew/blob/master/share/doc/homebrew/Querying\-Brew\.md\fR
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR\fIstd\fR|\fIsuper\fR] [\fB\-\-ignore\-dependencies\fR] [\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR|\fB\-\-force\-bottle\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] \fIformula\fR
|
\fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR\fIstd\fR|\fIsuper\fR] [\fB\-\-ignore\-dependencies\fR] [\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR|\fB\-\-force\-bottle\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR
|
||||||
Install \fIformula\fR\.
|
Install \fIformula\fR\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
@ -251,6 +251,9 @@ If \fB\-\-devel\fR is passed, and \fIformula\fR defines it, install the developm
|
|||||||
If \fB\-\-HEAD\fR is passed, and \fIformula\fR defines it, install the HEAD version, aka master, trunk, unstable\.
|
If \fB\-\-HEAD\fR is passed, and \fIformula\fR defines it, install the HEAD version, aka master, trunk, unstable\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are not deleted\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
To install a newer version of HEAD use \fBbrew rm <foo> && brew install \-\-HEAD <foo>\fR\.
|
To install a newer version of HEAD use \fBbrew rm <foo> && brew install \-\-HEAD <foo>\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
@ -449,7 +452,7 @@ Pin \fItap\fR, prioritizing its formulae over core when formula names are suppli
|
|||||||
Unpin \fItap\fR so its formulae are no longer prioritized\. See also \fBtap\-pin\fR\.
|
Unpin \fItap\fR so its formulae are no longer prioritized\. See also \fBtap\-pin\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBtest\fR [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-debug\fR] \fIformula\fR
|
\fBtest\fR [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-debug\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR
|
||||||
A few formulae provide a test method\. \fBbrew test\fR \fIformula\fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\.
|
A few formulae provide a test method\. \fBbrew test\fR \fIformula\fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
@ -459,6 +462,9 @@ To test the development or head version of a formula, use \fB\-\-devel\fR or \fB
|
|||||||
If \fB\-\-debug\fR is passed and the test fails, an interactive debugger will be launched with access to IRB or a shell inside the temporary test directory\.
|
If \fB\-\-debug\fR is passed and the test fails, an interactive debugger will be launched with access to IRB or a shell inside the temporary test directory\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are not deleted\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
Example: \fBbrew install jruby && brew test jruby\fR
|
Example: \fBbrew install jruby && brew test jruby\fR
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user