formula: update license specification
This commit is contained in:
parent
90d9454d1e
commit
60ec30d41e
@ -68,6 +68,10 @@ Style/HashTransformKeys:
|
|||||||
Style/HashTransformValues:
|
Style/HashTransformValues:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
# Allow for license expressions
|
||||||
|
Style/HashAsLastArrayItem:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
# Enabled now LineLength is lowish.
|
# Enabled now LineLength is lowish.
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|||||||
@ -61,6 +61,8 @@ Metrics/MethodLength:
|
|||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Max: 600
|
Max: 600
|
||||||
|
Exclude:
|
||||||
|
- 'test/**/*'
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Max: 90
|
Max: 90
|
||||||
@ -143,3 +145,9 @@ Style/GuardClause:
|
|||||||
# so many of these in formulae but none in here
|
# so many of these in formulae but none in here
|
||||||
Style/StringConcatenation:
|
Style/StringConcatenation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
# don't want this for formulae but re-enabled for Library/Homebrew
|
||||||
|
Style/HashAsLastArrayItem:
|
||||||
|
Enabled: true
|
||||||
|
Exclude:
|
||||||
|
- 'test/utils/spdx_spec.rb'
|
||||||
|
|||||||
@ -8,6 +8,7 @@ require "formula"
|
|||||||
require "keg"
|
require "keg"
|
||||||
require "tab"
|
require "tab"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "utils/spdx"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
@ -211,13 +212,7 @@ module Homebrew
|
|||||||
|
|
||||||
puts "From: #{Formatter.url(github_info(f))}"
|
puts "From: #{Formatter.url(github_info(f))}"
|
||||||
|
|
||||||
if f.license.present?
|
puts "License: #{SPDX.license_expression_to_string f.license}" if f.license.present?
|
||||||
licenses = f.license
|
|
||||||
.map(&:to_s)
|
|
||||||
.join(", ")
|
|
||||||
.sub("public_domain", "Public Domain")
|
|
||||||
puts "License: #{licenses}"
|
|
||||||
end
|
|
||||||
|
|
||||||
unless f.deps.empty?
|
unless f.deps.empty?
|
||||||
ohai "Dependencies"
|
ohai "Dependencies"
|
||||||
|
|||||||
@ -2219,18 +2219,20 @@ class Formula
|
|||||||
# @!attribute [w]
|
# @!attribute [w]
|
||||||
# The SPDX ID of the open-source license that the formula uses.
|
# The SPDX ID of the open-source license that the formula uses.
|
||||||
# Shows when running `brew info`.
|
# Shows when running `brew info`.
|
||||||
# Multiple licenses means that the software is licensed under multiple licenses.
|
# Use `:any`, `:all` or `:with` to describe complex license expressions.
|
||||||
# Do not use multiple licenses if e.g. different parts are under different licenses.
|
# `:any` should be used when the user can choose which license to use.
|
||||||
|
# `:all` should be used when the user must use all licenses.
|
||||||
|
# `:with` should be used to specify a valid SPDX exception.
|
||||||
|
# Add `+` to an identifier to indicate that the formulae can be
|
||||||
|
# licensed under later versions of the same license.
|
||||||
|
# @see https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/ SPDX license expression guide
|
||||||
# <pre>license "BSD-2-Clause"</pre>
|
# <pre>license "BSD-2-Clause"</pre>
|
||||||
# <pre>license ["MIT", "GPL-2.0"]</pre>
|
# <pre>license "EPL-1.0+"</pre>
|
||||||
|
# <pre>license any_of: ["MIT", "GPL-2.0-only"]</pre>
|
||||||
|
# <pre>license all_of: ["MIT", "GPL-2.0-only"]</pre>
|
||||||
|
# <pre>license "GPL-2.0-only" => { with: "LLVM-exception" }</pre>
|
||||||
# <pre>license :public_domain</pre>
|
# <pre>license :public_domain</pre>
|
||||||
def license(args = nil)
|
attr_rw :license
|
||||||
if args.nil?
|
|
||||||
@licenses
|
|
||||||
else
|
|
||||||
@licenses = Array(args)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# @!attribute [w] homepage
|
# @!attribute [w] homepage
|
||||||
# The homepage for the software. Used by users to get more information
|
# The homepage for the software. Used by users to get more information
|
||||||
|
|||||||
@ -19,6 +19,7 @@ require "messages"
|
|||||||
require "cask/cask_loader"
|
require "cask/cask_loader"
|
||||||
require "cmd/install"
|
require "cmd/install"
|
||||||
require "find"
|
require "find"
|
||||||
|
require "utils/spdx"
|
||||||
|
|
||||||
class FormulaInstaller
|
class FormulaInstaller
|
||||||
include FormulaCellarChecks
|
include FormulaCellarChecks
|
||||||
@ -1130,24 +1131,29 @@ class FormulaInstaller
|
|||||||
.to_s
|
.to_s
|
||||||
.sub("Public Domain", "public_domain")
|
.sub("Public Domain", "public_domain")
|
||||||
.split(" ")
|
.split(" ")
|
||||||
|
.to_h do |license|
|
||||||
|
[license, SPDX.license_version_info(license)]
|
||||||
|
end
|
||||||
|
|
||||||
return if forbidden_licenses.blank?
|
return if forbidden_licenses.blank?
|
||||||
|
|
||||||
compute_dependencies.each do |dep, _|
|
compute_dependencies.each do |dep, _|
|
||||||
next if @ignore_deps
|
next if @ignore_deps
|
||||||
|
|
||||||
dep_f = dep.to_formula
|
dep_f = dep.to_formula
|
||||||
next unless dep_f.license.all? { |license| forbidden_licenses.include?(license.to_s) }
|
next unless SPDX.licenses_forbid_installation? dep_f.license, forbidden_licenses
|
||||||
|
|
||||||
raise CannotInstallFormulaError, <<~EOS
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: #{dep_f.license}.
|
The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden:
|
||||||
|
#{SPDX.license_expression_to_string dep_f.license}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
return if @only_deps
|
return if @only_deps
|
||||||
|
|
||||||
return unless formula.license.all? { |license| forbidden_licenses.include?(license.to_s) }
|
return unless SPDX.licenses_forbid_installation? formula.license, forbidden_licenses
|
||||||
|
|
||||||
raise CannotInstallFormulaError, <<~EOS
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
#{formula.name}'s licenses are all forbidden: #{formula.license}.
|
#{formula.name}'s licenses are all forbidden: #{SPDX.license_expression_to_string formula.license}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user