summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oe/spdx30_tasks.py61
1 files changed, 42 insertions, 19 deletions
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index c60c97896c..658e533d75 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -135,7 +135,7 @@ def add_package_files(
135 topdir, 135 topdir,
136 get_spdxid, 136 get_spdxid,
137 get_purposes, 137 get_purposes,
138 license_data, 138 license_data=None,
139 *, 139 *,
140 archive=None, 140 archive=None,
141 ignore_dirs=[], 141 ignore_dirs=[],
@@ -169,7 +169,10 @@ def add_package_files(
169 ) 169 )
170 spdx_files.add(spdx_file) 170 spdx_files.add(spdx_file)
171 171
172 if oe.spdx30.software_SoftwarePurpose.source in file_purposes: 172 if (
173 oe.spdx30.software_SoftwarePurpose.source in file_purposes
174 and license_data is not None
175 ):
173 objset.scan_declared_licenses(spdx_file, filepath, license_data) 176 objset.scan_declared_licenses(spdx_file, filepath, license_data)
174 177
175 if archive is not None: 178 if archive is not None:
@@ -1072,25 +1075,45 @@ def create_image_spdx(d):
1072 for image in task["images"]: 1075 for image in task["images"]:
1073 image_filename = image["filename"] 1076 image_filename = image["filename"]
1074 image_path = image_deploy_dir / image_filename 1077 image_path = image_deploy_dir / image_filename
1075 a = objset.add_root( 1078 if os.path.isdir(image_path):
1076 oe.spdx30.software_File( 1079 a = add_package_files(
1077 _id=objset.new_spdxid("image", image_filename), 1080 d,
1078 creationInfo=objset.doc.creationInfo, 1081 objset,
1079 name=image_filename, 1082 image_path,
1080 verifiedUsing=[ 1083 lambda file_counter: objset.new_spdxid(
1081 oe.spdx30.Hash( 1084 "imagefile", str(file_counter)
1082 algorithm=oe.spdx30.HashAlgorithm.sha256, 1085 ),
1083 hashValue=bb.utils.sha256_file(image_path), 1086 lambda filepath: [],
1084 ) 1087 license_data=None,
1085 ], 1088 ignore_dirs=[],
1089 ignore_top_level_dirs=[],
1090 archive=None,
1086 ) 1091 )
1087 ) 1092 artifacts.extend(a)
1088 set_purposes( 1093 else:
1089 d, a, "SPDX_IMAGE_PURPOSE:%s" % imagetype, "SPDX_IMAGE_PURPOSE" 1094 a = objset.add_root(
1090 ) 1095 oe.spdx30.software_File(
1091 set_timestamp_now(d, a, "builtTime") 1096 _id=objset.new_spdxid("image", image_filename),
1097 creationInfo=objset.doc.creationInfo,
1098 name=image_filename,
1099 verifiedUsing=[
1100 oe.spdx30.Hash(
1101 algorithm=oe.spdx30.HashAlgorithm.sha256,
1102 hashValue=bb.utils.sha256_file(image_path),
1103 )
1104 ],
1105 )
1106 )
1107
1108 artifacts.append(a)
1109
1110 for a in artifacts:
1111 set_purposes(
1112 d, a, "SPDX_IMAGE_PURPOSE:%s" % imagetype, "SPDX_IMAGE_PURPOSE"
1113 )
1114
1115 set_timestamp_now(d, a, "builtTime")
1092 1116
1093 artifacts.append(a)
1094 1117
1095 if artifacts: 1118 if artifacts:
1096 objset.new_scoped_relationship( 1119 objset.new_scoped_relationship(