forbidden-license: include method in module scope for module-wide access
This commit is contained in:
parent
d24f911410
commit
a161829927
@ -342,24 +342,31 @@ module Homebrew
|
|||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e.message
|
ofail e.message
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def forbidden_license_check(f)
|
def get_forbidden_licenses
|
||||||
forbidden_licenses = ENV["HOMEBREW_FORBIDDEN_LICENSES"].split(" ")
|
Homebrew::EnvConfig.forbidden_licenses.split(" ")
|
||||||
|
end
|
||||||
|
|
||||||
if forbidden_licenses.include? f.license
|
def forbidden_license_check(f)
|
||||||
raise CannotInstallFormulaError, <<~EOS
|
forbidden_licenses = get_forbidden_licenses
|
||||||
|
|
||||||
|
if forbidden_licenses.include? f.license
|
||||||
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
#{f.name} has a forbidden license #{f.license}.
|
#{f.name} has a forbidden license #{f.license}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f)
|
fi = FormulaInstaller.new(f)
|
||||||
fi.compute_dependencies.each do |dep, _|
|
fi.compute_dependencies.each do |dep, _|
|
||||||
dep_f = dep.to_formula
|
dep_f = dep.to_formula
|
||||||
next unless forbidden_licenses.include? dep_f.license
|
next unless forbidden_licenses.include? dep_f.license
|
||||||
|
|
||||||
raise CannotInstallFormulaError, <<~EOS
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
The installation of #{f.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}.
|
The installation of #{f.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}.
|
||||||
EOS
|
EOS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -148,6 +148,8 @@ class FormulaInstaller
|
|||||||
def prelude
|
def prelude
|
||||||
Tab.clear_cache
|
Tab.clear_cache
|
||||||
verify_deps_exist unless ignore_deps?
|
verify_deps_exist unless ignore_deps?
|
||||||
|
Homebrew.forbidden_license_check(formula) unless ENV["HOMEBREW_FORBIDDEN_LICENSES"].blank?
|
||||||
|
|
||||||
check_install_sanity
|
check_install_sanity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user