From fe5b757712aa99ff1ff10d2304ac320100635200 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Wed, 1 Sep 2021 08:44:53 -0500 Subject: classes/create-spdx: Add special exception for Public Domain license The Public Domain license (PD) needs a special exception in the license processing since there is no common license text to be extracted for these licenses. Signed-off-by: Joshua Watt Signed-off-by: Richard Purdie --- meta/classes/create-spdx.bbclass | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass index aa640977f9..f72b7b762e 100644 --- a/meta/classes/create-spdx.bbclass +++ b/meta/classes/create-spdx.bbclass @@ -51,6 +51,23 @@ def convert_license_to_spdx(lic, document, d): import oe.spdx license_data = d.getVar("SPDX_LICENSE_DATA") + + def add_extracted_license(ident, name, text): + nonlocal document + + for lic_data in license_data["licenses"]: + if lic_data["licenseId"] == ident: + return False + + spdx_lic = oe.spdx.SPDXExtractedLicensingInfo() + spdx_lic.name = name + spdx_lic.licenseId = ident + spdx_lic.extractedText = text + + document.hasExtractedLicensingInfos.append(spdx_lic) + + return True + def convert(l): if l == "(" or l == ")": return l @@ -67,19 +84,11 @@ def convert_license_to_spdx(lic, document, d): return spdx_license spdx_license = "LicenseRef-" + l - for spdx_lic in document.hasExtractedLicensingInfos: - if spdx_lic.licenseId == spdx_license: - return spdx_license - - bb.warn("No SPDX License found for %s. Creating a place holder" % l) - spdx_lic = oe.spdx.SPDXExtractedLicensingInfo() - spdx_lic.name = l - spdx_lic.licenseId = spdx_license - # TODO: Extract the actual license text from the common license files - spdx_lic.extractedText = "This software is licensed under the %s license" % l - - document.hasExtractedLicensingInfos.append(spdx_lic) + if l == "PD": + add_extracted_license(spdx_license, l, "Software released to the public domain") + elif add_extracted_license(spdx_license, l, "This software is licensed under the %s license" % l): + bb.warn("No SPDX License found for %s. Creating a place holder" % l) return spdx_license -- cgit 1.2.3-korg