diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index d975d131f9..42089d4d87 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -211,7 +211,13 @@ module Homebrew puts "From: #{Formatter.url(github_info(f))}" - puts "License: #{f.license.join(", ")}" if 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? ohai "Dependencies" diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ba44997d7e..3ca72994b1 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -337,12 +337,12 @@ module Homebrew def audit_license if formula.license.present? - non_standard_licenses = [] - formula.license.each do |license| + non_standard_licenses = formula.license.map do |license| + next if license == :public_domain next if @spdx_data["licenses"].any? { |spdx| spdx["licenseId"] == license } - non_standard_licenses << license - end + license + end.compact if non_standard_licenses.present? problem "Formula #{formula.name} contains non-standard SPDX licenses: #{non_standard_licenses}." diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 735f333424..10ab763470 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2221,6 +2221,8 @@ class Formula # 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. #
license "BSD-2-Clause"+ #
license ["MIT", "GPL-2.0"]+ #
license :public_domaindef license(args = nil) if args.nil? @licenses diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index d9b5e6d1c3..e70d60089e 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1129,14 +1129,17 @@ class FormulaInstaller end def forbidden_license_check - forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses.to_s.split(" ") + forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses + .to_s + .sub("Public Domain", "public_domain") + .split(" ") 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 } + next unless dep_f.license.all? { |license| forbidden_licenses.include?(license.to_s) } raise CannotInstallFormulaError, <<~EOS The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: #{dep_f.license}. @@ -1144,7 +1147,7 @@ class FormulaInstaller end return if @only_deps - return unless formula.license.all? { |license| forbidden_licenses.include? license } + return unless formula.license.all? { |license| forbidden_licenses.include?(license.to_s) } raise CannotInstallFormulaError, <<~EOS #{formula.name}'s licenses are all forbidden: #{formula.license}. diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index f3fad76169..bdc44a8e89 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -91,7 +91,9 @@ Try to summarise from the [`homepage`](https://rubydoc.brew.sh/Formula#homepage% **We don’t accept new formulae into Homebrew/homebrew-core without a [`license`](https://rubydoc.brew.sh/Formula#license-class_method)!** -Find the license identifier from the [SPDX License List](https://spdx.org/licenses/). We only accept licenses from this list that are a [Debian Free Software Guidelines license](https://wiki.debian.org/DFSGLicenses). +We only accept formulae that use a [Debian Free Software Guidelines license](https://wiki.debian.org/DFSGLicenses) or are released into the public domain following [DFSG Guidelines on Public Domain software](https://wiki.debian.org/DFSGLicenses#Public_Domain). + +Use the license identifier from the [SPDX License List](https://spdx.org/licenses/) e.g. `license "BSD-2-Clause"`, or use `license :public_domain` for public domain software. If the software is available under multiple licenses, you should list them all in an array: