do away with DFS since compute_dep already does it

This commit is contained in:
lionellloh 2020-07-02 00:12:17 +08:00 committed by Lionell
parent 589524254b
commit ed42ed5265

View File

@ -258,7 +258,7 @@ module Homebrew
formulae.each do |f| formulae.each do |f|
Migrator.migrate_if_needed(f) Migrator.migrate_if_needed(f)
licenses_not_blisted(f) forbidden_license_check(f) unless ENV["HOMEBREW_FORBIDDEN_LICENSES"].blank?
install_formula(f) install_formula(f)
Cleanup.install_formula_clean!(f) Cleanup.install_formula_clean!(f)
end end
@ -344,32 +344,12 @@ module Homebrew
end end
end end
def licenses_not_blisted(f) def forbidden_license_check(f)
puts f.class
puts "licenses not blisted running"
license_blist = ENV["HOMEBREW_FORBIDDEN_LICENSES"].split(" ") license_blist = ENV["HOMEBREW_FORBIDDEN_LICENSES"].split(" ")
fi = FormulaInstaller.new(f) fi = FormulaInstaller.new(f)
stack = [fi] fi.compute_dependencies.each do |dep, _|
dep_graph = {} if license_blist.include? dep.to_formula().license
until stack.blank? p "VIOLATION #{dep.name}"
fi = stack.pop()
# p "#{fi.formula.name} | Children: #{fi.compute_dependencies}"
fi.compute_dependencies.each do |dep_child, _|
dep_graph[dep_child.name] = fi.formula.name
stack << FormulaInstaller.new(dep_child.to_formula)
p dep_child.name
if license_blist.include? dep_child.to_formula().license
p "VIOLATION #{dep_child.name}"
dep_lineage = [dep_child.name]
curr_dep = dep_child.name
until dep_graph[curr_dep].blank?
curr_dep = dep_graph[curr_dep]
dep_lineage << curr_dep
end
p dep_lineage.reverse.map{ |dep|}.compact
end end
end end
end end
end