Skip to content

Commit

Permalink
create-spdx-3.0/populate_sdk_base: Add SDK_CLASSES inherit mechanism …
Browse files Browse the repository at this point in the history
…to fix tarball SPDX manifests

Currently, "tarball" sdk based recipes don't generate SPDX manifests as they
don't include the rootfs generation classes. Split the SPDX 3.0 image class into
two so the SDK components can be included where needed.

To do this, introduce an SDK_CLASSES variable similar to IMAGE_CLASSES which
the SDK code can use.

Migrate testsdk usage to this.

Also move the image/sdk spdx classes to classes-recipe rather than the general classes
directory since they'd never be included on a global level.

For buildtools-tarball, it has its own testsdk functions so disable the class there as
a deferred inherit would overwrite it.

Signed-off-by: Richard Purdie <[email protected]>
  • Loading branch information
rpurdie committed Jul 26, 2024
1 parent 92a9710 commit 6623965
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,69 +77,3 @@ python do_create_image_sbom_spdx_setscene() {
sstate_setscene(d)
}
addtask do_create_image_sbom_spdx_setscene

do_populate_sdk[recrdeptask] += "do_create_spdx do_create_package_spdx"
do_populate_sdk[cleandirs] += "${SPDXSDKWORK}"
do_populate_sdk[postfuncs] += "sdk_create_sbom"
POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk = " sdk_host_create_spdx"
POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk = " sdk_target_create_spdx"

do_populate_sdk_ext[recrdeptask] += "do_create_spdx do_create_package_spdx"
do_populate_sdk_ext[cleandirs] += "${SPDXSDKEXTWORK}"
do_populate_sdk_ext[postfuncs] += "sdk_ext_create_sbom"
POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk-ext = " sdk_ext_host_create_spdx"
POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk-ext = " sdk_ext_target_create_spdx"

python sdk_host_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKWORK'))

oe.spdx30_tasks.sdk_create_spdx(d, "host", spdx_work_dir, d.getVar("TOOLCHAIN_OUTPUTNAME"))
}

python sdk_target_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKWORK'))

oe.spdx30_tasks.sdk_create_spdx(d, "target", spdx_work_dir, d.getVar("TOOLCHAIN_OUTPUTNAME"))
}

python sdk_ext_host_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKEXTWORK'))

# TODO: This doesn't seem to work
oe.spdx30_tasks.sdk_create_spdx(d, "host", spdx_work_dir, d.getVar("TOOLCHAINEXT_OUTPUTNAME"))
}

python sdk_ext_target_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKEXTWORK'))

# TODO: This doesn't seem to work
oe.spdx30_tasks.sdk_create_spdx(d, "target", spdx_work_dir, d.getVar("TOOLCHAINEXT_OUTPUTNAME"))
}


python sdk_create_sbom() {
from pathlib import Path
import oe.spdx30_tasks
sdk_deploydir = Path(d.getVar("SDKDEPLOYDIR"))
spdx_work_dir = Path(d.getVar('SPDXSDKWORK'))

oe.spdx30_tasks.create_sdk_sbom(d, sdk_deploydir, spdx_work_dir, d.getVar("TOOLCHAIN_OUTPUTNAME"))
}

python sdk_ext_create_sbom() {
from pathlib import Path
import oe.spdx30_tasks
sdk_deploydir = Path(d.getVar("SDKEXTDEPLOYDIR"))
spdx_work_dir = Path(d.getVar('SPDXSDKEXTWORK'))

oe.spdx30_tasks.create_sdk_sbom(d, sdk_deploydir, spdx_work_dir, d.getVar("TOOLCHAINEXT_OUTPUTNAME"))
}

72 changes: 72 additions & 0 deletions meta/classes-recipe/create-spdx-sdk-3.0.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
# SPDX SDK tasks

do_populate_sdk[recrdeptask] += "do_create_spdx do_create_package_spdx"
do_populate_sdk[cleandirs] += "${SPDXSDKWORK}"
do_populate_sdk[postfuncs] += "sdk_create_sbom"
POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk = " sdk_host_create_spdx"
POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk = " sdk_target_create_spdx"

