diff options
| author | Jack Nagel | 2015-04-17 22:58:02 -0400 | 
|---|---|---|
| committer | Jack Nagel | 2015-04-17 22:58:02 -0400 | 
| commit | 9286dacc7292bc3620795a454de480d55c4cdd7f (patch) | |
| tree | 1111712c9c4cf396578e61576ada62f45f14aa04 /Library/Homebrew/cmd/cleanup.rb | |
| parent | 6bca860118938fdf98e04e4004840ac2f9bc12d3 (diff) | |
| download | homebrew-9286dacc7292bc3620795a454de480d55c4cdd7f.tar.bz2 | |
Move can_cleanup? off of the formula instance
Diffstat (limited to 'Library/Homebrew/cmd/cleanup.rb')
| -rw-r--r-- | Library/Homebrew/cmd/cleanup.rb | 13 | 
1 files changed, 5 insertions, 8 deletions
| diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index 850cd45e5..b4211c373 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -42,7 +42,7 @@ module Homebrew    def cleanup_formula f      if f.installed?        eligible_kegs = f.rack.subdirs.map { |d| Keg.new(d) }.select { |k| f.pkg_version > k.version } -      if eligible_kegs.any? && f.can_cleanup? +      if eligible_kegs.any? && eligible_for_cleanup?(f)          eligible_kegs.each { |keg| cleanup_keg(keg) }        else          eligible_kegs.each { |keg| opoo "Skipping (old) keg-only: #{keg}" } @@ -109,21 +109,18 @@ module Homebrew      quiet_system "find", *args    end -end - -class Formula -  def can_cleanup? +  def eligible_for_cleanup?(formula)      # It used to be the case that keg-only kegs could not be cleaned up, because      # older brews were built against the full path to the keg-only keg. Then we      # introduced the opt symlink, and built against that instead. So provided      # no brew exists that was built against an old-style keg-only keg, we can      # remove it. -    if not keg_only? or ARGV.force? +    if not formula.keg_only? or ARGV.force?        true -    elsif opt_prefix.directory? +    elsif formula.opt_prefix.directory?        # SHA records were added to INSTALL_RECEIPTS the same day as opt symlinks        Formula.installed. -        select { |f| f.deps.any? { |d| d.name == name } }. +        select { |f| f.deps.any? { |d| d.name == formula.name } }.          all? { |f| f.rack.subdirs.all? { |keg| Tab.for_keg(keg).HEAD } }      end    end | 
