summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/create-spdx-2.2.bbclass83
1 files changed, 42 insertions, 41 deletions
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index aee7fbac13..2351a3d5a1 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -1044,52 +1044,53 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx
1044 1044
1045 doc.packages.append(image) 1045 doc.packages.append(image)
1046 1046
1047 for name in sorted(packages.keys()): 1047 if packages:
1048 if name not in providers: 1048 for name in sorted(packages.keys()):
1049 bb.fatal("Unable to find SPDX provider for '%s'" % name) 1049 if name not in providers:
1050 bb.fatal("Unable to find SPDX provider for '%s'" % name)
1050 1051
1051 pkg_name, pkg_hashfn = providers[name] 1052 pkg_name, pkg_hashfn = providers[name]
1052 1053
1053 pkg_spdx_path = oe.sbom.doc_find_by_hashfn(deploy_dir_spdx, package_archs, pkg_name, pkg_hashfn) 1054 pkg_spdx_path = oe.sbom.doc_find_by_hashfn(deploy_dir_spdx, package_archs, pkg_name, pkg_hashfn)
1054 if not pkg_spdx_path: 1055 if not pkg_spdx_path:
1055 bb.fatal("No SPDX file found for package %s, %s" % (pkg_name, pkg_hashfn)) 1056 bb.fatal("No SPDX file found for package %s, %s" % (pkg_name, pkg_hashfn))
1056 1057
1057 pkg_doc, pkg_doc_sha1 = oe.sbom.read_doc(pkg_spdx_path) 1058 pkg_doc, pkg_doc_sha1 = oe.sbom.read_doc(pkg_spdx_path)
1058 1059
1059 for p in pkg_doc.packages: 1060 for p in pkg_doc.packages:
1060 if p.name == name: 1061 if p.name == name:
1061 pkg_ref = oe.spdx.SPDXExternalDocumentRef() 1062 pkg_ref = oe.spdx.SPDXExternalDocumentRef()
1062 pkg_ref.externalDocumentId = "DocumentRef-%s" % pkg_doc.name 1063 pkg_ref.externalDocumentId = "DocumentRef-%s" % pkg_doc.name
1063 pkg_ref.spdxDocument = pkg_doc.documentNamespace 1064 pkg_ref.spdxDocument = pkg_doc.documentNamespace
1064 pkg_ref.checksum.algorithm = "SHA1" 1065 pkg_ref.checksum.algorithm = "SHA1"
1065 pkg_ref.checksum.checksumValue = pkg_doc_sha1 1066 pkg_ref.checksum.checksumValue = pkg_doc_sha1
1066 1067
1067 doc.externalDocumentRefs.append(pkg_ref) 1068 doc.externalDocumentRefs.append(pkg_ref)
1068 doc.add_relationship(image, "CONTAINS", "%s:%s" % (pkg_ref.externalDocumentId, p.SPDXID)) 1069 doc.add_relationship(image, "CONTAINS", "%s:%s" % (pkg_ref.externalDocumentId, p.SPDXID))
1069 break 1070 break
1070 else: 1071 else:
1071 bb.fatal("Unable to find package with name '%s' in SPDX file %s" % (name, pkg_spdx_path)) 1072 bb.fatal("Unable to find package with name '%s' in SPDX file %s" % (name, pkg_spdx_path))
1072 1073
1073 runtime_spdx_path = oe.sbom.doc_find_by_hashfn(deploy_dir_spdx, package_archs, "runtime-" + name, pkg_hashfn) 1074 runtime_spdx_path = oe.sbom.doc_find_by_hashfn(deploy_dir_spdx, package_archs, "runtime-" + name, pkg_hashfn)
1074 if not runtime_spdx_path: 1075 if not runtime_spdx_path:
1075 bb.fatal("No runtime SPDX document found for %s, %s" % (name, pkg_hashfn)) 1076 bb.fatal("No runtime SPDX document found for %s, %s" % (name, pkg_hashfn))
1076 1077
1077 runtime_doc, runtime_doc_sha1 = oe.sbom.read_doc(runtime_spdx_path) 1078 runtime_doc, runtime_doc_sha1 = oe.sbom.read_doc(runtime_spdx_path)
1078 1079
1079 runtime_ref = oe.spdx.SPDXExternalDocumentRef() 1080 runtime_ref = oe.spdx.SPDXExternalDocumentRef()
1080 runtime_ref.externalDocumentId = "DocumentRef-%s" % runtime_doc.name 1081 runtime_ref.externalDocumentId = "DocumentRef-%s" % runtime_doc.name
1081 runtime_ref.spdxDocument = runtime_doc.documentNamespace 1082 runtime_ref.spdxDocument = runtime_doc.documentNamespace
1082 runtime_ref.checksum.algorithm = "SHA1" 1083 runtime_ref.checksum.algorithm = "SHA1"
1083 runtime_ref.checksum.checksumValue = runtime_doc_sha1 1084 runtime_ref.checksum.checksumValue = runtime_doc_sha1
1084 1085
1085 # "OTHER" isn't ideal here, but I can't find a relationship that makes sense 1086 # "OTHER" isn't ideal here, but I can't find a relationship that makes sense
1086 doc.externalDocumentRefs.append(runtime_ref) 1087 doc.externalDocumentRefs.append(runtime_ref)
1087 doc.add_relationship( 1088 doc.add_relationship(
1088 image, 1089 image,
1089 "OTHER", 1090 "OTHER",
1090 "%s:%s" % (runtime_ref.externalDocumentId, runtime_doc.SPDXID), 1091 "%s:%s" % (runtime_ref.externalDocumentId, runtime_doc.SPDXID),
1091 comment="Runtime dependencies for %s" % name 1092 comment="Runtime dependencies for %s" % name
1092 ) 1093 )
1093 bb.utils.mkdirhier(spdx_workdir) 1094 bb.utils.mkdirhier(spdx_workdir)
1094 image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json") 1095 image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json")
1095 1096