diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2021-09-01 08:44:43 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-03 09:53:28 +0100 |
commit | f1cd4f264d206a3bf9d95cc1e632a476299643e3 (patch) | |
tree | 42ce8da6ef81628e98139076c84aa000a60ff3bc /meta/lib | |
parent | f3796b452490804fa57e66937d912072b1729e8a (diff) | |
download | poky-f1cd4f264d206a3bf9d95cc1e632a476299643e3.tar.gz |
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>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/sbom.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/meta/lib/oe/sbom.py b/meta/lib/oe/sbom.py index d40e5b792f..294feee10b 100644 --- a/meta/lib/oe/sbom.py +++ b/meta/lib/oe/sbom.py | |||
@@ -45,11 +45,21 @@ def write_doc(d, spdx_doc, subdir): | |||
45 | return doc_sha1 | 45 | return doc_sha1 |
46 | 46 | ||
47 | 47 | ||
48 | def read_doc(filename): | 48 | def read_doc(fn): |
49 | import hashlib | 49 | import hashlib |
50 | import oe.spdx | 50 | import oe.spdx |
51 | 51 | import io | |
52 | with filename.open("rb") as f: | 52 | import contextlib |
53 | |||
54 | @contextlib.contextmanager | ||
55 | def get_file(): | ||
56 | if isinstance(fn, io.IOBase): | ||
57 | yield fn | ||
58 | else: | ||
59 | with fn.open("rb") as f: | ||
60 | yield f | ||
61 | |||
62 | with get_file() as f: | ||
53 | sha1 = hashlib.sha1() | 63 | sha1 = hashlib.sha1() |
54 | while True: | 64 | while True: |
55 | chunk = f.read(4096) | 65 | chunk = f.read(4096) |