mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 13:29:49 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
4c9414b35d
commit
ceb1f52dff
@@ -35,6 +35,17 @@ def get_doc_namespace(d, doc):
|
|||||||
namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, d.getVar("SPDX_UUID_NAMESPACE"))
|
namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, d.getVar("SPDX_UUID_NAMESPACE"))
|
||||||
return "%s/%s-%s" % (d.getVar("SPDX_NAMESPACE_PREFIX"), doc.name, str(uuid.uuid5(namespace_uuid, doc.name)))
|
return "%s/%s-%s" % (d.getVar("SPDX_NAMESPACE_PREFIX"), doc.name, str(uuid.uuid5(namespace_uuid, doc.name)))
|
||||||
|
|
||||||
|
def create_annotation(d, comment):
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
annotation = oe.spdx.SPDXAnnotation()
|
||||||
|
annotation.annotationDate = creation_time
|
||||||
|
annotation.annotationType = "OTHER"
|
||||||
|
annotation.annotator = "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION"))
|
||||||
|
annotation.comment = comment
|
||||||
|
return annotation
|
||||||
|
|
||||||
def recipe_spdx_is_native(d, recipe):
|
def recipe_spdx_is_native(d, recipe):
|
||||||
return any(a.annotationType == "OTHER" and
|
return any(a.annotationType == "OTHER" and
|
||||||
a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and
|
a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and
|
||||||
@@ -412,12 +423,7 @@ python do_create_spdx() {
|
|||||||
recipe.versionInfo = d.getVar("PV")
|
recipe.versionInfo = d.getVar("PV")
|
||||||
recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
|
recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
|
||||||
if bb.data.inherits_class("native", d):
|
if bb.data.inherits_class("native", d):
|
||||||
annotation = oe.spdx.SPDXAnnotation()
|
recipe.annotations.append(create_annotation(d, "isNative"))
|
||||||
annotation.annotationDate = creation_time
|
|
||||||
annotation.annotationType = "OTHER"
|
|
||||||
annotation.annotator = "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION"))
|
|
||||||
annotation.comment = "isNative"
|
|
||||||
recipe.annotations.append(annotation)
|
|
||||||
|
|
||||||
for s in d.getVar('SRC_URI').split():
|
for s in d.getVar('SRC_URI').split():
|
||||||
if not s.startswith("file://"):
|
if not s.startswith("file://"):
|
||||||
|
|||||||
Reference in New Issue
Block a user