Merge branch 'license-forbidden' of https://github.com/MLH-Fellowship/brew into license-forbidden
This commit is contained in:
commit
fc146873ee
@ -112,7 +112,7 @@ module Homebrew
|
|||||||
default: 15,
|
default: 15,
|
||||||
},
|
},
|
||||||
HOMEBREW_FORBIDDEN_LICENSES: {
|
HOMEBREW_FORBIDDEN_LICENSES: {
|
||||||
description: "Use this environment variable to define a blacklist of space separated licenses and Homebrew " \
|
description: "Use this environment variable to define a denylist of space separated licenses and Homebrew " \
|
||||||
"will avoid installing the packages with those licenses.",
|
"will avoid installing the packages with those licenses.",
|
||||||
},
|
},
|
||||||
HOMEBREW_FORCE_BREWED_CURL: {
|
HOMEBREW_FORCE_BREWED_CURL: {
|
||||||
|
@ -1106,23 +1106,17 @@ class FormulaInstaller
|
|||||||
$stderr.puts @requirement_messages
|
$stderr.puts @requirement_messages
|
||||||
end
|
end
|
||||||
|
|
||||||
def env_forbidden_licenses
|
def forbidden_license_check
|
||||||
Homebrew::EnvConfig.forbidden_licenses.split(" ")
|
forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses.split(" ")
|
||||||
end
|
return if forbidden_licenses.blank?
|
||||||
|
|
||||||
def forbidden_license_check(f)
|
if forbidden_licenses.include? formula.license
|
||||||
return if ENV["HOMEBREW_FORBIDDEN_LICENSES"].blank?
|
|
||||||
|
|
||||||
forbidden_licenses = env_forbidden_licenses
|
|
||||||
|
|
||||||
if forbidden_licenses.include? f.license
|
|
||||||
raise CannotInstallFormulaError, <<~EOS
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
#{f.name} has a forbidden license #{f.license}.
|
#{formula.name} has a forbidden license #{formula.license}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
fi = FormulaInstaller.new(f)
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user