From 0ff9bf60d2107a78b70bda1ff0c2d2e8dce5dce7 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Mon, 12 Aug 2024 20:04:55 -0400 Subject: [PATCH] formula_auditor: reject more SPDX licenses Also require licenses on non-disabled formulae --- Library/Homebrew/formula_auditor.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index 1c668c98b78043..effb093c100979 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -199,14 +199,30 @@ def audit_name "LGPL-3.0" => ["LGPL-3.0-only", "LGPL-3.0-or-later"], }.freeze + # The following licenses are non-free/open based on multiple sources (e.g. Debian, Fedora, FSF, OSI, ...) + INCOMPATIBLE_LICENSES = [ + "JSON", # https://wiki.debian.org/DFSGLicenses#JSON_evil_license + "OPL-1.0", # https://wiki.debian.org/DFSGLicenses#Open_Publication_License_.28OPL.29_v1.0 + ].freeze + INCOMPATIBLE_LICENSE_PREFIXES = [ + "BUSL", # https://spdx.org/licenses/BUSL-1.1.html#notes + "CC-BY-NC", # https://people.debian.org/~bap/dfsg-faq.html#no_commercial + "Elastic", # https://www.elastic.co/licensing/elastic-license#Limitations + "SSPL", # https://fedoraproject.org/wiki/Licensing/SSPL#License_Notes + ].freeze + def audit_license if formula.license.present? licenses, exceptions = SPDX.parse_license_expression formula.license - sspl_licensed = licenses.any? { |license| license.to_s.start_with?("SSPL") } - if sspl_licensed && @core_tap + incompatible_licenses = licenses.select do |license| + license.to_s.start_with?(*INCOMPATIBLE_LICENSE_PREFIXES) || INCOMPATIBLE_LICENSES.include?(license.to_s) + end + if incompatible_licenses.present? && @core_tap problem <<~EOS - Formula #{formula.name} is SSPL-licensed. Software under the SSPL must not be packaged in homebrew/core. + Formula #{formula.name} contains incompatible licenses: #{incompatible_licenses}. + Formulae in homebrew/core must either use a Debian Free Software Guidelines license + or be released into the public domain. See https://docs.brew.sh/License-Guidelines EOS end @@ -255,7 +271,7 @@ def audit_license problem "Formula license #{licenses} does not match GitHub license #{Array(github_license)}." - elsif @new_formula && @core_tap + elsif @core_tap && !formula.disabled? problem "Formulae in homebrew/core must specify a license." end end