2015-08-03 13:09:07 +01:00
|
|
|
require "formula"
|
|
|
|
require "tab"
|
2012-06-11 12:57:51 -07:00
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2015-08-03 13:09:07 +01:00
|
|
|
def missing_deps(ff)
|
2012-08-14 11:57:10 -05:00
|
|
|
missing = {}
|
|
|
|
ff.each do |f|
|
2013-01-23 00:26:28 -06:00
|
|
|
missing_deps = f.recursive_dependencies do |dependent, dep|
|
|
|
|
if dep.optional? || dep.recommended?
|
|
|
|
tab = Tab.for_formula(dependent)
|
2014-10-09 00:20:15 -05:00
|
|
|
Dependency.prune unless tab.with?(dep)
|
2013-01-23 00:26:28 -06:00
|
|
|
elsif dep.build?
|
|
|
|
Dependency.prune
|
2012-08-14 11:57:10 -05:00
|
|
|
end
|
2013-01-23 00:26:28 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
missing_deps.map!(&:to_formula)
|
|
|
|
missing_deps.reject! { |d| d.rack.exist? && d.rack.subdirs.length > 0 }
|
2012-06-11 12:57:51 -07:00
|
|
|
|
|
|
|
unless missing_deps.empty?
|
2015-05-27 21:05:55 +08:00
|
|
|
yield f.full_name, missing_deps if block_given?
|
|
|
|
missing[f.full_name] = missing_deps
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
end
|
2012-08-14 11:57:10 -05:00
|
|
|
missing
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def missing
|
|
|
|
return unless HOMEBREW_CELLAR.exist?
|
|
|
|
|
2012-08-14 11:57:10 -05:00
|
|
|
ff = if ARGV.named.empty?
|
2013-01-23 00:26:28 -06:00
|
|
|
Formula.installed
|
2012-06-11 12:57:51 -07:00
|
|
|
else
|
2015-05-17 21:02:54 +08:00
|
|
|
ARGV.resolved_formulae
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
|
2012-08-14 11:57:10 -05:00
|
|
|
missing_deps(ff) do |name, missing|
|
|
|
|
print "#{name}: " if ff.size > 1
|
2015-08-03 13:09:07 +01:00
|
|
|
puts "#{missing * " "}"
|
2012-06-11 12:57:51 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|