summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2023-03-27 15:05:29 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-04-01 20:23:23 +0100
commit006f1406875309aa86cd356734c60971d2f03cf5 (patch)
tree5a63a862e62c659c180ced12da7f9ef908f81531 /meta/classes
parent77e8b40baebb056bcffcdd28f9170bf4b05b43d4 (diff)
downloadpoky-006f1406875309aa86cd356734c60971d2f03cf5.tar.gz
create-spdx: Use gzip for compression
The master version of the SPDX classes uses zstd for efficient compression, but it relies on the zstd tool to be present on the host system. Since dunfell supports older distros, we don't want to add this tool as an additional requirement so switch to using gzip instead. (From OE-Core rev: 55b08fd641767a3d2e080727828ca37d9e610109) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/create-spdx-2.2.bbclass20
1 files changed, 9 insertions, 11 deletions
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index 13d13fe1fc..42b693d586 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -466,13 +466,11 @@ python do_create_spdx() {
466 @contextmanager 466 @contextmanager
467 def optional_tarfile(name, guard, mode="w"): 467 def optional_tarfile(name, guard, mode="w"):
468 import tarfile 468 import tarfile
469 import bb.compress.zstd 469 import gzip
470
471 num_threads = int(d.getVar("BB_NUMBER_THREADS"))
472 470
473 if guard: 471 if guard:
474 name.parent.mkdir(parents=True, exist_ok=True) 472 name.parent.mkdir(parents=True, exist_ok=True)
475 with bb.compress.zstd.open(name, mode=mode + "b", num_threads=num_threads) as f: 473 with gzip.open(name, mode=mode + "b") as f:
476 with tarfile.open(fileobj=f, mode=mode + "|") as tf: 474 with tarfile.open(fileobj=f, mode=mode + "|") as tf:
477 yield tf 475 yield tf
478 else: 476 else:
@@ -550,7 +548,7 @@ python do_create_spdx() {
550 add_download_packages(d, doc, recipe) 548 add_download_packages(d, doc, recipe)
551 549
552 if process_sources(d) and include_sources: 550 if process_sources(d) and include_sources:
553 recipe_archive = deploy_dir_spdx / "recipes" / (doc.name + ".tar.zst") 551 recipe_archive = deploy_dir_spdx / "recipes" / (doc.name + ".tar.gz")
554 with optional_tarfile(recipe_archive, archive_sources) as archive: 552 with optional_tarfile(recipe_archive, archive_sources) as archive:
555 spdx_get_src(d) 553 spdx_get_src(d)
556 554
@@ -618,7 +616,7 @@ python do_create_spdx() {
618 package_doc.add_relationship(spdx_package, "GENERATED_FROM", "%s:%s" % (recipe_ref.externalDocumentId, recipe.SPDXID)) 616 package_doc.add_relationship(spdx_package, "GENERATED_FROM", "%s:%s" % (recipe_ref.externalDocumentId, recipe.SPDXID))
619 package_doc.add_relationship(package_doc, "DESCRIBES", spdx_package) 617 package_doc.add_relationship(package_doc, "DESCRIBES", spdx_package)
620 618
621 package_archive = deploy_dir_spdx / "packages" / (package_doc.name + ".tar.zst") 619 package_archive = deploy_dir_spdx / "packages" / (package_doc.name + ".tar.gz")
622 with optional_tarfile(package_archive, archive_packaged) as archive: 620 with optional_tarfile(package_archive, archive_packaged) as archive:
623 package_files = add_package_files( 621 package_files = add_package_files(
624 d, 622 d,
@@ -899,8 +897,8 @@ python image_combine_spdx() {
899 if link != target_path: 897 if link != target_path:
900 link.symlink_to(os.path.relpath(target_path, link.parent)) 898 link.symlink_to(os.path.relpath(target_path, link.parent))
901 899
902 spdx_tar_path = imgdeploydir / (image_name + ".spdx.tar.zst") 900 spdx_tar_path = imgdeploydir / (image_name + ".spdx.tar.gz")
903 make_image_link(spdx_tar_path, ".spdx.tar.zst") 901 make_image_link(spdx_tar_path, ".spdx.tar.gz")
904} 902}
905 903
906python sdk_host_combine_spdx() { 904python sdk_host_combine_spdx() {
@@ -931,7 +929,7 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx
931 from datetime import timezone, datetime 929 from datetime import timezone, datetime
932 from pathlib import Path 930 from pathlib import Path
933 import tarfile 931 import tarfile
934 import bb.compress.zstd 932 import gzip
935 933
936 creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") 934 creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
937 deploy_dir_spdx = Path(d.getVar("DEPLOY_DIR_SPDX")) 935 deploy_dir_spdx = Path(d.getVar("DEPLOY_DIR_SPDX"))
@@ -1002,8 +1000,8 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx
1002 1000
1003 index = {"documents": []} 1001 index = {"documents": []}
1004 1002
1005 spdx_tar_path = rootfs_deploydir / (rootfs_name + ".spdx.tar.zst") 1003 spdx_tar_path = rootfs_deploydir / (rootfs_name + ".spdx.tar.gz")
1006 with bb.compress.zstd.open(spdx_tar_path, "w", num_threads=num_threads) as f: 1004 with gzip.open(spdx_tar_path, "w") as f:
1007 with tarfile.open(fileobj=f, mode="w|") as tar: 1005 with tarfile.open(fileobj=f, mode="w|") as tar:
1008 def collect_spdx_document(path): 1006 def collect_spdx_document(path):
1009 nonlocal tar 1007 nonlocal tar