diff options
-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 |