classes/create-spdx: Add SHA1 to index file

(From OE-Core rev: ebfe78ad26b643ce0fb22ba5b3ede43da4a78987)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt authored and Richard Purdie committed 2021-09-03 09:53:28 +01:00
1 parent f3796b4524
commit f1cd4f264d
2 files changed
+14 -3

No files matched your search

+2 -1
View File
@@ -627,7 +627,7 @@ python image_combine_spdx() {
visited_docs.add(path)
with path.open("rb") as f:
doc = oe.spdx.SPDXDocument.from_json(f)
doc, sha1 = oe.sbom.read_doc(f)
f.seek(0)
if doc.documentNamespace in visited_docs:
@@ -651,6 +651,7 @@ python image_combine_spdx() {
index["documents"].append({
"filename": info.name,
"documentNamespace": doc.documentNamespace,
"sha1": sha1,
})
for ref in doc.externalDocumentRefs:
+12 -2
View File
@@ -45,11 +45,21 @@ def write_doc(d, spdx_doc, subdir):
return doc_sha1
def read_doc(filename):
def read_doc(fn):
import hashlib
import oe.spdx
import io
import contextlib
with filename.open("rb") as f:
@contextlib.contextmanager
def get_file():
if isinstance(fn, io.IOBase):
yield fn
else:
with fn.open("rb") as f:
yield f
with get_file() as f:
sha1 = hashlib.sha1()
while True:
chunk = f.read(4096)