Add --fresh option to brew install

When invoked, this option will ensure brew doesn't re-use any options from
previous installs of a formula.
This commit is contained in:
Charlie Sharpsteen 2011-11-14 10:44:18 -08:00
parent 8ec2d8e043
commit 33a61d1897
4 changed files with 26 additions and 9 deletions

View File

@ -127,7 +127,7 @@ _brew_to_completion()
local opts=$( local opts=$(
local opts=(--force --verbose --debug --use-clang --use-gcc local opts=(--force --verbose --debug --use-clang --use-gcc
--use-llvm --ignore-dependencies --build-from-source --HEAD --use-llvm --ignore-dependencies --build-from-source --HEAD
--interactive $(brew options --compact "$prev")) --interactive --fresh $(brew options --compact "$prev"))
# options that make sense with '--interactive' # options that make sense with '--interactive'
if [[ "${COMP_WORDS[*]}" =~ "--interactive" ]]; then if [[ "${COMP_WORDS[*]}" =~ "--interactive" ]]; then

View File

@ -135,7 +135,7 @@ For the full command list, see the COMMANDS section.
* `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 [--force] [--debug] [--ignore-dependencies] [--use-clang] [--use-gcc] [--use-llvm] [--build-from-source] [--HEAD]` <formula>: * `install [--force] [--debug] [--ignore-dependencies] [--fresh] [--use-clang] [--use-gcc] [--use-llvm] [--build-from-source] [--HEAD]` <formula>:
Install <formula>. Install <formula>.
<formula> is usually the name of the formula to install, but may also be <formula> is usually the name of the formula to install, but may also be
@ -152,6 +152,9 @@ For the full command list, see the COMMANDS section.
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 `--fresh` is passed, the installation process will not re-use any
options from previous installs.
If `--use-clang` is passed, attempt to compile using clang. If `--use-clang` is passed, attempt to compile using clang.
If `--use-gcc` is passed, attempt to compile using GCC. This is useful for If `--use-gcc` is passed, attempt to compile using GCC. This is useful for

View File

@ -245,8 +245,9 @@ class FormulaInstaller
# This method gives us a chance to pre-process command line arguments before the # This method gives us a chance to pre-process command line arguments before the
# installer forks and `Formula.install` kicks in. # installer forks and `Formula.install` kicks in.
def filtered_args def filtered_args
# Did the user actually pass the formula this installer is considering on # Returns true if the formula attached to this installer was explicitly
# the command line? # passed on the command line by the user as opposed to being automatically
# added to satisfy a dependency.
def explicitly_requested? def explicitly_requested?
# `ARGV.formulae` will throw an exception if it comes up with an empty # `ARGV.formulae` will throw an exception if it comes up with an empty
# list. # list.
@ -257,13 +258,23 @@ class FormulaInstaller
return false if ARGV.named.empty? return false if ARGV.named.empty?
ARGV.formulae.include? f ARGV.formulae.include? f
end end
previous_install = Tab.for_formula f
args = ARGV.clone args = ARGV.clone
args.concat previous_install.used_options
args.uniq! # Just in case some dupes were added
%w[--HEAD --verbose -v --debug -d --interactive -i].each {|f| args.delete f} unless explicitly_requested? %w[
--debug -d
--fresh
--HEAD
--interactive -i
--verbose -v
].each {|flag| args.delete flag} unless explicitly_requested?
unless args.include? '--fresh'
previous_install = Tab.for_formula f
args.concat previous_install.used_options
end
args.uniq! # Just in case some dupes slipped by
return args return args
end end

View File

@ -158,7 +158,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 [\-\-force] [\-\-debug] [\-\-ignore\-dependencies] [\-\-use\-clang] [\-\-use\-gcc] [\-\-use\-llvm] [\-\-build\-from\-source] [\-\-HEAD]\fR \fIformula\fR \fBinstall [\-\-force] [\-\-debug] [\-\-ignore\-dependencies] [\-\-fresh] [\-\-use\-clang] [\-\-use\-gcc] [\-\-use\-llvm] [\-\-build\-from\-source] [\-\-HEAD]\fR \fIformula\fR
Install \fIformula\fR\. Install \fIformula\fR\.
. .
.IP .IP
@ -174,6 +174,9 @@ If \fB\-\-debug\fR is passed and brewing fails, open a shell inside the temporar
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\-\-fresh\fR is passed, the installation process will not re\-use any options from previous installs\.
.
.IP
If \fB\-\-use\-clang\fR is passed, attempt to compile using clang\. If \fB\-\-use\-clang\fR is passed, attempt to compile using clang\.
. .
.IP .IP