Bug 14890

Summary: create-spdx should parse license strings with and without spaces between license terms
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Saul Wold <saul.wold>
Component: Scripts and ToolsAssignee: Joshua Watt <JPEWhacker>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: JPEWhacker, louis.rannou, raj.khem, randy.macleod, ross.burton
Version: unspecified   
Target Milestone: 4.3 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Saul Wold 2022-08-16 15:34:23 UTC
meta-oe/meta-perl is showing some errors with some perl recipes that are not getting parsed correctly because there are no spaces between the license and the "op" (|, &).

ERROR: libdigest-hmac-perl-1.03-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libipc-signal-perl-1.00-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libmime-types-perl-2.17-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libproc-waitstat-perl-1.00-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libdigest-sha1-perl-2.13-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libxml-libxml-perl-2.0134-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libnet-telnet-perl-3.05-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libio-socket-ssl-perl-2.074-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libauthen-sasl-perl-2.16-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later
ERROR: libnet-ldap-perl-0.68-r0 do_create_spdx: Cannot find any text for license Artistic-1.0|GPL-1.0-or-later

We should extend the license parser to understand this correctly
Comment 1 Louis Rannou 2023-05-05 11:55:43 UTC
Hello ! It's possible for me to work on this
Comment 2 Louis Rannou 2023-05-09 13:29:59 UTC
I could not find any relation to "&" and "|" operators in the SPDX specifications. As they are use as shortcuts to "AND" and "OR", I would say spaces are required.

Note that recipes have been updated and now have spaces around the operators.

As the specification does not accept '&' and '|' in the identifier, it is possible to treat them as operators.

Do we want that ?
Comment 3 Joshua Watt 2023-05-23 16:52:11 UTC
Not quite sure what you mean by "operators"? The LICENSE field isn't _exactly_ an SPDX license string because it was developed indepndently and uses it's own syntax (& and |). However, it does accept SPDX license identifier names for the licenses, since this is a standardized way to enumerate licenses and saves us some of the trouble of enumerating them ourselves.

The code to convert OE license strings to SPDX licenes strings is pretty dumb and can't handle spaces, which is more or less the problem being described here. Either A) create-spdx.bbclass license parsing should get smarter to handle spaces, B) spaces should no longer be allowed elsewhere in the license code to match create-spdx.bbclass (otherwise, the licenses _only_ fail when SPDX is enabled, or C) LICENSE should be defined as the SPDX license string, dropping support for & and | in favor of AND, OR, et. al.

C) is probably the least likely since it's a pretty major breaking change, A) is probably the most expedient.