diff options
| -rwxr-xr-x | Library/Contributions/cmds/brew-missing.rb | 37 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/doctor.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/missing.rb | 48 | 
3 files changed, 57 insertions, 44 deletions
| diff --git a/Library/Contributions/cmds/brew-missing.rb b/Library/Contributions/cmds/brew-missing.rb deleted file mode 100755 index 50fae12e4..000000000 --- a/Library/Contributions/cmds/brew-missing.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "formula" -require "cmd/outdated" - -def installed_brews -  formulae = [] -  HOMEBREW_CELLAR.subdirs.each do |rack| -    f = Formula.factory rack.basename.to_s rescue nil -    formulae << f if f and f.installed? -  end -  formulae -end - -def main -  return unless HOMEBREW_CELLAR.exist? - -  # Names of outdated brews; they count as installed. -  outdated = Homebrew.outdated_brews.collect{ |b| b.name } - -  formulae_to_check = if ARGV.named.empty? -    installed_brews -  else -    ARGV.formulae -  end - -  formulae_to_check.each do |f| -    missing_deps = f.recursive_deps.map{ |g| g.name }.uniq.reject do |dep_name| -      Formula.factory(dep_name).installed? or outdated.include?(dep_name) -    end - -    unless missing_deps.empty? -      print "#{f.name}: " if formulae_to_check.size > 1 -      puts "#{missing_deps * ' '}" -    end -  end -end - -main() diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index ea7c1f8c4..277ce858f 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -1,3 +1,6 @@ +require 'set' +require 'cmd/missing' +  class Volumes    def initialize      @volumes = [] @@ -752,18 +755,17 @@ def check_tmpdir  end  def check_missing_deps -  s = [] -  `brew missing`.each_line do |line| -    line =~ /(.*): (.*)/ -    $2.split.each do |dep| -        s << dep unless s.include? dep -    end +  s = Set.new +  missing_deps = Homebrew.find_missing_brews(Homebrew.installed_brews) +  missing_deps.each do |m| +    s.merge m[1]    end +    if s.length > 0 then <<-EOS.undent      Some installed formula are missing dependencies.      You should `brew install` the missing dependencies: -        brew install #{s * " "} +        brew install #{s.to_a.sort * " "}      Run `brew missing` for more details.      EOS diff --git a/Library/Homebrew/cmd/missing.rb b/Library/Homebrew/cmd/missing.rb new file mode 100644 index 000000000..26d6e3340 --- /dev/null +++ b/Library/Homebrew/cmd/missing.rb @@ -0,0 +1,48 @@ +require 'formula' +require 'cmd/outdated' + +module Homebrew extend self +  def installed_brews +    formulae = [] +    HOMEBREW_CELLAR.subdirs.each do |rack| +      f = Formula.factory rack.basename.to_s rescue nil +      formulae << f if f and f.installed? +    end +    formulae +  end + +  def find_missing_brews top_level +    # Names of outdated brews; they count as installed. +    outdated = Homebrew.outdated_brews.collect{ |b| b.name } + +    brews = [] +    top_level.each do |f| +      missing_deps = f.recursive_deps.map{ |g| g.name }.uniq.reject do |dep_name| +        Formula.factory(dep_name).installed? or outdated.include?(dep_name) +      end + +      unless missing_deps.empty? +        brews << [f.name, missing_deps] +      end +    end +    brews +  end + +  def missing +    return unless HOMEBREW_CELLAR.exist? + +    formulae_to_check = if ARGV.named.empty? +      installed_brews +    else +      ARGV.formulae +    end + +    missing_deps = find_missing_brews(formulae_to_check) +    missing_deps.each do |d| +      name = d[0] +      missing = d[1] +      print "#{name}: " if formulae_to_check.size > 1 +      puts "#{missing * ' '}" +    end +  end +end | 
