diff options
| author | Mike McQuaid | 2017-01-03 20:10:22 +0000 |
|---|---|---|
| committer | GitHub | 2017-01-03 20:10:22 +0000 |
| commit | fc11f633b29e6a2c9c4d49d5fd5452549b328193 (patch) | |
| tree | 07356886d23e725783ac4c46d2bd10b5e24b5133 /Library/Homebrew/formula.rb | |
| parent | 619791e83d2781dca1b675e20249a8aebe085c7c (diff) | |
| parent | a571965df9d5dc84d1a32630a111768fbac71b3b (diff) | |
| download | brew-fc11f633b29e6a2c9c4d49d5fd5452549b328193.tar.bz2 | |
Merge pull request #1677 from MikeMcQuaid/formula-prefix-opt
formula: make prefix usually return opt_prefix.
Diffstat (limited to 'Library/Homebrew/formula.rb')
| -rw-r--r-- | Library/Homebrew/formula.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 02d4b09a0..eb85f804f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -198,6 +198,7 @@ class Formula @build = active_spec.build @pin = FormulaPin.new(self) @follow_installed_alias = true + @versioned_prefix = false end # @private @@ -548,9 +549,16 @@ class Formula end # The directory in the cellar that the formula is installed to. - # This directory contains the formula's name and version. + # This directory points to {#opt_prefix} if it exists and if #{prefix} is not + # called from within the same formula's {#install} or {#post_install} methods. + # Otherwise, return the full path to the formula's versioned cellar. def prefix(v = pkg_version) - Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}") + prefix = rack/v + if !@versioned_prefix && prefix.directory? && Keg.new(prefix).optlinked? + opt_prefix + else + prefix + end end # Is the formula linked? @@ -579,7 +587,7 @@ class Formula # installed versions of this software # @private def rack - prefix.parent + Pathname.new("#{HOMEBREW_CELLAR}/#{name}") end # All currently installed prefix directories. @@ -994,6 +1002,7 @@ class Formula # @private def run_post_install + @versioned_prefix = true build = self.build self.build = Tab.for_formula(self) old_tmpdir = ENV["TMPDIR"] @@ -1008,6 +1017,7 @@ class Formula ENV["TMPDIR"] = old_tmpdir ENV["TEMP"] = old_temp ENV["TMP"] = old_tmp + @versioned_prefix = false end # Tell the user about any caveats regarding this package. @@ -1110,6 +1120,7 @@ class Formula # where staging is a Mktemp staging context # @private def brew + @versioned_prefix = true stage do |staging| staging.retain! if ARGV.keep_tmp? prepare_patches @@ -1123,6 +1134,8 @@ class Formula cp Dir["config.log", "CMakeCache.txt"], logs end end + ensure + @versioned_prefix = false end # @private @@ -1624,6 +1637,7 @@ class Formula # @private def run_test + @versioned_prefix = true old_home = ENV["HOME"] old_curl_home = ENV["CURL_HOME"] old_tmpdir = ENV["TMPDIR"] @@ -1655,6 +1669,7 @@ class Formula ENV["TEMP"] = old_temp ENV["TMP"] = old_tmp ENV["TERM"] = old_term + @versioned_prefix = false end # @private |
