aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/formula.rb')
-rw-r--r--Library/Homebrew/formula.rb119
1 files changed, 63 insertions, 56 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 17a34dd13..d9254d23d 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -1,5 +1,5 @@
require "formula_support"
-require "formula_lock"
+require "lock_file"
require "formula_pin"
require "hardware"
require "utils/bottles"
@@ -621,14 +621,14 @@ class Formula
# No `make install` available?
# <pre>bin.install "binary1"</pre>
def bin
- prefix+"bin"
+ prefix/"bin"
end
# The directory where the formula's documentation should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def doc
- share+"doc"+name
+ share/"doc"/name
end
# The directory where the formula's headers should be installed.
@@ -638,14 +638,14 @@ class Formula
# No `make install` available?
# <pre>include.install "example.h"</pre>
def include
- prefix+"include"
+ prefix/"include"
end
# The directory where the formula's info files should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def info
- share+"info"
+ share/"info"
end
# The directory where the formula's libraries should be installed.
@@ -655,7 +655,7 @@ class Formula
# No `make install` available?
# <pre>lib.install "example.dylib"</pre>
def lib
- prefix+"lib"
+ prefix/"lib"
end
# The directory where the formula's binaries should be installed.
@@ -664,7 +664,7 @@ class Formula
# symlinked into HOMEBREW_PREFIX from one of the other directories and
# instead manually create symlinks or wrapper scripts into e.g. {#bin}.
def libexec
- prefix+"libexec"
+ prefix/"libexec"
end
# The root directory where the formula's manual pages should be installed.
@@ -673,7 +673,7 @@ class Formula
# Often one of the more specific `man` functions should be used instead
# e.g. {#man1}
def man
- share+"man"
+ share/"man"
end
# The directory where the formula's man1 pages should be installed.
@@ -683,14 +683,14 @@ class Formula
# No `make install` available?
# <pre>man1.install "example.1"</pre>
def man1
- man+"man1"
+ man/"man1"
end
# The directory where the formula's man2 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def man2
- man+"man2"
+ man/"man2"
end
# The directory where the formula's man3 pages should be installed.
@@ -700,42 +700,42 @@ class Formula
# No `make install` available?
# <pre>man3.install "man.3"</pre>
def man3
- man+"man3"
+ man/"man3"
end
# The directory where the formula's man4 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def man4
- man+"man4"
+ man/"man4"
end
# The directory where the formula's man5 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def man5
- man+"man5"
+ man/"man5"
end
# The directory where the formula's man6 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def man6
- man+"man6"
+ man/"man6"
end
# The directory where the formula's man7 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def man7
- man+"man7"
+ man/"man7"
end
# The directory where the formula's man8 pages should be installed.
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def man8
- man+"man8"
+ man/"man8"
end
# The directory where the formula's `sbin` binaries should be installed.
@@ -743,7 +743,7 @@ class Formula
# `brew link` for formulae that are not keg-only.
# Generally we try to migrate these to {#bin} instead.
def sbin
- prefix+"sbin"
+ prefix/"sbin"
end
# The directory where the formula's shared files should be installed.
@@ -762,7 +762,7 @@ class Formula
# Install `./example_code/simple/ones` to share/demos/examples
# <pre>(share/"demos").install "example_code/simple/ones" => "examples"</pre>
def share
- prefix+"share"
+ prefix/"share"
end
# The directory where the formula's shared files should be installed,
@@ -773,7 +773,7 @@ class Formula
# No `make install` available?
# <pre>pkgshare.install "examples"</pre>
def pkgshare
- prefix+"share"+name
+ prefix/"share"/name
end
# The directory where Emacs Lisp files should be installed, with the
@@ -782,7 +782,7 @@ class Formula
# Install an Emacs mode included with a software package:
# <pre>elisp.install "contrib/emacs/example-mode.el"</pre>
def elisp
- prefix+"share/emacs/site-lisp"+name
+ prefix/"share/emacs/site-lisp"/name
end
# The directory where the formula's Frameworks should be installed.
@@ -790,7 +790,7 @@ class Formula
# `brew link` for formulae that are not keg-only.
# This is not symlinked into `HOMEBREW_PREFIX`.
def frameworks
- prefix+"Frameworks"
+ prefix/"Frameworks"
end
# The directory where the formula's kernel extensions should be installed.
@@ -798,7 +798,7 @@ class Formula
# `brew link` for formulae that are not keg-only.
# This is not symlinked into `HOMEBREW_PREFIX`.
def kext_prefix
- prefix+"Library/Extensions"
+ prefix/"Library/Extensions"
end
# The directory where the formula's configuration files should be installed.
@@ -807,14 +807,14 @@ class Formula
# This directory is not inside the `HOMEBREW_CELLAR` so it is persisted
# across upgrades.
def etc
- (HOMEBREW_PREFIX+"etc").extend(InstallRenamed)
+ (HOMEBREW_PREFIX/"etc").extend(InstallRenamed)
end
# The directory where the formula's variable files should be installed.
# This directory is not inside the `HOMEBREW_CELLAR` so it is persisted
# across upgrades.
def var
- HOMEBREW_PREFIX+"var"
+ HOMEBREW_PREFIX/"var"
end
# The directory where the formula's ZSH function files should be
@@ -822,7 +822,7 @@ class Formula
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def zsh_function
- share+"zsh/site-functions"
+ share/"zsh/site-functions"
end
# The directory where the formula's fish function files should be
@@ -830,7 +830,7 @@ class Formula
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def fish_function
- share+"fish/vendor_functions.d"
+ share/"fish/vendor_functions.d"
end
# The directory where the formula's Bash completion files should be
@@ -838,7 +838,7 @@ class Formula
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def bash_completion
- prefix+"etc/bash_completion.d"
+ prefix/"etc/bash_completion.d"
end
# The directory where the formula's ZSH completion files should be
@@ -846,7 +846,7 @@ class Formula
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def zsh_completion
- share+"zsh/site-functions"
+ share/"zsh/site-functions"
end
# The directory where the formula's fish completion files should be
@@ -854,7 +854,7 @@ class Formula
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
# `brew link` for formulae that are not keg-only.
def fish_completion
- share+"fish/vendor_completions.d"
+ share/"fish/vendor_completions.d"
end
# The directory used for as the prefix for {#etc} and {#var} files on
@@ -862,13 +862,13 @@ class Formula
# there after pouring a bottle.
# @private
def bottle_prefix
- prefix+".bottle"
+ prefix/".bottle"
end
# The directory where the formula's installation or test logs will be written.
# @private
def logs
- HOMEBREW_LOGS+name
+ HOMEBREW_LOGS + name
end
# The prefix, if any, to use in filenames for logging current activity
@@ -921,12 +921,12 @@ class Formula
# The generated launchd {.plist} service name.
def plist_name
- "homebrew.mxcl."+name
+ "homebrew.mxcl." + name
end
# The generated launchd {.plist} file path.
def plist_path
- prefix+(plist_name+".plist")
+ prefix + (plist_name + ".plist")
end
# @private
@@ -951,39 +951,39 @@ class Formula
end
def opt_bin
- opt_prefix+"bin"
+ opt_prefix/"bin"
end
def opt_include
- opt_prefix+"include"
+ opt_prefix/"include"
end
def opt_lib
- opt_prefix+"lib"
+ opt_prefix/"lib"
end
def opt_libexec
- opt_prefix+"libexec"
+ opt_prefix/"libexec"
end
def opt_sbin
- opt_prefix+"sbin"
+ opt_prefix/"sbin"
end
def opt_share
- opt_prefix+"share"
+ opt_prefix/"share"
end
def opt_pkgshare
- opt_prefix+"share"+name
+ opt_prefix/"share"/name
end
def opt_elisp
- opt_prefix+"share/emacs/site-lisp"+name
+ opt_prefix/"share/emacs/site-lisp"/name
end
def opt_frameworks
- opt_prefix+"Frameworks"
+ opt_prefix/"Frameworks"
end
# Indicates that this formula supports bottles. (Not necessarily that one
@@ -1553,11 +1553,11 @@ class Formula
def missing_dependencies(hide: nil)
hide ||= []
missing_dependencies = recursive_dependencies do |dependent, dep|
- if dep.optional? || dep.recommended?
+ if dep.build?
+ Dependency.prune
+ elsif dep.optional? || dep.recommended?
tab = Tab.for_formula(dependent)
Dependency.prune unless tab.with?(dep)
- elsif dep.build?
- Dependency.prune
end
end
@@ -1588,7 +1588,7 @@ class Formula
"revision" => revision,
"version_scheme" => version_scheme,
"installed" => [],
- "linked_keg" => (linked_keg.resolved_path.basename.to_s if linked_keg.exist?),
+ "linked_keg" => (linked_version.to_s if linked_keg.exist?),
"pinned" => pinned?,
"outdated" => outdated?,
"keg_only" => keg_only?,
@@ -1673,11 +1673,13 @@ class Formula
old_temp = ENV["TEMP"]
old_tmp = ENV["TMP"]
old_term = ENV["TERM"]
- old_path = ENV["HOMEBREW_PATH"]
+ old_path = ENV["PATH"]
+ old_homebrew_path = ENV["HOMEBREW_PATH"]
ENV["CURL_HOME"] = old_curl_home || old_home
ENV["TMPDIR"] = ENV["TEMP"] = ENV["TMP"] = HOMEBREW_TEMP
ENV["TERM"] = "dumb"
+ ENV["PATH"] = PATH.new(old_path).append(HOMEBREW_PREFIX/"bin")
ENV["HOMEBREW_PATH"] = nil
ENV.clear_sensitive_environment!
@@ -1704,7 +1706,8 @@ class Formula
ENV["TEMP"] = old_temp
ENV["TMP"] = old_tmp
ENV["TERM"] = old_term
- ENV["HOMEBREW_PATH"] = old_path
+ ENV["PATH"] = old_path
+ ENV["HOMEBREW_PATH"] = old_homebrew_path
@prefix_returns_versioned_prefix = false
end
@@ -1719,7 +1722,7 @@ class Formula
# @private
def test_fixtures(file)
- HOMEBREW_LIBRARY_PATH.join("test", "support", "fixtures", file)
+ HOMEBREW_LIBRARY_PATH/"test/support/fixtures"/file
end
# This method is overridden in {Formula} subclasses to provide the installation instructions.
@@ -1784,7 +1787,7 @@ class Formula
pretty_args[i] = "import setuptools..."
end
end
- ohai "#{cmd} #{pretty_args*" "}".strip
+ ohai "#{cmd} #{pretty_args * " "}".strip
@exec_count ||= 0
@exec_count += 1
@@ -1943,8 +1946,10 @@ class Formula
old_curl_home = ENV["CURL_HOME"]
old_path = ENV["HOMEBREW_PATH"]
- ENV["HOME"] = env_home
- ENV["CURL_HOME"] = old_curl_home || old_home
+ unless ARGV.interactive?
+ ENV["HOME"] = env_home
+ ENV["CURL_HOME"] = old_curl_home || old_home
+ end
ENV["HOMEBREW_PATH"] = nil
setup_home env_home
@@ -1955,8 +1960,10 @@ class Formula
yield staging
ensure
@buildpath = nil
- ENV["HOME"] = old_home
- ENV["CURL_HOME"] = old_curl_home
+ unless ARGV.interactive?
+ ENV["HOME"] = old_home
+ ENV["CURL_HOME"] = old_curl_home
+ end
ENV["HOMEBREW_PATH"] = old_path
end
end
@@ -1993,7 +2000,7 @@ class Formula
# The methods below define the formula DSL.
class << self
- include BuildEnvironmentDSL
+ include BuildEnvironment::DSL
# The reason for why this software is not linked (by default) to
# {::HOMEBREW_PREFIX}.
@@ -2362,7 +2369,7 @@ class Formula
end
# If this formula conflicts with another one.
- # <pre>conflicts_with "imagemagick", :because => "because this is just a stupid example"</pre>
+ # <pre>conflicts_with "imagemagick", :because => "because both install 'convert' binaries"</pre>
def conflicts_with(*names)
opts = names.last.is_a?(Hash) ? names.pop : {}
names.each { |name| conflicts << FormulaConflict.new(name, opts[:because]) }