do_populate_sdk_ext[recrdeptask] += "do_create_spdx do_create_package_spdx"
do_populate_sdk_ext[cleandirs] += "${SPDXSDKEXTWORK}"
do_populate_sdk_ext[postfuncs] += "sdk_ext_create_sbom"
POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk-ext = " sdk_ext_host_create_spdx"
POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk-ext = " sdk_ext_target_create_spdx"

python sdk_host_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKWORK'))

oe.spdx30_tasks.sdk_create_spdx(d, "host", spdx_work_dir, d.getVar("TOOLCHAIN_OUTPUTNAME"))
}

python sdk_target_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKWORK'))

oe.spdx30_tasks.sdk_create_spdx(d, "target", spdx_work_dir, d.getVar("TOOLCHAIN_OUTPUTNAME"))
}

python sdk_ext_host_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKEXTWORK'))

# TODO: This doesn't seem to work
oe.spdx30_tasks.sdk_create_spdx(d, "host", spdx_work_dir, d.getVar("TOOLCHAINEXT_OUTPUTNAME"))
}

python sdk_ext_target_create_spdx() {
from pathlib import Path
import oe.spdx30_tasks
spdx_work_dir = Path(d.getVar('SPDXSDKEXTWORK'))

# TODO: This doesn't seem to work
oe.spdx30_tasks.sdk_create_spdx(d, "target", spdx_work_dir, d.getVar("TOOLCHAINEXT_OUTPUTNAME"))
}


python sdk_create_sbom() {
from pathlib import Path
import oe.spdx30_tasks
sdk_deploydir = Path(d.getVar("SDKDEPLOYDIR"))
spdx_work_dir = Path(d.getVar('SPDXSDKWORK'))

oe.spdx30_tasks.create_sdk_sbom(d, sdk_deploydir, spdx_work_dir, d.getVar("TOOLCHAIN_OUTPUTNAME"))
}

python sdk_ext_create_sbom() {
from pathlib import Path
import oe.spdx30_tasks
sdk_deploydir = Path(d.getVar("SDKEXTDEPLOYDIR"))
spdx_work_dir = Path(d.getVar('SPDXSDKEXTWORK'))

oe.spdx30_tasks.create_sdk_sbom(d, sdk_deploydir, spdx_work_dir, d.getVar("TOOLCHAINEXT_OUTPUTNAME"))
}

3 changes: 3 additions & 0 deletions meta/classes-recipe/populate_sdk_base.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# SPDX-License-Identifier: MIT
#

SDK_CLASSES += "${@bb.utils.contains("IMAGE_CLASSES", "testimage", "testsdk", "", d)}"
inherit_defer ${SDK_CLASSES}

PACKAGES = ""

# This exists as an optimization for SPDX processing to only run in image and
Expand Down
2 changes: 0 additions & 2 deletions meta/classes-recipe/testimage.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,3 @@ python () {
if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"):
bb.build.addtask("testimage", "do_build", "do_image_complete", d)
}

inherit testsdk
1 change: 1 addition & 0 deletions meta/classes/create-spdx-3.0.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ SPDX_PACKAGE_SUPPLIER[doc] = "The base variable name to describe the Agent who \


IMAGE_CLASSES:append = " create-spdx-image-3.0"
SDK_CLASSES += "create-spdx-sdk-3.0"

oe.spdx30_tasks.set_timestamp_now[vardepsexclude] = "SPDX_INCLUDE_TIMESTAMPS"
oe.spdx30_tasks.get_package_sources_from_debug[vardepsexclude] += "STAGING_KERNEL_DIR"
Expand Down
3 changes: 3 additions & 0 deletions meta/recipes-core/meta/buildtools-tarball.bb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ INHIBIT_DEFAULT_DEPS = "1"
# Directory in testsdk that contains testcases
TESTSDK_CASES = "buildtools-cases"

# We have our own code, avoid deferred inherit
SDK_CLASSES:remove = "testsdk"

python do_testsdk() {
import oeqa.sdk.testsdk
testsdk = oeqa.sdk.testsdk.TestSDK()
Expand Down

0 comments on commit 6623965

Please sign in to comment.