diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2024-07-12 09:58:19 -0600 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-07-16 14:55:53 +0100 |
| commit | 9850df1b6051cefdef4f6f9acd93cc93ab2b8b75 (patch) | |
| tree | cd3153d83952cad38f351d602e84641cd8425e08 /meta/classes/create-spdx-2.2.bbclass | |
| parent | 454008311b958a080cffb2cf535958fa0be38c05 (diff) | |
| download | poky-9850df1b6051cefdef4f6f9acd93cc93ab2b8b75.tar.gz | |
classes/spdx-common: Move to library
Moves the bulk of the code in the spdx-common bbclass into library code
(From OE-Core rev: 3f9b7c7f6b15493b6890031190ca8d1a10f2f384)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/create-spdx-2.2.bbclass')
| -rw-r--r-- | meta/classes/create-spdx-2.2.bbclass | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass index 239a95da14..865323d66a 100644 --- a/meta/classes/create-spdx-2.2.bbclass +++ b/meta/classes/create-spdx-2.2.bbclass | |||
| @@ -38,6 +38,12 @@ def recipe_spdx_is_native(d, recipe): | |||
| 38 | a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and | 38 | a.annotator == "Tool: %s - %s" % (d.getVar("SPDX_TOOL_NAME"), d.getVar("SPDX_TOOL_VERSION")) and |
| 39 | a.comment == "isNative" for a in recipe.annotations) | 39 | a.comment == "isNative" for a in recipe.annotations) |
| 40 | 40 | ||
| 41 | def get_json_indent(d): | ||
| 42 | if d.getVar("SPDX_PRETTY") == "1": | ||
| 43 | return 2 | ||
| 44 | return None | ||
| 45 | |||
| 46 | |||
| 41 | def convert_license_to_spdx(lic, document, d, existing={}): | 47 | def convert_license_to_spdx(lic, document, d, existing={}): |
| 42 | from pathlib import Path | 48 | from pathlib import Path |
| 43 | import oe.spdx | 49 | import oe.spdx |
| @@ -113,6 +119,7 @@ def convert_license_to_spdx(lic, document, d, existing={}): | |||
| 113 | def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archive=None, ignore_dirs=[], ignore_top_level_dirs=[]): | 119 | def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archive=None, ignore_dirs=[], ignore_top_level_dirs=[]): |
| 114 | from pathlib import Path | 120 | from pathlib import Path |
| 115 | import oe.spdx | 121 | import oe.spdx |
| 122 | import oe.spdx_common | ||
| 116 | import hashlib | 123 | import hashlib |
| 117 | 124 | ||
| 118 | source_date_epoch = d.getVar("SOURCE_DATE_EPOCH") | 125 | source_date_epoch = d.getVar("SOURCE_DATE_EPOCH") |
| @@ -165,7 +172,7 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv | |||
| 165 | )) | 172 | )) |
| 166 | 173 | ||
| 167 | if "SOURCE" in spdx_file.fileTypes: | 174 | if "SOURCE" in spdx_file.fileTypes: |
| 168 | extracted_lics = extract_licenses(filepath) | 175 | extracted_lics = oe.spdx_common.extract_licenses(filepath) |
| 169 | if extracted_lics: | 176 | if extracted_lics: |
| 170 | spdx_file.licenseInfoInFiles = extracted_lics | 177 | spdx_file.licenseInfoInFiles = extracted_lics |
| 171 | 178 | ||
| @@ -256,6 +263,7 @@ def collect_dep_recipes(d, doc, spdx_recipe): | |||
| 256 | from pathlib import Path | 263 | from pathlib import Path |
| 257 | import oe.sbom | 264 | import oe.sbom |
| 258 | import oe.spdx | 265 | import oe.spdx |
| 266 | import oe.spdx_common | ||
| 259 | 267 | ||
| 260 | deploy_dir_spdx = Path(d.getVar("DEPLOY_DIR_SPDX")) | 268 | deploy_dir_spdx = Path(d.getVar("DEPLOY_DIR_SPDX")) |
| 261 | package_archs = d.getVar("SSTATE_ARCHS").split() | 269 | package_archs = d.getVar("SSTATE_ARCHS").split() |
| @@ -263,7 +271,7 @@ def collect_dep_recipes(d, doc, spdx_recipe): | |||
| 263 | 271 | ||
| 264 | dep_recipes = [] | 272 | dep_recipes = [] |
| 265 | 273 | ||
| 266 | deps = get_spdx_deps(d) | 274 | deps = oe.spdx_common.get_spdx_deps(d) |
| 267 | 275 | ||
| 268 | for dep_pn, dep_hashfn, in_taskhash in deps: | 276 | for dep_pn, dep_hashfn, in_taskhash in deps: |
| 269 | # If this dependency is not calculated in the taskhash skip it. | 277 | # If this dependency is not calculated in the taskhash skip it. |
| @@ -386,6 +394,7 @@ python do_create_spdx() { | |||
| 386 | from datetime import datetime, timezone | 394 | from datetime import datetime, timezone |
| 387 | import oe.sbom | 395 | import oe.sbom |
| 388 | import oe.spdx | 396 | import oe.spdx |
| 397 | import oe.spdx_common | ||
| 389 | import uuid | 398 | import uuid |
| 390 | from pathlib import Path | 399 | from pathlib import Path |
| 391 | from contextlib import contextmanager | 400 | from contextlib import contextmanager |
| @@ -478,10 +487,10 @@ python do_create_spdx() { | |||
| 478 | 487 | ||
| 479 | add_download_packages(d, doc, recipe) | 488 | add_download_packages(d, doc, recipe) |
| 480 | 489 | ||
| 481 | if process_sources(d) and include_sources: | 490 | if oe.spdx_common.process_sources(d) and include_sources: |
| 482 | recipe_archive = deploy_dir_spdx / "recipes" / (doc.name + ".tar.zst") | 491 | recipe_archive = deploy_dir_spdx / "recipes" / (doc.name + ".tar.zst") |
| 483 | with optional_tarfile(recipe_archive, archive_sources) as archive: | 492 | with optional_tarfile(recipe_archive, archive_sources) as archive: |
| 484 | spdx_get_src(d) | 493 | oe.spdx_common.get_patched_src(d) |
| 485 | 494 | ||
| 486 | add_package_files( | 495 | add_package_files( |
| 487 | d, | 496 | d, |
| @@ -588,6 +597,7 @@ python do_create_runtime_spdx() { | |||
| 588 | from datetime import datetime, timezone | 597 | from datetime import datetime, timezone |
| 589 | import oe.sbom | 598 | import oe.sbom |
| 590 | import oe.spdx | 599 | import oe.spdx |
| 600 | import oe.spdx_common | ||
| 591 | import oe.packagedata | 601 | import oe.packagedata |
| 592 | from pathlib import Path | 602 | from pathlib import Path |
| 593 | 603 | ||
| @@ -597,7 +607,7 @@ python do_create_runtime_spdx() { | |||
| 597 | 607 | ||
| 598 | creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") | 608 | creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") |
| 599 | 609 | ||
| 600 | providers = collect_package_providers(d) | 610 | providers = oe.spdx_common.collect_package_providers(d) |
| 601 | pkg_arch = d.getVar("SSTATE_PKGARCH") | 611 | pkg_arch = d.getVar("SSTATE_PKGARCH") |
| 602 | package_archs = d.getVar("SSTATE_ARCHS").split() | 612 | package_archs = d.getVar("SSTATE_ARCHS").split() |
| 603 | package_archs.reverse() | 613 | package_archs.reverse() |
| @@ -778,6 +788,7 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx | |||
| 778 | import os | 788 | import os |
| 779 | import oe.spdx | 789 | import oe.spdx |
| 780 | import oe.sbom | 790 | import oe.sbom |
| 791 | import oe.spdx_common | ||
| 781 | import io | 792 | import io |
| 782 | import json | 793 | import json |
| 783 | from datetime import timezone, datetime | 794 | from datetime import timezone, datetime |
| @@ -785,7 +796,7 @@ def combine_spdx(d, rootfs_name, rootfs_deploydir, rootfs_spdxid, packages, spdx | |||
| 785 | import tarfile | 796 | import tarfile |
| 786 | import bb.compress.zstd | 797 | import bb.compress.zstd |
| 787 | 798 | ||
| 788 | providers = collect_package_providers(d) | 799 | providers = oe.spdx_common.collect_package_providers(d) |
| 789 | package_archs = d.getVar("SSTATE_ARCHS").split() | 800 | package_archs = d.getVar("SSTATE_ARCHS").split() |
| 790 | package_archs.reverse() | 801 | package_archs.reverse() |
| 791 | 802 | ||
