#7 license-validate doesn't accept `WITH` operator
Closed by msuchy. Opened by omajid.

I have a piece of code that's under GPL and a linking exception: https://github.com/libgit2/libgit2/blob/main/COPYING. The Fedora licensing guidelines suggest I should use WITH for this: https://docs.fedoraproject.org/en-US/legal/license-field/#_license_with_exception

But license-validate wont accept the license with the WITH operator:

$ rpm -q license-validate
license-validate-12-1.fc37.noarch
$ license-validate "GPL-2.0-only WITH GCC-exception-2.0"
No terminal defined for 'W' at line 1 col 14
GPL-2.0-only WITH GCC-exception-2.0
             ^
Expecting: {'OR', 'AND'}
$ license-validate "(GPL-2.0-only with GCC-exception-2.0)"
No terminal defined for 'w' at line 1 col 15
(GPL-2.0-only with GCC-exception-2.0)
              ^
Expecting: {'AND', 'RPAR', 'OR'}
$ license-validate "(GPL-2.0-only WITH GCC-exception-2.0)"
No terminal defined for 'W' at line 1 col 15
(GPL-2.0-only WITH GCC-exception-2.0)
              ^
Expecting: {'OR', 'AND', 'RPAR'}

@omajid You should use https://github.com/nexB/license-expression/ to parse and validate license expressions IMHO. This is in Python like your tools, used in Scancode, tern, REUSE and other places. (I maintain it and scancode-toolkit that you may be using based on some of the license keys you use).

This is valid. I want to get hands on this in the upcoming days.

@msuchy note that the license-expression library has been packaged at https://src.fedoraproject.org/rpms/python-license-expression/ by @carmenbianca
And with a set of Fedora license "ids" like in https://pagure.io/copr/license-validate/blob/main/f/fedora-approved-licenses.txt you could both process "legacy" things such as AGPLv3 with exceptions and all the values in https://pagure.io/copr/license-validate/blob/main/f/fedora-approved-licenses.txt in addition to the SPDX licenses.

>>> from license_expression import *
>>> exp = "AGPLv3 with exceptions"
>>> Licensing().parse(exp)
LicenseWithExceptionSymbol(license_symbol=LicenseSymbol('AGPLv3', is_exception=False), exception_symbol=LicenseSymbol('exce
ptions', is_exception=False))
>>> str(Licensing().parse(exp))
'AGPLv3 WITH exceptions'
>>> Licensing()         
>>> l.license_keys(exp)
['AGPLv3', 'exceptions']

Just food for thoughts.

Hmm, the library looks great. But the packaged version is desperately old. I pinged the maintainer in https://bugzilla.redhat.com/show_bug.cgi?id=1972010

I dived into that "WITH exception" thing.

In the package fedora-license-data we do not have a separate list of exceptions. We have it as a separate license. E.g., https://gitlab.com/fedora/legal/fedora-license-data/-/blob/main/data/GPL-2.0-only_WITH_GCC-exception-2.0.toml

So from the view of this tool, it is a separate term. And when I try it with a nightly build, this whole license including the WITH is accepted.

Metadata Update from @msuchy:
- Issue status updated to: Closed (was: Open)

This issue has been migrated to GitHub: https://github.com/fedora-copr/license-validate/issues/7
Don't forget to subscribe for notifications about new comments.

Metadata