All of lore.kernel.org
 help / color / mirror / Atom feed
* [poky-contrib][PATCH 1/4] oe.license: Add functions to split and canonicalise license strings.
@ 2021-03-09 23:31 Meh Mbeh Ida Delphine
  2021-03-09 23:31 ` [poky-contrib][PATCH 2/4] package.bbclass: Displays warnings for just licences in recipes Meh Mbeh Ida Delphine
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Meh Mbeh Ida Delphine @ 2021-03-09 23:31 UTC (permalink / raw)
  To: openembedded-core

These functions ensures recipe LICENSE strings are split into their individual licenses and then canonicalised to easily enable their matching with licenses of sources during the packaging process.

Signed-off-by: Ida Delphine <idadelm@gmail.com>
---
 meta/lib/oe/license.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 665d32ecbb..9e9957be1d 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -236,3 +236,26 @@ def list_licenses(licensestr):
     except SyntaxError as exc:
         raise LicenseSyntaxError(licensestr, exc)
     return visitor.licenses
+
+def canonical_license(license, d):
+    """
+    Return the canonical (SPDX) form of the license if available (so GPLv3
+    becomes GPL-3.0), for the license named 'X+', return canonical form of
+    'X' if available and the tailing '+' (so GPLv3+ becomes GPL-3.0+),
+    or the passed license if there is no canonical form.
+    """
+    lic = d.getVarFlag('SPDXLICENSEMAP', license) or ""
+    if not lic and license.endswith('+'):
+        lic = d.getVarFlag('SPDXLICENSEMAP', license.rstrip('+'))
+        if lic:
+            lic += '+'
+    return lic or license
+
+def split_spdx_lic(licensestr,d):
+    """
+    Split the license strings and returns a set of the
+    canonicalised licenses.
+    """
+    split_lic = list_licenses(licensestr)
+    spdx_lic = set([canonical_license(l, d) for l in split_lic])
+    return spdx_lic
\ No newline at end of file
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-03-12 17:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 23:31 [poky-contrib][PATCH 1/4] oe.license: Add functions to split and canonicalise license strings Meh Mbeh Ida Delphine
2021-03-09 23:31 ` [poky-contrib][PATCH 2/4] package.bbclass: Displays warnings for just licences in recipes Meh Mbeh Ida Delphine
2021-03-12 16:57   ` [OE-core] " Peter Kjellerstedt
2021-03-09 23:31 ` [poky-contrib][PATCH 3/4] package.bbclass: Add handle_qa_error check Meh Mbeh Ida Delphine
2021-03-12 16:44   ` [OE-core] " Peter Kjellerstedt
2021-03-12 16:54     ` Christopher Larson
2021-03-12 16:59       ` Richard Purdie
2021-03-12 17:29         ` Meh Mbeh Ida Delphine
2021-03-09 23:31 ` [poky-contrib][PATCH 4/4] Moved logic to get filelics from package.bbclass to license.py Meh Mbeh Ida Delphine
2021-03-12 16:18   ` [OE-core] " Peter Kjellerstedt
2021-03-12 17:38     ` Meh Mbeh Ida Delphine
2021-03-12 15:59 ` [OE-core] [poky-contrib][PATCH 1/4] oe.license: Add functions to split and canonicalise license strings Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.