Centralize definition of rack
in formula.rb
`rack` is a commonly used alias for `formula.prefix.parent`---so common that it gets defined and used quite a bit. This patch makes `rack` an official method of the `Formula` class.
This commit is contained in:
parent
95ce00729c
commit
94dba21f7d
@ -86,7 +86,7 @@ def install f
|
|||||||
rescue Exception
|
rescue Exception
|
||||||
if f.prefix.directory?
|
if f.prefix.directory?
|
||||||
f.prefix.rmtree
|
f.prefix.rmtree
|
||||||
f.prefix.parent.rmdir_if_possible
|
f.rack.rmdir_if_possible
|
||||||
end
|
end
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
@ -23,25 +23,24 @@ module Homebrew extend self
|
|||||||
|
|
||||||
def cleanup_formula f
|
def cleanup_formula f
|
||||||
f = Formula.factory f
|
f = Formula.factory f
|
||||||
rack = f.prefix.parent
|
|
||||||
|
|
||||||
# Don't clean up keg-only brews for now.
|
# Don't clean up keg-only brews for now.
|
||||||
# Formulae link directly to them, so cleaning up old
|
# Formulae link directly to them, so cleaning up old
|
||||||
# ones will break already compiled software.
|
# ones will break already compiled software.
|
||||||
if f.keg_only? and not ARGV.force?
|
if f.keg_only? and not ARGV.force?
|
||||||
opoo "Skipping keg-only #{f.name}" if rack.children.length > 1
|
opoo "Skipping keg-only #{f.name}" if f.rack.children.length > 1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if f.installed? and rack.directory?
|
if f.installed? and f.rack.directory?
|
||||||
rack.children.each do |keg|
|
f.rack.children.each do |keg|
|
||||||
if f.installed_prefix != keg
|
if f.installed_prefix != keg
|
||||||
print "Removing #{keg}..."
|
print "Removing #{keg}..."
|
||||||
rm_rf keg
|
rm_rf keg
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif rack.children.length > 1
|
elsif f.rack.children.length > 1
|
||||||
# If the cellar only has one version installed, don't complain
|
# If the cellar only has one version installed, don't complain
|
||||||
# that we can't tell which one to keep.
|
# that we can't tell which one to keep.
|
||||||
opoo "Skipping #{f.name}: most recent version #{f.version} not installed"
|
opoo "Skipping #{f.name}: most recent version #{f.version} not installed"
|
||||||
|
@ -50,9 +50,8 @@ module Homebrew extend self
|
|||||||
|
|
||||||
puts "Depends on: #{f.deps*', '}" unless f.deps.empty?
|
puts "Depends on: #{f.deps*', '}" unless f.deps.empty?
|
||||||
|
|
||||||
rack = f.prefix.parent
|
if f.rack.directory?
|
||||||
if rack.directory?
|
kegs = f.rack.children
|
||||||
kegs = rack.children
|
|
||||||
kegs.each do |keg|
|
kegs.each do |keg|
|
||||||
next if keg.basename.to_s == '.DS_Store'
|
next if keg.basename.to_s == '.DS_Store'
|
||||||
print "#{keg} (#{keg.abv})"
|
print "#{keg} (#{keg.abv})"
|
||||||
|
@ -10,17 +10,16 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
ARGV.formulae.each do |f|
|
ARGV.formulae.each do |f|
|
||||||
rack = f.prefix.parent
|
if f.rack.directory?
|
||||||
if rack.directory?
|
|
||||||
puts "Uninstalling #{f}..."
|
puts "Uninstalling #{f}..."
|
||||||
rack.children.each do |keg|
|
f.rack.children.each do |keg|
|
||||||
if keg.directory?
|
if keg.directory?
|
||||||
keg = Keg.new(keg)
|
keg = Keg.new(keg)
|
||||||
keg.unlink
|
keg.unlink
|
||||||
keg.rmtree
|
keg.rmtree
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rack.rmtree
|
f.rack.rmtree
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,12 +7,6 @@ class Fixnum
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Formula
|
|
||||||
def rack
|
|
||||||
HOMEBREW_CELLAR/name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def upgrade
|
def upgrade
|
||||||
Homebrew.perform_preinstall_checks
|
Homebrew.perform_preinstall_checks
|
||||||
@ -23,7 +17,7 @@ module Homebrew extend self
|
|||||||
ARGV.formulae.map do |f|
|
ARGV.formulae.map do |f|
|
||||||
raise "#{f} already upgraded" if f.installed?
|
raise "#{f} already upgraded" if f.installed?
|
||||||
raise "#{f} not installed" unless f.rack.exist? and not f.rack.children.empty?
|
raise "#{f} not installed" unless f.rack.exist? and not f.rack.children.empty?
|
||||||
[f.prefix.parent, f.name, f.version]
|
[f.rack, f.name, f.version]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -170,6 +170,7 @@ class Formula
|
|||||||
validate_variable :version
|
validate_variable :version
|
||||||
HOMEBREW_CELLAR+@name+@version
|
HOMEBREW_CELLAR+@name+@version
|
||||||
end
|
end
|
||||||
|
def rack; prefix.parent end
|
||||||
|
|
||||||
def bin; prefix+'bin' end
|
def bin; prefix+'bin' end
|
||||||
def doc; prefix+'share/doc'+name end
|
def doc; prefix+'share/doc'+name end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user