Skip to content

Commit

Permalink
formula_auditor: reject more SPDX licenses
Browse files Browse the repository at this point in the history
Also require licenses on non-disabled formulae
  • Loading branch information
cho-m committed Sep 2, 2024
1 parent 33f53dd commit 0ff9bf6
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Library/Homebrew/formula_auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0ff9bf6

Please sign in to comment.