diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2021-09-01 08:44:46 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-03 09:53:28 +0100 |
commit | bdda62648149b03a8c4522a9597464c5b3f9ec59 (patch) | |
tree | 4065859af570d08eba37d88fc3187ae2f920ce8b /meta | |
parent | 0b871c57b8c3e45fd64d10037a32033d4a347d67 (diff) | |
download | poky-bdda62648149b03a8c4522a9597464c5b3f9ec59.tar.gz |
classes/create-spdx: Add NOASSERTION for unknown debug sources
If a debug source cannot be found, mark it as NOASSERTION so that other
tools at least know we were unable to locate it.
(From OE-Core rev: 0e6bdd3f208c50153087c2baca67e9fd64a458d0)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/create-spdx.bbclass | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass index 28a2e64f52..3f635045a6 100644 --- a/meta/classes/create-spdx.bbclass +++ b/meta/classes/create-spdx.bbclass | |||
@@ -190,6 +190,7 @@ def add_package_sources_from_debug(d, package_doc, spdx_package, package, packag | |||
190 | continue | 190 | continue |
191 | 191 | ||
192 | for debugsrc in file_data["debugsrc"]: | 192 | for debugsrc in file_data["debugsrc"]: |
193 | ref_id = "NOASSERTION" | ||
193 | for search in debug_search_paths: | 194 | for search in debug_search_paths: |
194 | debugsrc_path = search / debugsrc.lstrip("/") | 195 | debugsrc_path = search / debugsrc.lstrip("/") |
195 | if not debugsrc_path.exists(): | 196 | if not debugsrc_path.exists(): |
@@ -205,31 +206,26 @@ def add_package_sources_from_debug(d, package_doc, spdx_package, package, packag | |||
205 | 206 | ||
206 | file_sha256 = sha.hexdigest() | 207 | file_sha256 = sha.hexdigest() |
207 | 208 | ||
208 | if not file_sha256 in sources: | 209 | if file_sha256 in sources: |
209 | bb.debug(1, "Debug source %s with SHA256 %s not found in any dependency" % (str(debugsrc_path), file_sha256)) | 210 | source_file = sources[file_sha256] |
210 | continue | 211 | |
212 | doc_ref = package_doc.find_external_document_ref(source_file.doc.documentNamespace) | ||
213 | if doc_ref is None: | ||
214 | doc_ref = oe.spdx.SPDXExternalDocumentRef() | ||
215 | doc_ref.externalDocumentId = "DocumentRef-dependency-" + source_file.doc.name | ||
216 | doc_ref.spdxDocument = source_file.doc.documentNamespace | ||
217 | doc_ref.checksum.algorithm = "SHA1" | ||
218 | doc_ref.checksum.checksumValue = source_file.doc_sha1 | ||
219 | package_doc.externalDocumentRefs.append(doc_ref) | ||
211 | 220 | ||
212 | source_file = sources[file_sha256] | 221 | ref_id = "%s:%s" % (doc_ref.externalDocumentId, source_file.file.SPDXID), |
213 | 222 | else: | |
214 | doc_ref = package_doc.find_external_document_ref(source_file.doc.documentNamespace) | 223 | bb.debug(1, "Debug source %s with SHA256 %s not found in any dependency" % (str(debugsrc_path), file_sha256)) |
215 | if doc_ref is None: | ||
216 | doc_ref = oe.spdx.SPDXExternalDocumentRef() | ||
217 | doc_ref.externalDocumentId = "DocumentRef-dependency-" + source_file.doc.name | ||
218 | doc_ref.spdxDocument = source_file.doc.documentNamespace | ||
219 | doc_ref.checksum.algorithm = "SHA1" | ||
220 | doc_ref.checksum.checksumValue = source_file.doc_sha1 | ||
221 | package_doc.externalDocumentRefs.append(doc_ref) | ||
222 | |||
223 | package_doc.add_relationship( | ||
224 | pkg_file, | ||
225 | "GENERATED_FROM", | ||
226 | "%s:%s" % (doc_ref.externalDocumentId, source_file.file.SPDXID), | ||
227 | comment=debugsrc | ||
228 | ) | ||
229 | break | 224 | break |
230 | else: | 225 | else: |
231 | bb.debug(1, "Debug source %s not found" % debugsrc) | 226 | bb.debug(1, "Debug source %s not found" % debugsrc) |
232 | 227 | ||
228 | package_doc.add_relationship(pkg_file, "GENERATED_FROM", ref_id, comment=debugsrc) | ||
233 | 229 | ||
234 | def collect_dep_recipes(d, doc, spdx_recipe): | 230 | def collect_dep_recipes(d, doc, spdx_recipe): |
235 | from pathlib import Path | 231 | from pathlib import Path |