]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes/create-spdx: Add NOASSERTION for unknown debug sources
authorJoshua Watt <JPEWhacker@gmail.com>
Wed, 1 Sep 2021 13:44:46 +0000 (08:44 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 3 Sep 2021 08:03:36 +0000 (09:03 +0100)
If a debug source cannot be found, mark it as NOASSERTION so that other
tools at least know we were unable to locate it.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/create-spdx.bbclass

index 28a2e64f520e31a3bbaa510a1335752cf17b9586..3f635045a6370c61825d0b64a9a3f9e92e7fbf1f 100644 (file)
@@ -190,6 +190,7 @@ def add_package_sources_from_debug(d, package_doc, spdx_package, package, packag
             continue
 
         for debugsrc in file_data["debugsrc"]:
+            ref_id = "NOASSERTION"
             for search in debug_search_paths:
                 debugsrc_path = search / debugsrc.lstrip("/")
                 if not debugsrc_path.exists():
@@ -205,31 +206,26 @@ def add_package_sources_from_debug(d, package_doc, spdx_package, package, packag
 
                 file_sha256 = sha.hexdigest()
 
-                if not file_sha256 in sources:
-                    bb.debug(1, "Debug source %s with SHA256 %s not found in any dependency" % (str(debugsrc_path), file_sha256))
-                    continue
+                if file_sha256 in sources:
+                    source_file = sources[file_sha256]
+
+                    doc_ref = package_doc.find_external_document_ref(source_file.doc.documentNamespace)
+                    if doc_ref is None:
+                        doc_ref = oe.spdx.SPDXExternalDocumentRef()
+                        doc_ref.externalDocumentId = "DocumentRef-dependency-" + source_file.doc.name
+                        doc_ref.spdxDocument = source_file.doc.documentNamespace
+                        doc_ref.checksum.algorithm = "SHA1"
+                        doc_ref.checksum.checksumValue = source_file.doc_sha1
+                        package_doc.externalDocumentRefs.append(doc_ref)
 
-                source_file = sources[file_sha256]
-
-                doc_ref = package_doc.find_external_document_ref(source_file.doc.documentNamespace)
-                if doc_ref is None:
-                    doc_ref = oe.spdx.SPDXExternalDocumentRef()
-                    doc_ref.externalDocumentId = "DocumentRef-dependency-" + source_file.doc.name
-                    doc_ref.spdxDocument = source_file.doc.documentNamespace
-                    doc_ref.checksum.algorithm = "SHA1"
-                    doc_ref.checksum.checksumValue = source_file.doc_sha1
-                    package_doc.externalDocumentRefs.append(doc_ref)
-
-                package_doc.add_relationship(
-                    pkg_file,
-                    "GENERATED_FROM",
-                    "%s:%s" % (doc_ref.externalDocumentId, source_file.file.SPDXID),
-                    comment=debugsrc
-                )
+                    ref_id = "%s:%s" % (doc_ref.externalDocumentId, source_file.file.SPDXID),
+                else:
+                    bb.debug(1, "Debug source %s with SHA256 %s not found in any dependency" % (str(debugsrc_path), file_sha256))
                 break
             else:
                 bb.debug(1, "Debug source %s not found" % debugsrc)
 
+            package_doc.add_relationship(pkg_file, "GENERATED_FROM", ref_id, comment=debugsrc)
 
 def collect_dep_recipes(d, doc, spdx_recipe):
     from pathlib import Path