summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-09-21 09:04:20 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-09-22 07:45:17 +0100
commitb0b0b89ad763a50cb02429b31f24400ddd4491b7 (patch)
treeb993d07ce068b9a6d74652f404ab27af5956f49d /meta/lib/oe
parentaab44111d72d87528cfb9e210b6217a09d1636d4 (diff)
downloadpoky-b0b0b89ad763a50cb02429b31f24400ddd4491b7.tar.gz
create-spdx/sbom: Ensure files don't overlap between machines
Currently the by-id and by-namespace SPDX files are created without reference to PACKAGE_ARCH. This means that for two machines using a common package architecture (e.g. genericx86-64 and qqemux86-64), there would be overlapping files. This means that the build of one can remove files from the other leading to build failures. An example would be: MACHINE=qemux86-64 bitbake core-image-minimal MACHINE=genericx86-64 bitbake core-image-minimal MACHINE=qemux86-64 bitbake linux-yocto -c clean MACHINE=genericx86-64 bitbake core-image-minimal -C rootfs To fix this, add PACKAGE_ARCH to the path used for the files and use a search path based upon PACKAGE_ARCHS to access them. (From OE-Core rev: b2db10e966438071d00d2057b84d5f347613d841) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/sbom.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/meta/lib/oe/sbom.py b/meta/lib/oe/sbom.py
index 1130fa668b..fd4b6895d8 100644
--- a/meta/lib/oe/sbom.py
+++ b/meta/lib/oe/sbom.py
@@ -38,16 +38,34 @@ def get_sdk_spdxid(sdk):
38 return "SPDXRef-SDK-%s" % sdk 38 return "SPDXRef-SDK-%s" % sdk
39 39
40 40
41def doc_path_by_namespace(spdx_deploy, doc_namespace): 41def _doc_path_by_namespace(spdx_deploy, arch, doc_namespace):
42 return spdx_deploy / "by-namespace" / doc_namespace.replace("/", "_") 42 return spdx_deploy / "by-namespace" / arch / doc_namespace.replace("/", "_")
43 43
44 44
45def doc_path_by_hashfn(spdx_deploy, doc_name, hashfn): 45def doc_find_by_namespace(spdx_deploy, search_arches, doc_namespace):
46 return spdx_deploy / "by-hash" / hashfn.split()[1] / (doc_name + ".spdx.json") 46 for pkgarch in search_arches:
47 p = _doc_path_by_namespace(spdx_deploy, pkgarch, doc_namespace)
48 if os.path.exists(p):
49 return p
50 return None
51
52
53def _doc_path_by_hashfn(spdx_deploy, arch, doc_name, hashfn):
54 return (
55 spdx_deploy / "by-hash" / arch / hashfn.split()[1] / (doc_name + ".spdx.json")
56 )
57
58
59def doc_find_by_hashfn(spdx_deploy, search_arches, doc_name, hashfn):
60 for pkgarch in search_arches:
61 p = _doc_path_by_hashfn(spdx_deploy, pkgarch, doc_name, hashfn)
62 if os.path.exists(p):
63 return p
64 return None
47 65
48 66
49def doc_path(spdx_deploy, doc_name, arch, subdir): 67def doc_path(spdx_deploy, doc_name, arch, subdir):
50 return spdx_deploy / arch/ subdir / (doc_name + ".spdx.json") 68 return spdx_deploy / arch / subdir / (doc_name + ".spdx.json")
51 69
52 70
53def write_doc(d, spdx_doc, arch, subdir, spdx_deploy=None, indent=None): 71def write_doc(d, spdx_doc, arch, subdir, spdx_deploy=None, indent=None):
@@ -61,11 +79,13 @@ def write_doc(d, spdx_doc, arch, subdir, spdx_deploy=None, indent=None):
61 with dest.open("wb") as f: 79 with dest.open("wb") as f:
62 doc_sha1 = spdx_doc.to_json(f, sort_keys=True, indent=indent) 80 doc_sha1 = spdx_doc.to_json(f, sort_keys=True, indent=indent)
63 81
64 l = doc_path_by_namespace(spdx_deploy, spdx_doc.documentNamespace) 82 l = _doc_path_by_namespace(spdx_deploy, arch, spdx_doc.documentNamespace)
65 l.parent.mkdir(exist_ok=True, parents=True) 83 l.parent.mkdir(exist_ok=True, parents=True)
66 l.symlink_to(os.path.relpath(dest, l.parent)) 84 l.symlink_to(os.path.relpath(dest, l.parent))
67 85
68 l = doc_path_by_hashfn(spdx_deploy, spdx_doc.name, d.getVar("BB_HASHFILENAME")) 86 l = _doc_path_by_hashfn(
87 spdx_deploy, arch, spdx_doc.name, d.getVar("BB_HASHFILENAME")
88 )
69 l.parent.mkdir(exist_ok=True, parents=True) 89 l.parent.mkdir(exist_ok=True, parents=True)
70 l.symlink_to(os.path.relpath(dest, l.parent)) 90 l.symlink_to(os.path.relpath(dest, l.parent))
71 91