diff options
| author | Saul Wold <Saul.Wold@windriver.com> | 2021-10-26 18:30:49 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-08 23:41:00 +0000 |
| commit | ceb1f52dff8567322b989d03cde439034a56e2da (patch) | |
| tree | 123b0bcf2553e8ba031f710ada37341bb8c36fb6 | |
| parent | 4c9414b35d88d1551643cc51434025a0267c4e26 (diff) | |
| download | poky-ceb1f52dff8567322b989d03cde439034a56e2da.tar.gz | |
create-spdx: add create_annotation function
This allows code reuse and future usage with relationship annotations
(From OE-Core rev: a56b50ada5d1aba57e901684af6a3761f74f6674)
Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit 1f8fdb7dc9d02d0ee3c42674ca16e03f0ec18cba)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/classes/create-spdx.bbclass | 18 |
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 | ||
| 38 | def 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 | |||
| 38 | def recipe_spdx_is_native(d, recipe): | 49 | def 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://"): |
