summaryrefslogtreecommitdiffstats
path: root/meta/classes/create-spdx.bbclass
diff options
context:
space:
mode:
authorSaul Wold <Saul.Wold@windriver.com>2021-10-26 18:30:49 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-28 14:16:31 +0100
commit36c184344eb9db87f06ed42f3391ca7c8d83de19 (patch)
tree0b3b78082bca8c0eb98016d09fff2e384d9b9d1f /meta/classes/create-spdx.bbclass
parentb2f859ee6173e74a0a66b7f75c55fc774f454a35 (diff)
downloadpoky-36c184344eb9db87f06ed42f3391ca7c8d83de19.tar.gz
create-spdx: add create_annotation function
This allows code reuse and future usage with relationship annotations (From OE-Core rev: 1f8fdb7dc9d02d0ee3c42674ca16e03f0ec18cba) Signed-off-by: Saul Wold <saul.wold@windriver.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/create-spdx.bbclass')
-rw-r--r--meta/classes/create-spdx.bbclass18
1 files changed, 12 insertions, 6 deletions
diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass
index 739b46e9b3..aa9514121d 100644
--- a/meta/classes/create-spdx.bbclass
+++ b/meta/classes/create-spdx.bbclass
@@ -35,6 +35,17 @@ def get_doc_namespace(d, doc):
35 namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, d.getVar("SPDX_UUID_NAMESPACE")) 35 namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, d.getVar("SPDX_UUID_NAMESPACE"))
36 return "%s/%s-%s" % (d.getVar("SPDX_NAMESPACE_PREFIX"), doc.name, str(uuid.uuid5(namespace_uuid, doc.name))) 36 return "%s/%s-%s" % (d.getVar("SPDX_NAMESPACE_PREFIX"), doc.name, str(uuid.uuid5(namespace_uuid, doc.name)))
37 37
38def create_annotation(d, comment):
39 from datetime import datetime, timezone
40
41 creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
42 annotation = oe.spdx.SPDXAnnotation()
43 annotation.annotationDate = creation_time
44 annotation.annotationType = "OTHER"
45 annotation.annotator = "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION"))
46 annotation.comment = comment
47 return annotation
48
38def recipe_spdx_is_native(d, recipe): 49def recipe_spdx_is_native(d, recipe):
39 return any(a.annotationType == "OTHER" and 50 return any(a.annotationType == "OTHER" and
40 a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and 51 a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and
@@ -412,12 +423,7 @@ python do_create_spdx() {
412 recipe.versionInfo = d.getVar("PV") 423 recipe.versionInfo = d.getVar("PV")
413 recipe.SPDXID = oe.sbom.get_recipe_spdxid(d) 424 recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
414 if bb.data.inherits_class("native", d): 425 if bb.data.inherits_class("native", d):
415 annotation = oe.spdx.SPDXAnnotation() 426 recipe.annotations.append(create_annotation(d, "isNative"))
416 annotation.annotationDate = creation_time
417 annotation.annotationType = "OTHER"
418 annotation.annotator = "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION"))
419 annotation.comment = "isNative"
420 recipe.annotations.append(annotation)
421 427
422 for s in d.getVar('SRC_URI').split(): 428 for s in d.getVar('SRC_URI').split():
423 if not s.startswith("file://"): 429 if not s.startswith("file://"):