formula: update license specification
This commit is contained in:
parent
90d9454d1e
commit
60ec30d41e
@ -68,6 +68,10 @@ Style/HashTransformKeys:
|
||||
Style/HashTransformValues:
|
||||
Enabled: true
|
||||
|
||||
# Allow for license expressions
|
||||
Style/HashAsLastArrayItem:
|
||||
Enabled: false
|
||||
|
||||
# Enabled now LineLength is lowish.
|
||||
Style/IfUnlessModifier:
|
||||
Enabled: true
|
||||
|
||||
@ -61,6 +61,8 @@ Metrics/MethodLength:
|
||||
Metrics/ModuleLength:
|
||||
Enabled: true
|
||||
Max: 600
|
||||
Exclude:
|
||||
- 'test/**/*'
|
||||
Metrics/PerceivedComplexity:
|
||||
Enabled: true
|
||||
Max: 90
|
||||
@ -143,3 +145,9 @@ Style/GuardClause:
|
||||
# so many of these in formulae but none in here
|
||||
Style/StringConcatenation:
|
||||
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 "tab"
|
||||
require "json"
|
||||
require "utils/spdx"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
@ -211,13 +212,7 @@ module Homebrew
|
||||
|
||||
puts "From: #{Formatter.url(github_info(f))}"
|
||||
|
||||
if f.license.present?
|
||||
licenses = f.license
|
||||
.map(&:to_s)
|
||||
.join(", ")
|
||||
.sub("public_domain", "Public Domain")
|
||||
puts "License: #{licenses}"
|
||||
end
|
||||
puts "License: #{SPDX.license_expression_to_string f.license}" if f.license.present?
|
||||
|
||||
unless f.deps.empty?
|
||||
ohai "Dependencies"
|
||||
|
||||
@ -2219,18 +2219,20 @@ class Formula
|
||||
# @!attribute [w]
|
||||
# The SPDX ID of the open-source license that the formula uses.
|
||||
# Shows when running `brew info`.
|
||||
# Multiple licenses means that the software is licensed under multiple licenses.
|
||||
# Do not use multiple licenses if e.g. different parts are under different licenses.
|
||||
# Use `:any`, `:all` or `:with` to describe complex license expressions.
|
||||
# `: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 ["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>
|
||||
def license(args = nil)
|
||||
if args.nil?
|
||||
@licenses
|
||||
else
|
||||
@licenses = Array(args)
|
||||
end
|
||||
end
|
||||
attr_rw :license
|
||||
|
||||
# @!attribute [w] homepage
|
||||
# The homepage for the software. Used by users to get more information
|
||||
|
||||
@ -19,6 +19,7 @@ require "messages"
|
||||
require "cask/cask_loader"
|
||||
require "cmd/install"
|
||||
require "find"
|
||||
require "utils/spdx"
|
||||
|
||||
class FormulaInstaller
|
||||
include FormulaCellarChecks
|
||||
@ -1130,24 +1131,29 @@ class FormulaInstaller
|
||||
.to_s
|
||||
.sub("Public Domain", "public_domain")
|
||||
.split(" ")
|
||||
.to_h do |license|
|
||||
[license, SPDX.license_version_info(license)]
|
||||
end
|
||||
|
||||
return if forbidden_licenses.blank?
|
||||
|
||||
compute_dependencies.each do |dep, _|
|
||||
next if @ignore_deps
|
||||
|
||||
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
|
||||
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
|
||||
end
|
||||
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
|
||||
#{formula.name}'s licenses are all forbidden: #{formula.license}.
|
||||
#{formula.name}'s licenses are all forbidden: #{SPDX.license_expression_to_string formula.license}.
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user