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 <[email protected]> --- 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
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#149197): https://lists.openembedded.org/g/openembedded-core/message/149197 Mute This Topic: https://lists.openembedded.org/mt/81215300/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
