summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/create-spdx-2.2.bbclass11
-rw-r--r--meta/lib/oe/spdx30_tasks.py13
-rw-r--r--meta/lib/oe/spdx_common.py20
3 files changed, 23 insertions, 21 deletions
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index 795ba1a882..cd1d6819bf 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -354,15 +354,6 @@ def add_download_packages(d, doc, recipe):
354 if f.type == "file": 354 if f.type == "file":
355 continue 355 continue
356 356
357 uri = f.type
358 proto = getattr(f, "proto", None)
359 if proto is not None:
360 uri = uri + "+" + proto
361 uri = uri + "://" + f.host + f.path
362
363 if f.method.supports_srcrev():
364 uri = uri + "@" + f.revisions[name]
365
366 if f.method.supports_checksum(f): 357 if f.method.supports_checksum(f):
367 for checksum_id in CHECKSUM_LIST: 358 for checksum_id in CHECKSUM_LIST:
368 if checksum_id.upper() not in oe.spdx.SPDXPackage.ALLOWED_CHECKSUMS: 359 if checksum_id.upper() not in oe.spdx.SPDXPackage.ALLOWED_CHECKSUMS:
@@ -377,7 +368,7 @@ def add_download_packages(d, doc, recipe):
377 c.checksumValue = expected_checksum 368 c.checksumValue = expected_checksum
378 package.checksums.append(c) 369 package.checksums.append(c)
379 370
380 package.downloadLocation = uri 371 package.downloadLocation = oe.spdx_common.fetch_data_to_uri(f, name)
381 doc.packages.append(package) 372 doc.packages.append(package)
382 doc.add_relationship(doc, "DESCRIBES", package) 373 doc.add_relationship(doc, "DESCRIBES", package)
383 # In the future, we might be able to do more fancy dependencies, 374 # In the future, we might be able to do more fancy dependencies,
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index 70d1bc7e8a..1ae13b4af8 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -379,22 +379,15 @@ def add_download_files(d, objset):
379 inputs.add(file) 379 inputs.add(file)
380 380
381 else: 381 else:
382 uri = fd.type
383 proto = getattr(fd, "proto", None)
384 if proto is not None:
385 uri = uri + "+" + proto
386 uri = uri + "://" + fd.host + fd.path
387
388 if fd.method.supports_srcrev():
389 uri = uri + "@" + fd.revisions[name]
390
391 dl = objset.add( 382 dl = objset.add(
392 oe.spdx30.software_Package( 383 oe.spdx30.software_Package(
393 _id=objset.new_spdxid("source", str(download_idx + 1)), 384 _id=objset.new_spdxid("source", str(download_idx + 1)),
394 creationInfo=objset.doc.creationInfo, 385 creationInfo=objset.doc.creationInfo,
395 name=file_name, 386 name=file_name,
396 software_primaryPurpose=primary_purpose, 387 software_primaryPurpose=primary_purpose,
397 software_downloadLocation=uri, 388 software_downloadLocation=oe.spdx_common.fetch_data_to_uri(
389 fd, name
390 ),
398 ) 391 )
399 ) 392 )
400 393
diff --git a/meta/lib/oe/spdx_common.py b/meta/lib/oe/spdx_common.py
index dfe90f96cf..1ea55419ae 100644
--- a/meta/lib/oe/spdx_common.py
+++ b/meta/lib/oe/spdx_common.py
@@ -42,7 +42,6 @@ def is_work_shared_spdx(d):
42 42
43 43
44def load_spdx_license_data(d): 44def load_spdx_license_data(d):
45
46 with open(d.getVar("SPDX_LICENSES"), "r") as f: 45 with open(d.getVar("SPDX_LICENSES"), "r") as f:
47 data = json.load(f) 46 data = json.load(f)
48 # Transform the license array to a dictionary 47 # Transform the license array to a dictionary
@@ -225,3 +224,22 @@ def get_patched_src(d):
225 bb.utils.mkdirhier(spdx_workdir) 224 bb.utils.mkdirhier(spdx_workdir)
226 finally: 225 finally:
227 d.setVar("WORKDIR", workdir) 226 d.setVar("WORKDIR", workdir)
227
228
229def fetch_data_to_uri(fd, name):
230 """
231 Translates a bitbake FetchData to a string URI
232 """
233 uri = fd.type
234 # Map gitsm to git, since gitsm:// is not a valid URI protocol
235 if uri == "gitsm":
236 uri = "git"
237 proto = getattr(fd, "proto", None)
238 if proto is not None:
239 uri = uri + "+" + proto
240 uri = uri + "://" + fd.host + fd.path
241
242 if fd.method.supports_srcrev():
243 uri = uri + "@" + fd.revisions[name]
244
245 return uri