diff options
Diffstat (limited to 'meta/classes/create-spdx.bbclass')
-rw-r--r-- | meta/classes/create-spdx.bbclass | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass index 3c73c21c04..739b46e9b3 100644 --- a/meta/classes/create-spdx.bbclass +++ b/meta/classes/create-spdx.bbclass | |||
@@ -13,6 +13,9 @@ SPDXDIR ??= "${WORKDIR}/spdx" | |||
13 | SPDXDEPLOY = "${SPDXDIR}/deploy" | 13 | SPDXDEPLOY = "${SPDXDIR}/deploy" |
14 | SPDXWORK = "${SPDXDIR}/work" | 14 | SPDXWORK = "${SPDXDIR}/work" |
15 | 15 | ||
16 | SPDX_TOOL_NAME ??= "oe-spdx-creator" | ||
17 | SPDX_TOOL_VERSION ??= "1.0" | ||
18 | |||
16 | SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy" | 19 | SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy" |
17 | 20 | ||
18 | SPDX_INCLUDE_SOURCES ??= "0" | 21 | SPDX_INCLUDE_SOURCES ??= "0" |
@@ -32,6 +35,10 @@ def get_doc_namespace(d, doc): | |||
32 | 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")) |
33 | 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))) |
34 | 37 | ||
38 | def recipe_spdx_is_native(d, recipe): | ||
39 | return any(a.annotationType == "OTHER" and | ||
40 | a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and | ||
41 | a.comment == "isNative" for a in recipe.annotations) | ||
35 | 42 | ||
36 | def is_work_shared(d): | 43 | def is_work_shared(d): |
37 | pn = d.getVar('PN') | 44 | pn = d.getVar('PN') |
@@ -336,6 +343,10 @@ def collect_dep_sources(d, dep_recipes): | |||
336 | 343 | ||
337 | sources = {} | 344 | sources = {} |
338 | for dep in dep_recipes: | 345 | for dep in dep_recipes: |
346 | # Don't collect sources from native recipes as they | ||
347 | # match non-native sources also. | ||
348 | if recipe_spdx_is_native(d, dep.recipe): | ||
349 | continue | ||
339 | recipe_files = set(dep.recipe.hasFiles) | 350 | recipe_files = set(dep.recipe.hasFiles) |
340 | 351 | ||
341 | for spdx_file in dep.doc.files: | 352 | for spdx_file in dep.doc.files: |
@@ -382,7 +393,6 @@ python do_create_spdx() { | |||
382 | include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1" | 393 | include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1" |
383 | archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1" | 394 | archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1" |
384 | archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1" | 395 | archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1" |
385 | is_native = bb.data.inherits_class("native", d) | ||
386 | 396 | ||
387 | creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") | 397 | creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") |
388 | 398 | ||
@@ -401,6 +411,13 @@ python do_create_spdx() { | |||
401 | recipe.name = d.getVar("PN") | 411 | recipe.name = d.getVar("PN") |
402 | recipe.versionInfo = d.getVar("PV") | 412 | recipe.versionInfo = d.getVar("PV") |
403 | recipe.SPDXID = oe.sbom.get_recipe_spdxid(d) | 413 | recipe.SPDXID = oe.sbom.get_recipe_spdxid(d) |
414 | if bb.data.inherits_class("native", d): | ||
415 | annotation = oe.spdx.SPDXAnnotation() | ||
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) | ||
404 | 421 | ||
405 | for s in d.getVar('SRC_URI').split(): | 422 | for s in d.getVar('SRC_URI').split(): |
406 | if not s.startswith("file://"): | 423 | if not s.startswith("file://"): |
@@ -480,7 +497,7 @@ python do_create_spdx() { | |||
480 | sources = collect_dep_sources(d, dep_recipes) | 497 | sources = collect_dep_sources(d, dep_recipes) |
481 | found_licenses = {license.name:recipe_ref.externalDocumentId + ":" + license.licenseId for license in doc.hasExtractedLicensingInfos} | 498 | found_licenses = {license.name:recipe_ref.externalDocumentId + ":" + license.licenseId for license in doc.hasExtractedLicensingInfos} |
482 | 499 | ||
483 | if not is_native: | 500 | if not recipe_spdx_is_native(d, recipe): |
484 | bb.build.exec_func("read_subpackage_metadata", d) | 501 | bb.build.exec_func("read_subpackage_metadata", d) |
485 | 502 | ||
486 | pkgdest = Path(d.getVar("PKGDEST")) | 503 | pkgdest = Path(d.getVar("PKGDEST")) |