summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Kang <kai.kang@windriver.com>2025-11-24 21:55:06 +0800
committerSteve Sakoman <steve@sakoman.com>2025-12-01 07:34:54 -0800
commit91ba7b5d6613c8ea493c9eb7e592c30d5a0bf335 (patch)
tree7b9c845ad847f461f38689dc8dcb91049e203b14
parentd71d81814adae2c51fdaf42f62c146041545c7fd (diff)
downloadpoky-91ba7b5d6613c8ea493c9eb7e592c30d5a0bf335.tar.gz
Revert "spdx: Update for bitbake changes"
This reverts part of commit 4859cdf97fd9a260036e148e25f0b78eb393df1e. Modification of meta/classes/create-spdx-2.2.bbclass is not backported, so no need to consider it. In the commit, it updates spdx according to bitbake change. But the bitbake commit * 2515fbd10 fetch: Drop multiple branch/revision support for single git urls doesn't backport for scarthgap. So revert the other parts of the commit 4859cdf97fd9a260036e148e25f0b. (From OE-Core rev: f3bfb98d1cf928678d9931308c116e9e6ec64ba5) Signed-off-by: Kai Kang <kai.kang@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/lib/oe/spdx30_tasks.py125
-rw-r--r--meta/lib/oe/spdx_common.py2
2 files changed, 64 insertions, 63 deletions
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index a2d316301f..0fa9a7d724 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -356,77 +356,78 @@ def add_download_files(d, objset):
356 for download_idx, src_uri in enumerate(urls): 356 for download_idx, src_uri in enumerate(urls):
357 fd = fetch.ud[src_uri] 357 fd = fetch.ud[src_uri]
358 358
359 file_name = os.path.basename(fetch.localpath(src_uri)) 359 for name in fd.names:
360 if oe.patch.patch_path(src_uri, fetch, "", expand=False): 360 file_name = os.path.basename(fetch.localpath(src_uri))
361 primary_purpose = oe.spdx30.software_SoftwarePurpose.patch 361 if oe.patch.patch_path(src_uri, fetch, "", expand=False):
362 else: 362 primary_purpose = oe.spdx30.software_SoftwarePurpose.patch
363 primary_purpose = oe.spdx30.software_SoftwarePurpose.source 363 else:
364 364 primary_purpose = oe.spdx30.software_SoftwarePurpose.source
365 if fd.type == "file": 365
366 if os.path.isdir(fd.localpath): 366 if fd.type == "file":
367 walk_idx = 1 367 if os.path.isdir(fd.localpath):
368 for root, dirs, files in os.walk(fd.localpath, onerror=walk_error): 368 walk_idx = 1
369 dirs.sort() 369 for root, dirs, files in os.walk(fd.localpath, onerror=walk_error):
370 files.sort() 370 dirs.sort()
371 for f in files: 371 files.sort()
372 f_path = os.path.join(root, f) 372 for f in files:
373 if os.path.islink(f_path): 373 f_path = os.path.join(root, f)
374 # TODO: SPDX doesn't support symlinks yet 374 if os.path.islink(f_path):
375 continue 375 # TODO: SPDX doesn't support symlinks yet
376 continue
377
378 file = objset.new_file(
379 objset.new_spdxid(
380 "source", str(download_idx + 1), str(walk_idx)
381 ),
382 os.path.join(
383 file_name, os.path.relpath(f_path, fd.localpath)
384 ),
385 f_path,
386 purposes=[primary_purpose],
387 )
376 388
377 file = objset.new_file( 389 inputs.add(file)
378 objset.new_spdxid( 390 walk_idx += 1
379 "source", str(download_idx + 1), str(walk_idx)
380 ),
381 os.path.join(
382 file_name, os.path.relpath(f_path, fd.localpath)
383 ),
384 f_path,
385 purposes=[primary_purpose],
386 )
387 391
388 inputs.add(file) 392 else:
389 walk_idx += 1 393 file = objset.new_file(
394 objset.new_spdxid("source", str(download_idx + 1)),
395 file_name,
396 fd.localpath,
397 purposes=[primary_purpose],
398 )
399 inputs.add(file)
390 400
391 else: 401 else:
392 file = objset.new_file( 402 dl = objset.add(
393 objset.new_spdxid("source", str(download_idx + 1)), 403 oe.spdx30.software_Package(
394 file_name, 404 _id=objset.new_spdxid("source", str(download_idx + 1)),
395 fd.localpath, 405 creationInfo=objset.doc.creationInfo,
396 purposes=[primary_purpose], 406 name=file_name,
397 ) 407 software_primaryPurpose=primary_purpose,
398 inputs.add(file) 408 software_downloadLocation=oe.spdx_common.fetch_data_to_uri(
399 409 fd, name
400 else: 410 ),
401 dl = objset.add( 411 )
402 oe.spdx30.software_Package(
403 _id=objset.new_spdxid("source", str(download_idx + 1)),
404 creationInfo=objset.doc.creationInfo,
405 name=file_name,
406 software_primaryPurpose=primary_purpose,
407 software_downloadLocation=oe.spdx_common.fetch_data_to_uri(
408 fd, fd.names[0]
409 ),
410 ) 412 )
411 )
412 413
413 if fd.method.supports_checksum(fd): 414 if fd.method.supports_checksum(fd):
414 # TODO Need something better than hard coding this 415 # TODO Need something better than hard coding this
415 for checksum_id in ["sha256", "sha1"]: 416 for checksum_id in ["sha256", "sha1"]:
416 expected_checksum = getattr( 417 expected_checksum = getattr(
417 fd, "%s_expected" % checksum_id, None 418 fd, "%s_expected" % checksum_id, None
418 ) 419 )
419 if expected_checksum is None: 420 if expected_checksum is None:
420 continue 421 continue
421 422
422 dl.verifiedUsing.append( 423 dl.verifiedUsing.append(
423 oe.spdx30.Hash( 424 oe.spdx30.Hash(
424 algorithm=getattr(oe.spdx30.HashAlgorithm, checksum_id), 425 algorithm=getattr(oe.spdx30.HashAlgorithm, checksum_id),
425 hashValue=expected_checksum, 426 hashValue=expected_checksum,
427 )
426 ) 428 )
427 )
428 429
429 inputs.add(dl) 430 inputs.add(dl)
430 431
431 return inputs 432 return inputs
432 433
diff --git a/meta/lib/oe/spdx_common.py b/meta/lib/oe/spdx_common.py
index 4caefc7673..e1b26edaaf 100644
--- a/meta/lib/oe/spdx_common.py
+++ b/meta/lib/oe/spdx_common.py
@@ -239,6 +239,6 @@ def fetch_data_to_uri(fd, name):
239 uri = uri + "://" + fd.host + fd.path 239 uri = uri + "://" + fd.host + fd.path
240 240
241 if fd.method.supports_srcrev(): 241 if fd.method.supports_srcrev():
242 uri = uri + "@" + fd.revision 242 uri = uri + "@" + fd.revisions[name]
243 243
244 return uri 244 return uri