install: add --only-dependencies option

The traditional approach to installing the dependencies of a formula is
the following:

  brew install `brew deps formula`

This approach ignores any options that are specified in the parent
formula. This pull request adds a --only-dependencies option to brew
install that installs the dependencies of a formula with optional flags,
but returns before installing the parent formula.

Closes Homebrew/homebrew#25272.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Steven Peters 2013-12-16 16:37:59 -08:00 committed by Jack Nagel
parent d03100c615
commit b524943226
5 changed files with 23 additions and 4 deletions

View File

@ -235,6 +235,7 @@ _brew_install ()
--HEAD --HEAD
--ignore-dependencies --ignore-dependencies
--interactive --interactive
--only-dependencies
--verbose --verbose
$(brew options --compact "$prv" 2>/dev/null) $(brew options --compact "$prv" 2>/dev/null)
" "

View File

@ -151,7 +151,7 @@ Note that these flags should only appear after a command.
* `info` <URL>: * `info` <URL>:
Print the name and version that will be detected for <URL>. Print the name and version that will be detected for <URL>.
* `install [--debug] [--env=<std|super>] [--ignore-dependencies] [--fresh] [--cc=<compiler>] [--build-from-source] [--devel|--HEAD]` <formula>: * `install [--debug] [--env=<std|super>] [--ignore-dependencies] [--only-dependencies] [--fresh] [--cc=<compiler>] [--build-from-source] [--devel|--HEAD]` <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
@ -170,6 +170,9 @@ Note that these flags should only appear after a command.
any kind. If they are not already present, the formula will probably fail any kind. If they are not already present, the formula will probably fail
to install. to install.
If `--only-dependencies` is passed, install the dependencies with specified
options but do not install the specified formula.
If `--fresh` is passed, the installation process will not re-use any If `--fresh` is passed, the installation process will not re-use any
options from previous installs. options from previous installs.

View File

@ -102,6 +102,10 @@ module HomebrewArgvExtension
include? '--ignore-dependencies' include? '--ignore-dependencies'
end end
def only_deps?
include? '--only-dependencies'
end
def json def json
value 'json' value 'json'
end end

View File

@ -15,13 +15,14 @@ class FormulaInstaller
include FormulaCellarChecks include FormulaCellarChecks
attr_reader :f attr_reader :f
attr_accessor :tab, :options, :ignore_deps attr_accessor :tab, :options, :ignore_deps, :only_deps
attr_accessor :show_summary_heading, :show_header attr_accessor :show_summary_heading, :show_header
def initialize ff def initialize ff
@f = ff @f = ff
@show_header = false @show_header = false
@ignore_deps = ARGV.ignore_deps? || ARGV.interactive? @ignore_deps = ARGV.ignore_deps? || ARGV.interactive?
@only_deps = ARGV.only_deps?
@options = Options.new @options = Options.new
@tab = Tab.dummy_tab(ff) @tab = Tab.dummy_tab(ff)
@ -105,6 +106,8 @@ class FormulaInstaller
compute_and_install_dependencies unless ignore_deps compute_and_install_dependencies unless ignore_deps
return if only_deps
if ARGV.build_bottle? && (arch = ARGV.bottle_arch) && !Hardware::CPU.optimization_flags.include?(arch) if ARGV.build_bottle? && (arch = ARGV.bottle_arch) && !Hardware::CPU.optimization_flags.include?(arch)
raise "Unrecognized architecture for --bottle-arch: #{arch}" raise "Unrecognized architecture for --bottle-arch: #{arch}"
end end
@ -270,6 +273,7 @@ class FormulaInstaller
fi.tab = dep_tab fi.tab = dep_tab
fi.options = dep_options fi.options = dep_options
fi.ignore_deps = true fi.ignore_deps = true
fi.only_deps = false
fi.show_header = false fi.show_header = false
oh1 "Installing #{f} dependency: #{Tty.green}#{dep}#{Tty.reset}" oh1 "Installing #{f} dependency: #{Tty.green}#{dep}#{Tty.reset}"
outdated_keg.unlink if outdated_keg outdated_keg.unlink if outdated_keg
@ -282,6 +286,8 @@ class FormulaInstaller
end end
def caveats def caveats
return if only_deps
if ARGV.homebrew_developer? and not f.keg_only? if ARGV.homebrew_developer? and not f.keg_only?
audit_bin audit_bin
audit_sbin audit_sbin
@ -299,6 +305,8 @@ class FormulaInstaller
end end
def finish def finish
return if only_deps
ohai 'Finishing up' if ARGV.verbose? ohai 'Finishing up' if ARGV.verbose?
install_plist install_plist

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BREW" "1" "November 2013" "Homebrew" "brew" .TH "BREW" "1" "December 2013" "Homebrew" "brew"
. .
.SH "NAME" .SH "NAME"
\fBbrew\fR \- The missing package manager for OS X \fBbrew\fR \- The missing package manager for OS X
@ -174,7 +174,7 @@ To view formula history locally: \fBbrew log \-p <formula>\fR\.
Print the name and version that will be detected for \fIURL\fR\. Print the name and version that will be detected for \fIURL\fR\.
. .
.TP .TP
\fBinstall [\-\-debug] [\-\-env=<std|super>] [\-\-ignore\-dependencies] [\-\-fresh] [\-\-cc=<compiler>] [\-\-build\-from\-source] [\-\-devel|\-\-HEAD]\fR \fIformula\fR \fBinstall [\-\-debug] [\-\-env=<std|super>] [\-\-ignore\-dependencies] [\-\-only\-dependencies] [\-\-fresh] [\-\-cc=<compiler>] [\-\-build\-from\-source] [\-\-devel|\-\-HEAD]\fR \fIformula\fR
Install \fIformula\fR\. Install \fIformula\fR\.
. .
.IP .IP
@ -193,6 +193,9 @@ If \fB\-\-env=super\fR is passed, use superenv even if the formula specifies the
If \fB\-\-ignore\-dependencies\fR is passed, skip installing any dependencies of any kind\. If they are not already present, the formula will probably fail to install\. If \fB\-\-ignore\-dependencies\fR is passed, skip installing any dependencies of any kind\. If they are not already present, the formula will probably fail to install\.
. .
.IP .IP
If \fB\-\-only\-dependencies\fR is passed, install the dependencies with specified options but do not install the specified formula\.
.
.IP
If \fB\-\-fresh\fR is passed, the installation process will not re\-use any options from previous installs\. If \fB\-\-fresh\fR is passed, the installation process will not re\-use any options from previous installs\.
. .
.IP .IP