summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/sbom.py22
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
41def write_doc(d, spdx_doc, subdir, spdx_deploy=None, indent=None): 41def doc_path_by_namespace(spdx_deploy, doc_namespace):
42 return spdx_deploy / "by-namespace" / doc_namespace.replace("/", "_")
43
44
45def doc_path_by_hashfn(spdx_deploy, doc_name, hashfn):
46 return spdx_deploy / "by-hash" / hashfn.split()[1] / (doc_name + ".spdx.json")
47
48
49def doc_path(spdx_deploy, doc_name, arch, subdir):
50 return spdx_deploy / arch/ subdir / (doc_name + ".spdx.json")
51
52
53def 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