Merge pull request #7871 from MLH-Fellowship/license-forbidden
License forbidden
This commit is contained in:
commit
a2ae8741a9
@ -111,6 +111,10 @@ module Homebrew
|
|||||||
description: "Output this many lines of output on formula `system` failures.",
|
description: "Output this many lines of output on formula `system` failures.",
|
||||||
default: 15,
|
default: 15,
|
||||||
},
|
},
|
||||||
|
HOMEBREW_FORBIDDEN_LICENSES: {
|
||||||
|
description: "A space-separated list of licenses. Homebrew will refuse to install a " \
|
||||||
|
"formula if that formula or any of its dependencies has a license on this list.",
|
||||||
|
},
|
||||||
HOMEBREW_FORCE_BREWED_CURL: {
|
HOMEBREW_FORCE_BREWED_CURL: {
|
||||||
description: "If set, always use a Homebrew-installed `curl`(1) rather than the system version. " \
|
description: "If set, always use a Homebrew-installed `curl`(1) rather than the system version. " \
|
||||||
"Automatically set if the system version of `curl` is too old.",
|
"Automatically set if the system version of `curl` is too old.",
|
||||||
|
|||||||
@ -17,6 +17,7 @@ require "linkage_checker"
|
|||||||
require "install"
|
require "install"
|
||||||
require "messages"
|
require "messages"
|
||||||
require "cask/cask_loader"
|
require "cask/cask_loader"
|
||||||
|
require "cmd/install"
|
||||||
require "find"
|
require "find"
|
||||||
|
|
||||||
class FormulaInstaller
|
class FormulaInstaller
|
||||||
@ -148,6 +149,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?
|
||||||
|
forbidden_license_check
|
||||||
|
|
||||||
check_install_sanity
|
check_install_sanity
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1102,4 +1105,27 @@ class FormulaInstaller
|
|||||||
|
|
||||||
$stderr.puts @requirement_messages
|
$stderr.puts @requirement_messages
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def forbidden_license_check
|
||||||
|
forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses.to_s.split(" ")
|
||||||
|
return if forbidden_licenses.blank?
|
||||||
|
|
||||||
|
compute_dependencies.each do |dep, _|
|
||||||
|
next if @ignore_deps
|
||||||
|
|
||||||
|
dep_f = dep.to_formula
|
||||||
|
next unless forbidden_licenses.include? dep_f.license
|
||||||
|
|
||||||
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
|
The installation of #{formula.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
return if @only_deps
|
||||||
|
|
||||||
|
return unless forbidden_licenses.include? formula.license
|
||||||
|
|
||||||
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
|
#{formula.name} has a forbidden license #{formula.license}.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -161,6 +161,12 @@ RSpec.shared_context "integration test" do
|
|||||||
content = <<~RUBY
|
content = <<~RUBY
|
||||||
url "https://brew.sh/#{name}-1.0"
|
url "https://brew.sh/#{name}-1.0"
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
|
when "package_license"
|
||||||
|
content = <<~RUBY
|
||||||
|
url "https://brew.sh/#patchelf-1.0"
|
||||||
|
license "0BSD"
|
||||||
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
Formulary.core_path(name).tap do |formula_path|
|
Formulary.core_path(name).tap do |formula_path|
|
||||||
|
|||||||
@ -1394,6 +1394,9 @@ Note that environment variables must have a value set to be detected. For exampl
|
|||||||
|
|
||||||
*Default:* `15`.
|
*Default:* `15`.
|
||||||
|
|
||||||
|
* `HOMEBREW_FORBIDDEN_LICENSES`:
|
||||||
|
A space-separated list of licenses. Homebrew will refuse to install a formula if that formula or any of its dependencies has a license on this list.
|
||||||
|
|
||||||
* `HOMEBREW_FORCE_BREWED_CURL`:
|
* `HOMEBREW_FORCE_BREWED_CURL`:
|
||||||
If set, always use a Homebrew-installed `curl`(1) rather than the system version. Automatically set if the system version of `curl` is too old.
|
If set, always use a Homebrew-installed `curl`(1) rather than the system version. Automatically set if the system version of `curl` is too old.
|
||||||
|
|
||||||
|
|||||||
@ -1799,6 +1799,10 @@ Output this many lines of output on formula \fBsystem\fR failures\.
|
|||||||
\fIDefault:\fR \fB15\fR\.
|
\fIDefault:\fR \fB15\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fBHOMEBREW_FORBIDDEN_LICENSES\fR
|
||||||
|
A space\-separated list of licenses\. Homebrew will refuse to install a formula if that formula or any of its dependencies has a license on this list\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fBHOMEBREW_FORCE_BREWED_CURL\fR
|
\fBHOMEBREW_FORCE_BREWED_CURL\fR
|
||||||
If set, always use a Homebrew\-installed \fBcurl\fR(1) rather than the system version\. Automatically set if the system version of \fBcurl\fR is too old\.
|
If set, always use a Homebrew\-installed \fBcurl\fR(1) rather than the system version\. Automatically set if the system version of \fBcurl\fR is too old\.
|
||||||
.
|
.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user