aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula_installer.rb
diff options
context:
space:
mode:
authorJack Nagel2014-10-29 22:38:49 -0500
committerJack Nagel2014-10-29 22:41:03 -0500
commit1195718d0ee0413d271f109c40bd58e73431ea8f (patch)
treee4dd98fc08fe9d273b7668b5c1f0a8428b806dfe /Library/Homebrew/formula_installer.rb
parentd1fae671f1534fd0775bc660a4731752892d9f89 (diff)
downloadbrew-1195718d0ee0413d271f109c40bd58e73431ea8f.tar.bz2
Rename "f" to "formula" in the installer
Diffstat (limited to 'Library/Homebrew/formula_installer.rb')
-rw-r--r--Library/Homebrew/formula_installer.rb161
1 files changed, 81 insertions, 80 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index ae0787c52..9b2099430 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -22,15 +22,15 @@ class FormulaInstaller
names.each { |name| define_method("#{name}?") { !!send(name) }}
end
- attr_reader :f
+ attr_reader :formula
attr_accessor :options
mode_attr_accessor :show_summary_heading, :show_header
mode_attr_accessor :build_from_source, :build_bottle, :force_bottle
mode_attr_accessor :ignore_deps, :only_deps, :interactive
mode_attr_accessor :verbose, :debug
- def initialize ff
- @f = ff
+ def initialize(formula)
+ @formula = formula
@show_header = false
@ignore_deps = false
@only_deps = false
@@ -49,19 +49,21 @@ class FormulaInstaller
end
def pour_bottle? install_bottle_options={:warn=>false}
- return true if Homebrew::Hooks::Bottles.formula_has_bottle?(f)
+ return true if Homebrew::Hooks::Bottles.formula_has_bottle?(formula)
return false if @pour_failed
- return true if force_bottle? && f.bottle
+
+ bottle = formula.bottle
+ return true if force_bottle? && bottle
return false if build_from_source? || build_bottle? || interactive?
return false unless options.empty?
- return true if f.local_bottle_path
- return false unless f.bottle && f.pour_bottle?
+ return true if formula.local_bottle_path
+ return false unless bottle && formula.pour_bottle?
- unless f.bottle.compatible_cellar?
+ unless bottle.compatible_cellar?
if install_bottle_options[:warn]
- opoo "Building source; cellar of #{f.name}'s bottle is #{f.bottle.cellar}"
+ opoo "Building source; cellar of #{formula.name}'s bottle is #{bottle.cellar}"
end
return false
end
@@ -70,7 +72,7 @@ class FormulaInstaller
end
def install_bottle_for?(dep, build)
- return pour_bottle? if dep == f
+ return pour_bottle? if dep == formula
return false if build_from_source?
return false unless dep.bottle && dep.pour_bottle?
return false unless build.used_options.empty?
@@ -86,7 +88,7 @@ class FormulaInstaller
def verify_deps_exist
begin
- f.recursive_dependencies.map(&:to_formula)
+ formula.recursive_dependencies.map(&:to_formula)
rescue TapFormulaUnavailableError => e
if Homebrew.install_tap(e.user, e.repo)
retry
@@ -95,25 +97,25 @@ class FormulaInstaller
end
end
rescue FormulaUnavailableError => e
- e.dependent = f.name
+ e.dependent = formula.name
raise
end
def check_install_sanity
- raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f
+ raise FormulaInstallationAlreadyAttemptedError, formula if @@attempted.include?(formula)
- if f.installed?
- msg = "#{f.name}-#{f.installed_version} already installed"
- msg << ", it's just not linked" unless f.linked_keg.symlink? or f.keg_only?
+ if formula.installed?
+ msg = "#{formula.name}-#{formula.installed_version} already installed"
+ msg << ", it's just not linked" unless formula.linked_keg.symlink? or formula.keg_only?
raise FormulaAlreadyInstalledError, msg
end
unless ignore_deps?
- unlinked_deps = f.recursive_dependencies.map(&:to_formula).select do |dep|
+ unlinked_deps = formula.recursive_dependencies.map(&:to_formula).select do |dep|
dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?
end
raise CannotInstallFormulaError,
- "You must `brew link #{unlinked_deps*' '}' before #{f.name} can be installed" unless unlinked_deps.empty?
+ "You must `brew link #{unlinked_deps*' '}' before #{formula.name} can be installed" unless unlinked_deps.empty?
end
end
@@ -125,7 +127,7 @@ class FormulaInstaller
def build_bottle_postinstall
@etc_var_postinstall = Dir[@etc_var_glob]
(@etc_var_postinstall - @etc_var_preinstall).each do |file|
- Pathname.new(file).cp_path_sub(HOMEBREW_PREFIX, f.bottle_prefix)
+ Pathname.new(file).cp_path_sub(HOMEBREW_PREFIX, formula.bottle_prefix)
end
end
@@ -133,11 +135,11 @@ class FormulaInstaller
# not in initialize so upgrade can unlink the active keg before calling this
# function but after instantiating this class so that it can avoid having to
# relink the active keg if possible (because it is slow).
- if f.linked_keg.directory?
+ if formula.linked_keg.directory?
# some other version is already installed *and* linked
raise CannotInstallFormulaError, <<-EOS.undent
- #{f.name}-#{f.linked_keg.resolved_path.basename} already installed
- To install this version, first `brew unlink #{f.name}'
+ #{formula.name}-#{formula.linked_keg.resolved_path.basename} already installed
+ To install this version, first `brew unlink #{formula.name}'
EOS
end
@@ -151,15 +153,15 @@ class FormulaInstaller
raise "Unrecognized architecture for --bottle-arch: #{arch}"
end
- f.active_spec.deprecated_flags.each do |deprecated_option|
+ formula.active_spec.deprecated_flags.each do |deprecated_option|
old_flag = deprecated_option.old_flag
new_flag = deprecated_option.current_flag
- opoo "#{f.name}: #{old_flag} was deprecated; using #{new_flag} instead!"
+ opoo "#{formula.name}: #{old_flag} was deprecated; using #{new_flag} instead!"
end
- oh1 "Installing #{Tty.green}#{f.name}#{Tty.reset}" if show_header?
+ oh1 "Installing #{Tty.green}#{formula.name}#{Tty.reset}" if show_header?
- @@attempted << f
+ @@attempted << formula
if pour_bottle?(:warn => true)
begin
@@ -184,13 +186,13 @@ class FormulaInstaller
build_bottle_postinstall if build_bottle?
- opoo "Nothing was installed to #{f.prefix}" unless f.installed?
+ opoo "Nothing was installed to #{formula.prefix}" unless formula.installed?
end
# HACK: If readline is present in the dependency tree, it will clash
# with the stdlib's Readline module when the debugger is loaded
def perform_readline_hack
- if (f.recursive_dependencies.any? { |d| d.name == "readline" } || f.name == "readline") && debug?
+ if (formula.recursive_dependencies.any? { |d| d.name == "readline" } || formula.name == "readline") && debug?
ENV['HOMEBREW_NO_READLINE'] = '1'
end
end
@@ -198,12 +200,12 @@ class FormulaInstaller
def check_conflicts
return if ARGV.force?
- conflicts = f.conflicts.reject do |c|
+ conflicts = formula.conflicts.reject do |c|
keg = Formulary.factory(c.name).prefix
not keg.directory? && Keg.new(keg).linked?
end
- raise FormulaConflictError.new(f, conflicts) unless conflicts.empty?
+ raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty?
end
def compute_and_install_dependencies
@@ -213,10 +215,10 @@ class FormulaInstaller
check_requirements(req_map)
- deps = expand_dependencies(req_deps + f.deps)
+ deps = expand_dependencies(req_deps + formula.deps)
if deps.empty? and only_deps?
- puts "All dependencies for #{f.name} are satisfied."
+ puts "All dependencies for #{formula.name} are satisfied."
else
install_dependencies(deps)
end
@@ -244,10 +246,9 @@ class FormulaInstaller
def expand_requirements
unsatisfied_reqs = Hash.new { |h, k| h[k] = [] }
deps = []
- formulae = [f]
+ formulae = [formula]
while f = formulae.pop
-
f.recursive_requirements do |dependent, req|
build = effective_build_options_for(dependent)
@@ -274,7 +275,7 @@ class FormulaInstaller
def expand_dependencies(deps)
inherited_options = {}
- expanded_deps = Dependency.expand(f, deps) do |dependent, dep|
+ expanded_deps = Dependency.expand(formula, deps) do |dependent, dep|
options = inherited_options[dep.name] = inherited_options_for(dep)
build = effective_build_options_for(
dependent,
@@ -295,7 +296,7 @@ class FormulaInstaller
def effective_build_options_for(dependent, inherited_options=[])
args = dependent.build.used_options
- args |= dependent == f ? options : inherited_options
+ args |= dependent == formula ? options : inherited_options
args |= Tab.for_formula(dependent).used_options
BuildOptions.new(args, dependent.options)
end
@@ -303,7 +304,7 @@ class FormulaInstaller
def inherited_options_for(dep)
inherited_options = Options.new
u = Option.new("universal")
- if (options.include?(u) || f.require_universal_deps?) && !dep.build? && dep.to_formula.option_defined?(u)
+ if (options.include?(u) || formula.require_universal_deps?) && !dep.build? && dep.to_formula.option_defined?(u)
inherited_options << u
end
inherited_options
@@ -311,7 +312,7 @@ class FormulaInstaller
def install_dependencies(deps)
if deps.length > 1
- oh1 "Installing dependencies for #{f.name}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}"
+ oh1 "Installing dependencies for #{formula.name}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}"
end
deps.each { |dep, options| install_dependency(dep, options) }
@@ -320,7 +321,7 @@ class FormulaInstaller
end
class DependencyInstaller < FormulaInstaller
- def initialize ff
+ def initialize(*)
super
@ignore_deps = true
end
@@ -355,7 +356,7 @@ class FormulaInstaller
fi.verbose = verbose? unless verbose == :quieter
fi.debug = debug?
fi.prelude
- oh1 "Installing #{f.name} dependency: #{Tty.green}#{dep.name}#{Tty.reset}"
+ oh1 "Installing #{formula.name} dependency: #{Tty.green}#{dep.name}#{Tty.reset}"
fi.install
fi.caveats
fi.finish
@@ -372,9 +373,9 @@ class FormulaInstaller
def caveats
return if only_deps?
- audit_installed if ARGV.homebrew_developer? and not f.keg_only?
+ audit_installed if ARGV.homebrew_developer? and not formula.keg_only?
- c = Caveats.new(f)
+ c = Caveats.new(formula)
unless c.empty?
@show_summary_heading = true
@@ -389,7 +390,7 @@ class FormulaInstaller
install_plist
- keg = Keg.new(f.prefix)
+ keg = Keg.new(formula.prefix)
link(keg)
fix_install_names(keg) if OS.mac?
@@ -408,7 +409,7 @@ class FormulaInstaller
def summary
s = ""
s << "#{emoji} " if MacOS.version >= :lion and not ENV['HOMEBREW_NO_EMOJI']
- s << "#{f.prefix}: #{f.prefix.abv}"
+ s << "#{formula.prefix}: #{formula.prefix.abv}"
s << ", built in #{pretty_duration build_time}" if build_time
s
end
@@ -436,12 +437,12 @@ class FormulaInstaller
args << "--cc=#{ARGV.cc}" if ARGV.cc
args << "--env=#{ARGV.env}" if ARGV.env
- case f.active_spec
- when f.head then args << "--HEAD"
- when f.devel then args << "--devel"
+ case formula.active_spec
+ when formula.head then args << "--HEAD"
+ when formula.devel then args << "--devel"
end
- f.options.each do |opt|
+ formula.options.each do |opt|
name = opt.name[/\A(.+)=\z$/, 1]
value = ARGV.value(name)
args << "--#{name}=#{value}" if name && value
@@ -455,7 +456,7 @@ class FormulaInstaller
end
def build
- FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{f.name}/*"]
+ FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]
@start_time = Time.now
@@ -472,7 +473,7 @@ class FormulaInstaller
-I #{HOMEBREW_LIBRARY_PATH}
--
#{HOMEBREW_LIBRARY_PATH}/build.rb
- #{f.path}
+ #{formula.path}
].concat(build_argv)
# Ruby 2.0+ sets close-on-exec on all file descriptors except for
@@ -501,24 +502,24 @@ class FormulaInstaller
raise "Suspicious installation failure" unless $?.success?
end
- raise "Empty installation" if Dir["#{f.prefix}/*"].empty?
+ raise "Empty installation" if Dir["#{formula.prefix}/*"].empty?
rescue Exception
ignore_interrupts do
# any exceptions must leave us with nothing installed
- f.prefix.rmtree if f.prefix.directory?
- f.rack.rmdir_if_possible
+ formula.prefix.rmtree if formula.prefix.directory?
+ formula.rack.rmdir_if_possible
end
raise
end
def link(keg)
- if f.keg_only?
+ if formula.keg_only?
begin
keg.optlink
rescue Keg::LinkError => e
- onoe "Failed to create #{f.opt_prefix}"
- puts "Things that depend on #{f.name} will probably not build."
+ onoe "Failed to create #{formula.opt_prefix}"
+ puts "Things that depend on #{formula.name} will probably not build."
puts e
Homebrew.failed = true
end
@@ -548,7 +549,7 @@ class FormulaInstaller
puts e
puts
puts "You can try again using:"
- puts " brew link #{f.name}"
+ puts " brew link #{formula.name}"
@show_summary_heading = true
Homebrew.failed = true
rescue Exception => e
@@ -564,9 +565,9 @@ class FormulaInstaller
end
def install_plist
- return unless f.plist
- f.plist_path.atomic_write(f.plist)
- f.plist_path.chmod 0644
+ return unless formula.plist
+ formula.plist_path.atomic_write(formula.plist)
+ formula.plist_path.chmod 0644
rescue Exception => e
onoe "Failed to install plist file"
ohai e, e.backtrace if debug?
@@ -574,11 +575,11 @@ class FormulaInstaller
end
def fix_install_names(keg)
- keg.fix_install_names(:keg_only => f.keg_only?)
+ keg.fix_install_names(:keg_only => formula.keg_only?)
if @poured_bottle
keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s,
- Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s, :keg_only => f.keg_only?
+ Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s, :keg_only => formula.keg_only?
end
rescue Exception => e
onoe "Failed to fix install names"
@@ -591,7 +592,7 @@ class FormulaInstaller
def clean
ohai "Cleaning" if verbose?
- Cleaner.new(f).clean
+ Cleaner.new(formula).clean
rescue Exception => e
opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix"
@@ -601,42 +602,42 @@ class FormulaInstaller
end
def post_install
- f.post_install
+ formula.post_install
rescue Exception => e
opoo "The post-install step did not complete successfully"
- puts "You can try again using `brew postinstall #{f.name}`"
+ puts "You can try again using `brew postinstall #{formula.name}`"
ohai e, e.backtrace if debug?
Homebrew.failed = true
@show_summary_heading = true
end
def pour
- if Homebrew::Hooks::Bottles.formula_has_bottle?(f)
- return if Homebrew::Hooks::Bottles.pour_formula_bottle(f)
+ if Homebrew::Hooks::Bottles.formula_has_bottle?(formula)
+ return if Homebrew::Hooks::Bottles.pour_formula_bottle(formula)
end
- if f.local_bottle_path
- downloader = LocalBottleDownloadStrategy.new(f)
+ if formula.local_bottle_path
+ downloader = LocalBottleDownloadStrategy.new(formula)
else
- downloader = f.bottle
+ downloader = formula.bottle
downloader.verify_download_integrity(downloader.fetch)
end
HOMEBREW_CELLAR.cd do
downloader.stage
end
- Pathname.glob("#{f.bottle_prefix}/{etc,var}/**/*") do |path|
+ Pathname.glob("#{formula.bottle_prefix}/{etc,var}/**/*") do |path|
path.extend(InstallRenamed)
- path.cp_path_sub(f.bottle_prefix, HOMEBREW_PREFIX)
+ path.cp_path_sub(formula.bottle_prefix, HOMEBREW_PREFIX)
end
- FileUtils.rm_rf f.bottle_prefix
+ FileUtils.rm_rf formula.bottle_prefix
CxxStdlib.check_compatibility(
- f, f.recursive_dependencies,
- Keg.new(f.prefix), MacOS.default_compiler
+ formula, formula.recursive_dependencies,
+ Keg.new(formula.prefix), MacOS.default_compiler
)
- tab = Tab.for_keg(f.prefix)
+ tab = Tab.for_keg(formula.prefix)
tab.poured_from_bottle = true
tab.write
end
@@ -649,8 +650,8 @@ class FormulaInstaller
end
def audit_installed
- audit_check_output(check_PATH(f.bin))
- audit_check_output(check_PATH(f.sbin))
+ audit_check_output(check_PATH(formula.bin))
+ audit_check_output(check_PATH(formula.sbin))
super
end
@@ -662,10 +663,10 @@ class FormulaInstaller
def lock
if (@@locked ||= []).empty?
- f.recursive_dependencies.each do |dep|
+ formula.recursive_dependencies.each do |dep|
@@locked << dep.to_formula
end unless ignore_deps?
- @@locked.unshift(f)
+ @@locked.unshift(formula)
@@locked.uniq!
@@locked.each(&:lock)
@hold_locks = true