diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2023-05-30 10:11:48 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-02 15:59:07 +0100 |
| commit | 42071227f6f54055d8ac44126ab1d95f83f5b264 (patch) | |
| tree | b6be4892c9c604e148dcf8c6ebf8bbb822392709 /meta/lib/oe/sbom.py | |
| parent | 3b20aaad5ac239d4df282a5541d0858851e64da5 (diff) | |
| download | poky-42071227f6f54055d8ac44126ab1d95f83f5b264.tar.gz | |
classes/create-spdx-2.2: Use hashfn from BB_TASKDEPDATA instead of MACHINE
Enabling the SPDX class and running two builds, one with SDKMACHINE=i686
and then again with SDKMACHINE=x86_64 would lead to errors since the output
was stored per MACHINE and the overlapping files would cause manifest errors.
The hashfn data from bitbake has SSTATE_PKGARCH encoded into it which is how
sstate separates out it's targets and SDPX should be using the same structure.
Therefore switch to using this.
(From OE-Core rev: 51049cde0cf477f7988b94c1041eb33b018a669f)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/sbom.py')
| -rw-r--r-- | meta/lib/oe/sbom.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/meta/lib/oe/sbom.py b/meta/lib/oe/sbom.py index 22ed5070ea..1130fa668b 100644 --- a/meta/lib/oe/sbom.py +++ b/meta/lib/oe/sbom.py | |||
| @@ -38,18 +38,34 @@ def get_sdk_spdxid(sdk): | |||
| 38 | return "SPDXRef-SDK-%s" % sdk | 38 | return "SPDXRef-SDK-%s" % sdk |
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | def write_doc(d, spdx_doc, subdir, spdx_deploy=None, indent=None): | 41 | def doc_path_by_namespace(spdx_deploy, doc_namespace): |
| 42 | return spdx_deploy / "by-namespace" / doc_namespace.replace("/", "_") | ||
| 43 | |||
| 44 | |||
| 45 | def doc_path_by_hashfn(spdx_deploy, doc_name, hashfn): | ||
| 46 | return spdx_deploy / "by-hash" / hashfn.split()[1] / (doc_name + ".spdx.json") | ||
| 47 | |||
| 48 | |||
| 49 | def doc_path(spdx_deploy, doc_name, arch, subdir): | ||
| 50 | return spdx_deploy / arch/ subdir / (doc_name + ".spdx.json") | ||
| 51 | |||
| 52 | |||
| 53 | def write_doc(d, spdx_doc, arch, subdir, spdx_deploy=None, indent=None): | ||
| 42 | from pathlib import Path | 54 | from pathlib import Path |
| 43 | 55 | ||
| 44 | if spdx_deploy is None: | 56 | if spdx_deploy is None: |
| 45 | spdx_deploy = Path(d.getVar("SPDXDEPLOY")) | 57 | spdx_deploy = Path(d.getVar("SPDXDEPLOY")) |
| 46 | 58 | ||
| 47 | dest = spdx_deploy / subdir / (spdx_doc.name + ".spdx.json") | 59 | dest = doc_path(spdx_deploy, spdx_doc.name, arch, subdir) |
| 48 | dest.parent.mkdir(exist_ok=True, parents=True) | 60 | dest.parent.mkdir(exist_ok=True, parents=True) |
| 49 | with dest.open("wb") as f: | 61 | with dest.open("wb") as f: |
| 50 | doc_sha1 = spdx_doc.to_json(f, sort_keys=True, indent=indent) | 62 | doc_sha1 = spdx_doc.to_json(f, sort_keys=True, indent=indent) |
| 51 | 63 | ||
| 52 | l = spdx_deploy / "by-namespace" / spdx_doc.documentNamespace.replace("/", "_") | 64 | l = doc_path_by_namespace(spdx_deploy, spdx_doc.documentNamespace) |
| 65 | l.parent.mkdir(exist_ok=True, parents=True) | ||
| 66 | l.symlink_to(os.path.relpath(dest, l.parent)) | ||
| 67 | |||
| 68 | l = doc_path_by_hashfn(spdx_deploy, spdx_doc.name, d.getVar("BB_HASHFILENAME")) | ||
| 53 | l.parent.mkdir(exist_ok=True, parents=True) | 69 | l.parent.mkdir(exist_ok=True, parents=True) |
| 54 | l.symlink_to(os.path.relpath(dest, l.parent)) | 70 | l.symlink_to(os.path.relpath(dest, l.parent)) |
| 55 | 71 | ||
