mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
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:
committed by
Richard Purdie
parent
f3796b4524
commit
f1cd4f264d
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user