aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2021-09-01 08:44:53 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-03 09:03:36 +0100
commitfe5b757712aa99ff1ff10d2304ac320100635200 (patch)
tree549bbdf8c51d6e106a6e6eaf4855b7703d316f23
parent19c61ec3986213b336d965d90b1329085e7d6179 (diff)
downloadopenembedded-core-contrib-fe5b757712aa99ff1ff10d2304ac320100635200.tar.gz
openembedded-core-contrib-fe5b757712aa99ff1ff10d2304ac320100635200.tar.bz2
openembedded-core-contrib-fe5b757712aa99ff1ff10d2304ac320100635200.zip
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 <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/create-spdx.bbclass33
1 files 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