* [PATCH v2 0/1] license: Add support for SPDX 2.0 operators
@ 2016-07-04 8:25 Sergei Miroshnichenko
2016-07-04 8:25 ` [PATCH v2 1/1] " Sergei Miroshnichenko
2016-07-11 8:47 ` [PATCH v2 0/1] " Sergei Miroshnichenko
0 siblings, 2 replies; 3+ messages in thread
From: Sergei Miroshnichenko @ 2016-07-04 8:25 UTC (permalink / raw)
To: openembedded-core
Cc: WolfgangDenkwd, Alexander Dyachenko, Roger Meier,
Sergei Miroshnichenko
Composite SPDX license expressions can be constructed using "OR",
"AND" and "WITH" operators: map them to "|" and "&" operators
accordingly.
Recognize long form license identifiers: "[DocumentRef-XXX:][LicenseRef-]YYY".
Tested on the following expressions:
LICENSE = "Artistic-1.0"
LICENSE = "LicenseRef-Artistic-1.0 AND NASA-1.3"
LICENSE = "(LicenseRef-Artistic-1.0 WITH GPL-3.0-with-GCC-exception)
OR (DocumentRef-spdx-tool-1.2:LicenseRef-NASA-1.3 AND GPL-2.0+)"
Reference:
https://spdx.org/sites/spdx/files/SPDX-2.0.pdf Appendix IV: SPDX License Expression
Sergei Miroshnichenko (1):
license: Add support for SPDX 2.0 operators
meta/classes/license.bbclass | 17 ++++++++++-------
meta/lib/oe/license.py | 21 ++++++++++++++++-----
2 files changed, 26 insertions(+), 12 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] license: Add support for SPDX 2.0 operators
2016-07-04 8:25 [PATCH v2 0/1] license: Add support for SPDX 2.0 operators Sergei Miroshnichenko
@ 2016-07-04 8:25 ` Sergei Miroshnichenko
2016-07-11 8:47 ` [PATCH v2 0/1] " Sergei Miroshnichenko
1 sibling, 0 replies; 3+ messages in thread
From: Sergei Miroshnichenko @ 2016-07-04 8:25 UTC (permalink / raw)
To: openembedded-core
Cc: WolfgangDenkwd, Alexander Dyachenko, Roger Meier,
Sergei Miroshnichenko
LICENSE can contain "OR", "AND" and "WITH" operators of SPDX: map
them to "|" and "&" accordingly.
Signed-off-by: Sergei Miroshnichenko <sergeimir@emcraft.com>
---
meta/classes/license.bbclass | 17 ++++++++++-------
meta/lib/oe/license.py | 21 ++++++++++++++++-----
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index c543637..8efb545 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -643,20 +643,23 @@ def check_license_format(d):
"""
pn = d.getVar('PN', True)
licenses = d.getVar('LICENSE', True)
- from oe.license import license_operator, license_operator_chars, license_pattern
+ from oe.license import license_operator, license_pattern
elements = list(filter(lambda x: x.strip(), license_operator.split(licenses)))
for pos, element in enumerate(elements):
- if license_pattern.match(element):
- if pos > 0 and license_pattern.match(elements[pos - 1]):
+ operator_match = license_operator.match(element)
+ license_match = license_pattern.match(element)
+
+ if license_match and not operator_match:
+ if pos > 0 and license_pattern.match(elements[pos - 1]) and not license_operator.match(elements[pos - 1]):
bb.warn('%s: LICENSE value "%s" has an invalid format - license names ' \
- 'must be separated by the following characters to indicate ' \
+ 'must be separated by the following operators to indicate ' \
'the license selection: %s' %
- (pn, licenses, license_operator_chars))
- elif not license_operator.match(element):
+ (pn, licenses, license_operator.pattern))
+ elif not operator_match:
bb.warn('%s: LICENSE value "%s" has an invalid separator "%s" that is not ' \
'in the valid list of separators (%s)' %
- (pn, licenses, element, license_operator_chars))
+ (pn, licenses, element, license_operator.pattern))
SSTATETASKS += "do_populate_lic"
do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 39ef965..6769c55 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -40,8 +40,13 @@ class InvalidLicense(LicenseError):
return "invalid characters in license '%s'" % self.license
license_operator_chars = '&|() '
-license_operator = re.compile('([' + license_operator_chars + '])')
-license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$')
+license_operator = re.compile('([' + license_operator_chars + ']|AND|OR|WITH)')
+license_pattern = re.compile('^(?:DocumentRef-[a-zA-Z0-9.\-]+:)?(?:LicenseRef-)?([a-zA-Z0-9_.+\-]+)$')
+
+license_operator_map = {}
+license_operator_map["OR"] = '|'
+license_operator_map["AND"] = '&'
+license_operator_map["WITH"] = '&'
class LicenseVisitor(ast.NodeVisitor):
"""Get elements based on OpenEmbedded license strings"""
@@ -49,11 +54,17 @@ class LicenseVisitor(ast.NodeVisitor):
new_elements = []
elements = list([x for x in license_operator.split(licensestr) if x.strip()])
for pos, element in enumerate(elements):
- if license_pattern.match(element):
- if pos > 0 and license_pattern.match(elements[pos-1]):
+ operator_match = license_operator.match(element)
+ license_match = license_pattern.match(element)
+ if operator_match:
+ if license_operator_map.get(element, None) != None:
+ element = license_operator_map.get(element)
+ elif license_match:
+ if pos > 0 and license_pattern.match(elements[pos-1]) and not license_operator.match(elements[pos-1]):
new_elements.append('&')
+ element = license_match.group(1)
element = '"' + element + '"'
- elif not license_operator.match(element):
+ else:
raise InvalidLicense(element)
new_elements.append(element)
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 0/1] license: Add support for SPDX 2.0 operators
2016-07-04 8:25 [PATCH v2 0/1] license: Add support for SPDX 2.0 operators Sergei Miroshnichenko
2016-07-04 8:25 ` [PATCH v2 1/1] " Sergei Miroshnichenko
@ 2016-07-11 8:47 ` Sergei Miroshnichenko
1 sibling, 0 replies; 3+ messages in thread
From: Sergei Miroshnichenko @ 2016-07-11 8:47 UTC (permalink / raw)
To: openembedded-core, Mariano Lopez; +Cc: Roger Meier, Alexander Dyachenko
ping
Thanks,
Sergei
On 07/04/2016 11:25 AM, Sergei Miroshnichenko wrote:
> Composite SPDX license expressions can be constructed using "OR",
> "AND" and "WITH" operators: map them to "|" and "&" operators
> accordingly.
>
> Recognize long form license identifiers: "[DocumentRef-XXX:][LicenseRef-]YYY".
>
> Tested on the following expressions:
> LICENSE = "Artistic-1.0"
> LICENSE = "LicenseRef-Artistic-1.0 AND NASA-1.3"
> LICENSE = "(LicenseRef-Artistic-1.0 WITH GPL-3.0-with-GCC-exception)
> OR (DocumentRef-spdx-tool-1.2:LicenseRef-NASA-1.3 AND GPL-2.0+)"
>
> Reference:
> https://spdx.org/sites/spdx/files/SPDX-2.0.pdf Appendix IV: SPDX License Expression
>
> Sergei Miroshnichenko (1):
> license: Add support for SPDX 2.0 operators
>
> meta/classes/license.bbclass | 17 ++++++++++-------
> meta/lib/oe/license.py | 21 ++++++++++++++++-----
> 2 files changed, 26 insertions(+), 12 deletions(-)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-11 8:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-04 8:25 [PATCH v2 0/1] license: Add support for SPDX 2.0 operators Sergei Miroshnichenko
2016-07-04 8:25 ` [PATCH v2 1/1] " Sergei Miroshnichenko
2016-07-11 8:47 ` [PATCH v2 0/1] " Sergei Miroshnichenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox