Skip to contentSkip to conversation

Implement SPDX for deploy tasks

PATCH Superseded Joshua Watt 7 participants 105 messages Jun 9 – Nov 15 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

cover Implement SPDX for deploy tasks

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Joshua Watt (5):
classes/baremetal-image: Remove "do_" prefix from image manifest
spdx: Reformat
spdx: Add ability for deploy tasks to create SPDX
Add SPDX deploy tasks
spdx: Replace do_create_image_spdx with deploy task

 meta/classes-recipe/barebox.bbclass           |   3 +-
 meta/classes-recipe/baremetal-image.bbclass   |   2 +-
 .../create-spdx-image-3.0.bbclass             |  30 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/devicetree.bbclass        |   3 +-
 meta/classes-recipe/kernel-fit-image.bbclass  |   3 +-
 meta/classes-recipe/kernel.bbclass            |   3 +-
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 155 +++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/lib/oe/sbom30.py                         |  52 ++-
 meta/lib/oe/spdx30_tasks.py                   | 377 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/recipes-bsp/grub/grub-efi_2.14.bb        |   3 +-
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb     |   3 +-
 meta/recipes-bsp/u-boot/u-boot.inc            |   3 +-
 .../systemd/systemd-boot_259.5.bb             |   4 +-
 17 files changed, 509 insertions(+), 139 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/5 classes/baremetal-image: Remove "do_" prefix from image manifest

Removes the "do_" prefix from the image manifest to match the naming convention of image.bbclass

---
 meta/classes-recipe/baremetal-image.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-recipe/baremetal-image.bbclass +1 -1
index 4afc171314..7a6e71853b 100644
@@ -45,7 +45,7 @@ python do_image_complete(){
     import json
 
     data = {
-        "taskname": "do_image",
+        "taskname": "image",
         "imagetype": "baremetal-image",
         "images": []
     }
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/5 spdx: Reformat

In reply to Joshua Watt

Reformats SPDX files with black

---
 meta/lib/oe/sbom30.py       |  6 +--
 meta/lib/oe/spdx30_tasks.py | 76 ++++++++++++++++++++-----------------
 2 files changed, 44 insertions(+), 38 deletions(-)
meta/lib/oe/sbom30.py +3 -3
index b379ff947c..0926266295 100644
@@ -712,7 +712,7 @@ class ObjectSet(oe.spdx30.SHACLObjectSet):
         return self.add(v)
 
     def new_vex_patched_relationship(self, from_, to, notes: None):
-        props = {'security_statusNotes': notes} if notes else {}
+        props = {"security_statusNotes": notes} if notes else {}
         return self._new_relationship(
             oe.spdx30.security_VexFixedVulnAssessmentRelationship,
             from_,
@@ -724,7 +724,7 @@ class ObjectSet(oe.spdx30.SHACLObjectSet):
         )
 
     def new_vex_unpatched_relationship(self, from_, to, notes: None):
-        props = {'security_statusNotes': notes} if notes else {}
+        props = {"security_statusNotes": notes} if notes else {}
         return self._new_relationship(
             oe.spdx30.security_VexAffectedVulnAssessmentRelationship,
             from_,
@@ -737,7 +737,7 @@ class ObjectSet(oe.spdx30.SHACLObjectSet):
         )
 
     def new_vex_ignored_relationship(self, from_, to, *, impact_statement, notes: None):
-        props = {'security_statusNotes': notes} if notes else {}
+        props = {"security_statusNotes": notes} if notes else {}
         return self._new_relationship(
             oe.spdx30.security_VexNotAffectedVulnAssessmentRelationship,
             from_,
meta/lib/oe/spdx30_tasks.py +41 -35

171 lines not on this page · raw message

Signature · 1 line
2.54.0
#3 lore raw

PATCH 3/5 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 158 ++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 282 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 430 insertions(+), 65 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index 15a91e90e2..a96cfb25ed 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 7c99fcd1ec..b405f57d11 100644
@@ -11,3 +11,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +158 -0

167 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +237 -45

344 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 6b1a409c40..0337d1deb5 100644
@@ -113,7 +113,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.54.0
#4 lore raw

PATCH 4/5 Add SPDX deploy tasks

In reply to Joshua Watt

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 3 ++-
 meta/classes-recipe/devicetree.bbclass          | 3 ++-
 meta/classes-recipe/kernel-fit-image.bbclass    | 3 ++-
 meta/classes-recipe/kernel.bbclass              | 3 ++-
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 3 ++-
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 3 ++-
 meta/recipes-bsp/u-boot/u-boot.inc              | 3 ++-
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 4 ++--
 8 files changed, 16 insertions(+), 9 deletions(-)
meta/classes-recipe/barebox.bbclass +2 -1
index 73615999aa..0be611cf65 100644
@@ -157,6 +157,7 @@ barebox_do_deploy () {
                 done
         fi
 }
-addtask deploy after do_compile
+addtask deploy after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +2 -1
index ce9d008aac..a313507251 100644
@@ -163,7 +163,8 @@ devicetree_do_deploy() {
         install -Dm 0644 "${B}/$dtb_file" "${DEPLOYDIR}/devicetree/$dtb_file"
     done
 }
-addtask deploy before do_build after do_install
+addtask deploy before do_build after do_install do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +2 -1
index ae8f3c6688..becbc280ce 100644
@@ -240,4 +240,5 @@ do_deploy() {
         fi
     fi
 }
-addtask deploy after do_compile before do_build
+addtask deploy after do_compile do_create_spdx before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +2 -1
index 50cef17f69..5dc606048b 100644
@@ -841,7 +841,8 @@ kernel_do_deploy() {
 # ensure we get the right values for both
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
-addtask deploy after do_install do_populate_sysroot do_packagedata
+addtask deploy after do_install do_populate_sysroot do_packagedata do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +2 -1
index 6354b43989..db187ac373 100644
@@ -96,7 +96,8 @@ do_deploy() {
 	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
 }
 
-addtask deploy after do_install before do_build
+addtask deploy after do_install do_create_spdx before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +2 -1
index 0a9652c283..377a06fb78 100644
@@ -44,7 +44,8 @@ do_deploy () {
 	install -m 755 ${D}/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.* ${DEPLOYDIR}/
 }
 
-addtask deploy before do_build after do_install
+addtask deploy before do_build after do_install do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +2 -1
index a75948dfc3..1c3c9858df 100644
@@ -470,4 +470,5 @@ uboot_deploy_spl () {
     ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
 }
 
-addtask deploy before do_build after do_compile
+addtask deploy before do_build after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +2 -2
index c6c443f929..e2c579db97 100644
@@ -71,5 +71,5 @@ do_deploy () {
 	install ${B}/src/boot/addon*.efi.stub ${DEPLOYDIR}
 }
 
-addtask deploy before do_build after do_compile
-
+addtask deploy before do_build after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 1 line
2.54.0
#5 lore raw

Patchtest results for [OE-core][PATCH 4/5] Add SPDX deploy tasks

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/4-5-Add-SPDX-deploy-tasks.patch

FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#6 lore raw

Re: [OE-core][PATCH 4/5] Add SPDX deploy tasks

In reply to Joshua Watt

Hi,

Quoted 33 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 3 ++-
 meta/classes-recipe/devicetree.bbclass          | 3 ++-
 meta/classes-recipe/kernel-fit-image.bbclass    | 3 ++-
 meta/classes-recipe/kernel.bbclass              | 3 ++-
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 3 ++-
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 3 ++-
 meta/recipes-bsp/u-boot/u-boot.inc              | 3 ++-
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 4 ++--
 8 files changed, 16 insertions(+), 9 deletions(-)
meta/classes-recipe/barebox.bbclass +2 -1
index 73615999aa..0be611cf65 100644
@@ -157,6 +157,7 @@ barebox_do_deploy () {
                 done
         fi
 }
-addtask deploy after do_compile
+addtask deploy after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +0 -0
index ce9d008aac..a313507251 100644

meta/classes-recipe/devicetree.bbclass devicetree_do_deploy() { · line 167

Quoted 6 lines
meta/classes-recipe/devicetree.bbclass +2 -1
@@ -163,7 +163,8 @@ devicetree_do_deploy() {
         install -Dm 0644 "${B}/$dtb_file" "${DEPLOYDIR}/devicetree/$dtb_file"
     done
 }
-addtask deploy before do_build after do_install
+addtask deploy before do_build after do_install do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"

Could deploy.bbclass do this by default? There are plenty of similar changes needed in BSP etc layers which already use deploy.bbclass.

Cheers,

-Mikko

Quoted 91 lines
meta/classes-recipe/devicetree.bbclass +0 -0
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +2 -1
index ae8f3c6688..becbc280ce 100644
@@ -240,4 +240,5 @@ do_deploy() {
         fi
     fi
 }
-addtask deploy after do_compile before do_build
+addtask deploy after do_compile do_create_spdx before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +2 -1
index 50cef17f69..5dc606048b 100644
@@ -841,7 +841,8 @@ kernel_do_deploy() {
 # ensure we get the right values for both
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
-addtask deploy after do_install do_populate_sysroot do_packagedata
+addtask deploy after do_install do_populate_sysroot do_packagedata do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +2 -1
index 6354b43989..db187ac373 100644
@@ -96,7 +96,8 @@ do_deploy() {
 	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
 }
 
-addtask deploy after do_install before do_build
+addtask deploy after do_install do_create_spdx before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +2 -1
index 0a9652c283..377a06fb78 100644
@@ -44,7 +44,8 @@ do_deploy () {
 	install -m 755 ${D}/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.* ${DEPLOYDIR}/
 }
 
-addtask deploy before do_build after do_install
+addtask deploy before do_build after do_install do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +2 -1
index a75948dfc3..1c3c9858df 100644
@@ -470,4 +470,5 @@ uboot_deploy_spl () {
     ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
 }
 
-addtask deploy before do_build after do_compile
+addtask deploy before do_build after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +2 -2
index c6c443f929..e2c579db97 100644
@@ -71,5 +71,5 @@ do_deploy () {
 	install ${B}/src/boot/addon*.efi.stub ${DEPLOYDIR}
 }
 
-addtask deploy before do_build after do_compile
-
+addtask deploy before do_build after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 11 lines
2.54.0



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#238307): https://lists.openembedded.org/g/openembedded-core/message/238307
Mute This Topic: https://lists.openembedded.org/mt/119731707/7159507
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#7 lore raw

Re: [OE-core][PATCH 4/5] Add SPDX deploy tasks

In reply to Joshua Watt
Quoted 39 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 3 ++- meta/classes-recipe/devicetree.bbclass          | 3 ++- meta/classes-recipe/kernel-fit-image.bbclass    | 3 ++- meta/classes-recipe/kernel.bbclass              | 3 ++- meta/recipes-bsp/grub/grub-efi_2.14.bb          | 3 ++- meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 3 ++- meta/recipes-bsp/u-boot/u-boot.inc              | 3 ++- meta/recipes-core/systemd/systemd-boot_259.5.bb | 4 ++--

 8 files changed, 16 insertions(+), 9 deletions(-)
meta/classes-recipe/barebox.bbclass +0 -0
index 73615999aa..0be611cf65 100644
@@ -157,6 +157,7 @@ barebox_do_deploy () {

                 done
         fi
 }

meta/classes-recipe/barebox.bbclass +2 -1
-addtask deploy after do_compile
+addtask deploy after do_compile do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"


 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy

meta/classes-recipe/devicetree.bbclass +0 -0
index ce9d008aac..a313507251 100644
@@ -163,7 +163,8 @@ devicetree_do_deploy() {

         install -Dm 0644 "${B}/$dtb_file" "${DEPLOYDIR}/devicetree/$dtb_file" done
 }

meta/classes-recipe/devicetree.bbclass +2 -1
-addtask deploy before do_build after do_install
+addtask deploy before do_build after do_install do_create_spdx
+SPDX_DEPLOY_TASKS += "do_deploy"
Quoted 3 lines


 EXPORT_FUNCTIONS do_compile do_install do_deploy

Adding this "after do_create_spdx" makes spdx mandatory and impossible to disable which I'm not sure is what you intended?

Cheers,

Richard

#8 lore raw

PATCH 5/5 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 30 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 21 ++++++++-----
 5 files changed, 24 insertions(+), 32 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +10 -20
index a96cfb25ed..708981a0c0 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,23 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index b405f57d11..9c30c4d2c0 100644
@@ -9,6 +9,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index 19d5a45eba..c0263e4277 100644
@@ -358,9 +358,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +14 -7
index 3dae502e64..f5717b3919 100644
@@ -1539,19 +1539,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
     image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1644,13 +1644,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1672,7 +1677,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.54.0
#9 lore raw
In reply to Joshua Watt
Quoted 17 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Quoted 6 lines

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Joshua Watt (5):

Hi Joshua,

Thanks for your series. I believe we are seeing both a new error and new warnings because of it.

ERROR: grub-efi-2.14-r0 do_deploy_setscene: Recipe grub-efi is trying to install files into a shared area when those files already exist. The files and the manifests listing them are:
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/deploy/grub-efi-do_deploy-deploy.spdx.json
(matched in manifest-qemux86-grub-efi.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-task/grub-efi:do_deploy.spdx.json
(matched in manifest-qemux86-grub-efi.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-spdxid-hash/3c/3c29614c1a202bc0cc0a6f3dfd5b29235ea75ce5ee5bb0a847367bd8ce978004.spdx.json
(matched in manifest-qemux86-grub-efi.deploy)
Please adjust the recipes so only one recipe provides a given file.

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3852

WARNING: core-image-minimal-1.0-r0 do_create_deploy_sbom: The following SPDX IDs were unable to be resolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/500473e510f927d1a990e932c4942f978ce9da778692ab840dec17ad0ece09a1/pigz-native/UNIHASH/build/recipe

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3852
https://autobuilder.yoctoproject.org/valkyrie/#/builders/10/builds/3887
https://autobuilder.yoctoproject.org/valkyrie/#/builders/65/builds/3874

Can you have a look at the issues?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#10 lore raw
Quoted 41 lines · Mathieu Dubois-Briand
Quoted 17 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Quoted 6 lines

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Joshua Watt (5):

Hi Joshua,

Thanks for your series. I believe we are seeing both a new error and new warnings because of it.

ERROR: grub-efi-2.14-r0 do_deploy_setscene: Recipe grub-efi is trying to install files into a shared area when those files already exist. The files and the manifests listing them are:
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/deploy/grub-efi-do_deploy-deploy.spdx.json
(matched in manifest-qemux86-grub-efi.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-task/grub-efi:do_deploy.spdx.json
(matched in manifest-qemux86-grub-efi.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-spdxid-hash/3c/3c29614c1a202bc0cc0a6f3dfd5b29235ea75ce5ee5bb0a847367bd8ce978004.spdx.json
(matched in manifest-qemux86-grub-efi.deploy)
Please adjust the recipes so only one recipe provides a given file.

Quoted 1 line

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3852

This is caused because the grub-efi recipe changes subtly between qemux86 and genericx86: From bitbake -S printdiff:
Variable GRUB_IMAGE value changed from 'grub-efi-bootia32.efi' to
'bootia32.efi'
Variable GRUB_IMAGE_PREFIX value changed from '' to 'grub-efi-

However, the recipe arch is PACKAGE_ARCH, which is the same for both machines. I _think_ this means that grub-ef should be change to be MACHINE_ARCH instead, since its expected(?) that it will change based on machine and not just PACKAGE_ARCH, but I'm not sure about that.

Alternatively (or maybe in addition to), perhaps do_deploy SPDX output should always be written to a per-machine SPDX directory instead of using SSTATE_ARCH? This has congruence with DEPLOY_DIR_IMAGE containing MACHINE. I think this wouldn't actually work though because DEPLOY_DIR_IMAGE is an sstate output directory (so I think it can change without invalidating the task), where as SPDX is writing to SSTATE_ARCH as an sstate input directory.

Quoted 19 lines

WARNING: core-image-minimal-1.0-r0 do_create_deploy_sbom: The following SPDX IDs were unable to be resolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/500473e510f927d1a990e932c4942f978ce9da778692ab840dec17ad0ece09a1/pigz-native/UNIHASH/build/recipe

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3852
https://autobuilder.yoctoproject.org/valkyrie/#/builders/10/builds/3887
https://autobuilder.yoctoproject.org/valkyrie/#/builders/65/builds/3874

Can you have a look at the issues?

Thanks,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#11 lore raw

v2 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

Joshua Watt (5):
spdx: Add ability for deploy tasks to create SPDX classes-global/sstate: Keep SPDX generating setscene dependencies Add SPDX deploy tasks to various recipes
spdx: Replace do_create_image_spdx with deploy task
grub-efi: Change to MACHINE_ARCH

 meta/classes-global/sstate.bbclass            |  38 ++-
 meta/classes-recipe/barebox.bbclass           |   1 +
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/devicetree.bbclass        |   1 +
 meta/classes-recipe/kernel-fit-image.bbclass  |   1 +
 meta/classes-recipe/kernel.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 173 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 301 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/recipes-bsp/grub/grub-efi_2.14.bb        |   3 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb     |   1 +
 meta/recipes-bsp/u-boot/u-boot.inc            |   1 +
 .../systemd/systemd-boot_259.5.bb             |   2 +-
 17 files changed, 514 insertions(+), 94 deletions(-)
Signature · 1 line
2.54.0
#12 lore raw

PATCH v2 1/5 spdx: Add ability for deploy tasks to create SPDX

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 176 +++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 282 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 448 insertions(+), 65 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index 15a91e90e2..a96cfb25ed 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 7c99fcd1ec..b405f57d11 100644
@@ -11,3 +11,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +176 -0

185 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +237 -45

344 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 6b1a409c40..0337d1deb5 100644
@@ -113,7 +113,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.54.0
#13 lore raw

PATCH v2 2/5 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index 50dd0e51c4..833b78b870 100644
@@ -1115,11 +1115,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1132,6 +1149,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1188,12 +1207,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.54.0
#14 lore raw

PATCH v2 3/5 Add SPDX deploy tasks to various recipes

In reply to Joshua Watt

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index ae8f3c6688..5115482eff 100644
@@ -241,3 +241,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -1
index c6c443f929..c887835806 100644
@@ -72,4 +72,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 1 line
2.54.0
#15 lore raw

Patchtest results for [OE-core][PATCH v2 3/5] Add SPDX deploy tasks to various recipes

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/v2-3-5-Add-SPDX-deploy-tasks-to-various-recipes.patch

FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#16 lore raw

PATCH v2 4/5 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 21 ++++++++----
 5 files changed, 26 insertions(+), 32 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index a96cfb25ed..838a82c802 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index b405f57d11..9c30c4d2c0 100644
@@ -9,6 +9,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index 13d1de2774..919de094f8 100644
@@ -373,9 +373,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +14 -7
index 4a7d442ac7..6a3a626db1 100644
@@ -1539,19 +1539,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
     image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1644,13 +1644,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1672,7 +1677,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.54.0
#17 lore raw

PATCH v2 5/5 grub-efi: Change to MACHINE_ARCH

In reply to Joshua Watt

Machines can change EFI_PROVIDER which changes the way grub-efi is built, meaning two machine may not build it the same way. As such, the arch should be MACHINE_ARCH.

---
 meta/recipes-bsp/grub/grub-efi_2.14.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-bsp/grub/grub-efi_2.14.bb +2 -0
index e535d99710..8d8671614a 100644
@@ -41,6 +41,8 @@ python __anonymous () {
     d.setVar("GRUB_IMAGE_PREFIX", prefix)
 }
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 inherit deploy
 
 CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
Signature · 1 line
2.54.0
#18 lore raw
In reply to Joshua Watt
Quoted 22 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Quoted 6 lines

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

Hi Joshua,

Thanks for the new version, but I'm still seeing some errors on the autobuilder:

ERROR: systemd-boot-259.5-r0 do_deploy_setscene: Recipe systemd-boot is trying to install files into a shared area when those files already exist. The files and the manifests listing them are:
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-task/systemd-boot:do_deploy.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/deploy/systemd-boot-do_deploy-deploy.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-spdxid-hash/c0/c00d8889d28fc9521178ce481c8e76cfc116eb5f57bb1c1bb7d9d98271b16e07.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
Please adjust the recipes so only one recipe provides a given file.

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3927

2026-06-20 11:34:04,962 - oe-selftest - INFO - spdx.SPDX30Check.test_baremetal_helloworld (subunit.RemotedTestCase)
2026-06-20 11:34:04,963 - oe-selftest - INFO -  ... FAIL
...
2026-06-20 11:34:04,963 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 155, in test_baremetal_helloworld
    self.check_objset_missing_ids(objset)
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 73, in check_objset_missing_ids
    self.assertTrue(
  File "/usr/lib/python3.11/unittest/case.py", line 715, in assertTrue
    raise self.failureException(msg)

AssertionError: False is not true : The following SPDXIDs are unresolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/de503ed2af15b13f05a8f9025f181bbb421f080060947c2e31b480bd76d017b7/linux-libc-headers/UNIHASH/recipe/linux-libc-headers

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4105
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3936

Can you have a loot at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#19 lore raw
Quoted 57 lines · Mathieu Dubois-Briand
Quoted 22 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Quoted 6 lines

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

Hi Joshua,

Thanks for the new version, but I'm still seeing some errors on the autobuilder:

ERROR: systemd-boot-259.5-r0 do_deploy_setscene: Recipe systemd-boot is trying to install files into a shared area when those files already exist. The files and the manifests listing them are:
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-task/systemd-boot:do_deploy.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/deploy/systemd-boot-do_deploy-deploy.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-spdxid-hash/c0/c00d8889d28fc9521178ce481c8e76cfc116eb5f57bb1c1bb7d9d98271b16e07.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
Please adjust the recipes so only one recipe provides a given file.

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3927

2026-06-20 11:34:04,962 - oe-selftest - INFO - spdx.SPDX30Check.test_baremetal_helloworld (subunit.RemotedTestCase)
2026-06-20 11:34:04,963 - oe-selftest - INFO -  ... FAIL
...
2026-06-20 11:34:04,963 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 155, in test_baremetal_helloworld
    self.check_objset_missing_ids(objset)
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 73, in check_objset_missing_ids
    self.assertTrue(
  File "/usr/lib/python3.11/unittest/case.py", line 715, in assertTrue
    raise self.failureException(msg)
Quoted 5 lines

AssertionError: False is not true : The following SPDXIDs are unresolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/de503ed2af15b13f05a8f9025f181bbb421f080060947c2e31b480bd76d017b7/linux-libc-headers/UNIHASH/recipe/linux-libc-headers

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4105
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3936

Mathieu, I looked at these links, but they do not seem to be related to the error you listed; are they perhaps wrong? If so can you provide the correct links?

Thanks

Quoted 11 lines

Can you have a loot at the issue?

Thanks,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#20 lore raw
Quoted 62 lines · Joshua Watt
Quoted 60 lines · Mathieu Dubois-Briand
Quoted 22 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Quoted 6 lines

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

Hi Joshua,

Thanks for the new version, but I'm still seeing some errors on the autobuilder:

ERROR: systemd-boot-259.5-r0 do_deploy_setscene: Recipe systemd-boot is trying to install files into a shared area when those files already exist. The files and the manifests listing them are:
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-task/systemd-boot:do_deploy.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/deploy/systemd-boot-do_deploy-deploy.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
/srv/pokybuild/yocto-worker/wic/build/build/tmp/deploy/spdx/3.0.1/core2-32/by-spdxid-hash/c0/c00d8889d28fc9521178ce481c8e76cfc116eb5f57bb1c1bb7d9d98271b16e07.spdx.json
(matched in manifest-qemux86-systemd-boot.deploy)
Please adjust the recipes so only one recipe provides a given file.

https://autobuilder.yoctoproject.org/valkyrie/#/builders/15/builds/3927

2026-06-20 11:34:04,962 - oe-selftest - INFO - spdx.SPDX30Check.test_baremetal_helloworld (subunit.RemotedTestCase)
2026-06-20 11:34:04,963 - oe-selftest - INFO -  ... FAIL
...
2026-06-20 11:34:04,963 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 155, in test_baremetal_helloworld
    self.check_objset_missing_ids(objset)
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 73, in check_objset_missing_ids
    self.assertTrue(
  File "/usr/lib/python3.11/unittest/case.py", line 715, in assertTrue
    raise self.failureException(msg)

AssertionError: False is not true : The following SPDXIDs are unresolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/de503ed2af15b13f05a8f9025f181bbb421f080060947c2e31b480bd76d017b7/linux-libc-headers/UNIHASH/recipe/linux-libc-headers

Quoted 9 lines
Quoted 2 lines

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4105
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3936

Mathieu, I looked at these links, but they do not seem to be related to the error you listed; are they perhaps wrong? If so can you provide the correct links?

Thanks

I believe the links are correct, but maybe the fact that we have unrelated (weston) failures is a bit misleading.

Yet I confirm we have test_baremetal_helloworld failures:
- lines 7695 / 7803 of https://autobuilder.yoctoproject.org/valkyrie/?#/builders/35/builds/4105/steps/15/logs/stdio
- lines 7330 / 7478 of https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3936/steps/15/logs/stdio

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#21 lore raw

v3 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

Joshua Watt (8):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies Add SPDX deploy tasks to various recipes
spdx: Replace do_create_image_spdx with deploy task
grub-efi: Change to MACHINE_ARCH
systemd-boot: Change to MACHINE_ARCH

 meta/classes-global/sstate.bbclass            |  38 ++-
 meta/classes-recipe/barebox.bbclass           |   1 +
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/devicetree.bbclass        |   1 +
 meta/classes-recipe/kernel-fit-image.bbclass  |   1 +
 meta/classes-recipe/kernel.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 173 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 314 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        |   3 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb     |   1 +
 meta/recipes-bsp/u-boot/u-boot.inc            |   1 +
 .../systemd/systemd-boot_259.5.bb             |   4 +-
 18 files changed, 534 insertions(+), 100 deletions(-)
Signature · 1 line
2.54.0
#22 lore raw

PATCH v3 1/8 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 72d17aade6..fc78586cf2 100644
@@ -330,13 +330,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.54.0
#23 lore raw

PATCH v3 2/8 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 176 +++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 282 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 448 insertions(+), 65 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index 15a91e90e2..a96cfb25ed 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 7c99fcd1ec..b405f57d11 100644
@@ -11,3 +11,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +176 -0

185 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +237 -45

344 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 6b1a409c40..0337d1deb5 100644
@@ -113,7 +113,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.54.0
#24 lore raw

PATCH v3 3/8 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index 8285189382..af2a9dc236 100644
@@ -443,3 +443,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
                 r'\d',
                 f"Version '{version}' for package '{name}' should contain digits"
             )
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.54.0
#25 lore raw

PATCH v3 4/8 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index 4ad71a70da..4d744a887b 100644
@@ -1119,11 +1119,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1136,6 +1153,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1192,12 +1211,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.54.0
#26 lore raw

PATCH v3 5/8 Add SPDX deploy tasks to various recipes

In reply to Joshua Watt

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index ae8f3c6688..5115482eff 100644
@@ -241,3 +241,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -1
index c6c443f929..c887835806 100644
@@ -72,4 +72,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 1 line
2.54.0
#27 lore raw

Patchtest results for [OE-core][PATCH v3 5/8] Add SPDX deploy tasks to various recipes

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/v3-5-8-Add-SPDX-deploy-tasks-to-various-recipes.patch

FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#28 lore raw

Re: [OE-core][PATCH v3 5/8] Add SPDX deploy tasks to various recipes

In reply to Joshua Watt

Hi,

Quoted 4 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

Quoted 10 lines
---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)

Why not doing this in deploy.bbclass for all users of the class?

Cheers

-Mikko

Quoted 100 lines
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index ae8f3c6688..5115482eff 100644
@@ -241,3 +241,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -1
index c6c443f929..c887835806 100644
@@ -72,4 +72,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 11 lines
2.54.0



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239514): https://lists.openembedded.org/g/openembedded-core/message/239514
Mute This Topic: https://lists.openembedded.org/mt/119957548/7159507
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#29 lore raw

Re: [OE-core][PATCH v3 5/8] Add SPDX deploy tasks to various recipes

Quoted 19 lines · Mikko Rapeli

Hi,

Quoted 4 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

Quoted 10 lines
---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
Quoted 1 line

Why not doing this in deploy.bbclass for all users of the class?

We probably could do that; I guess I'd like some feedback if anyone else thinks that's a good idea or not. I initially did it this way just to minimize disruption

Quoted 106 lines

Cheers

-Mikko

Quoted 100 lines
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index ae8f3c6688..5115482eff 100644
@@ -241,3 +241,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -2
index c6c443f929..c887835806 100644
@@ -72,4 +72,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
--

2.54.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239514): https://lists.openembedded.org/g/openembedded-core/message/239514
Mute This Topic: https://lists.openembedded.org/mt/119957548/7159507
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#30 lore raw

Re: [OE-core][PATCH v3 5/8] Add SPDX deploy tasks to various recipes

Hi,

Quoted 20 lines · Joshua Watt
Quoted 19 lines · Mikko Rapeli

Hi,

Quoted 14 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line

Why not doing this in deploy.bbclass for all users of the class?

We probably could do that; I guess I'd like some feedback if anyone else thinks that's a good idea or not. I initially did it this way just to minimize disruption

As an example, meta-arm qemuarm64-secureboot machine builds u-boot with tf-a and optee which I think are all linked to a single u-boot binary. Both tf-a and optee binaries are captured via deploy directory, and u-boot exports the flash binary via deploy directory as well. None of these are visible in the rootfs images if the userspace optee-client, optee-examples, optee-test, TEE applications like optee-ftpm or tf-a tests are not installed.

Are all their SPDX and license data correctly captured with current approach via u-boot?

If yes, then things are better, but there are still a lot of external BSP etc layer recipes which use only deploy.bbclass to export their blobs which get flashed to target. Covering those as well via use of deploy.bbclass would be better, IMO.

Cheers,

-Mikko

Quoted 106 lines
Quoted 106 lines

Cheers

-Mikko

Quoted 100 lines
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index ae8f3c6688..5115482eff 100644
@@ -241,3 +241,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -2
index c6c443f929..c887835806 100644
@@ -72,4 +72,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
--

2.54.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239514): https://lists.openembedded.org/g/openembedded-core/message/239514
Mute This Topic: https://lists.openembedded.org/mt/119957548/7159507
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#31 lore raw

Re: [OE-core][PATCH v3 5/8] Add SPDX deploy tasks to various recipes

Quoted 30 lines · Mikko Rapeli

Hi,

Quoted 20 lines · Joshua Watt
Quoted 19 lines · Mikko Rapeli

Hi,

Quoted 14 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line

Why not doing this in deploy.bbclass for all users of the class?

We probably could do that; I guess I'd like some feedback if anyone else thinks that's a good idea or not. I initially did it this way just to minimize disruption

Quoted 8 lines

As an example, meta-arm qemuarm64-secureboot machine builds u-boot with tf-a and optee which I think are all linked to a single u-boot binary. Both tf-a and optee binaries are captured via deploy directory, and u-boot exports the flash binary via deploy directory as well. None of these are visible in the rootfs images if the userspace optee-client, optee-examples, optee-test, TEE applications like optee-ftpm or tf-a tests are not installed.

Are all their SPDX and license data correctly captured with current approach via u-boot?

That is the intention. As long as the do_deploy of u-boot has a dependency on do_deploy of the optee-ftpm and tf-a (either directly, or transitively through prior tasks in u-boot), it should get captured.

Quoted 4 lines

If yes, then things are better, but there are still a lot of external BSP etc layer recipes which use only deploy.bbclass to export their blobs which get flashed to target. Covering those as well via use of deploy.bbclass would be better, IMO.

Right. Even if it's not done in deploy.bbclass, adding the SPDX_DEPLOY_TASKS += "do_deploy" should be all that is needed, making it easy if not automatic.

Quoted 111 lines

Cheers,

-Mikko

Quoted 106 lines
Quoted 106 lines

Cheers

-Mikko

Quoted 100 lines
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index ae8f3c6688..5115482eff 100644
@@ -241,3 +241,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -2
index c6c443f929..c887835806 100644
@@ -72,4 +72,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
--

2.54.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239514): https://lists.openembedded.org/g/openembedded-core/message/239514
Mute This Topic: https://lists.openembedded.org/mt/119957548/7159507
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#32 lore raw

PATCH v3 6/8 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 21 ++++++++----
 5 files changed, 26 insertions(+), 32 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index a96cfb25ed..838a82c802 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index b405f57d11..9c30c4d2c0 100644
@@ -9,6 +9,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index 13d1de2774..919de094f8 100644
@@ -373,9 +373,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +14 -7
index c58c8c30e1..79c608d8e5 100644
@@ -1540,19 +1540,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
     image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1645,13 +1645,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1673,7 +1678,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.54.0
#33 lore raw

PATCH v3 7/8 grub-efi: Change to MACHINE_ARCH

In reply to Joshua Watt

Machines can change EFI_PROVIDER which changes the way grub-efi is built, meaning two machine may not build it the same way. As such, the arch should be MACHINE_ARCH.

---
 meta/recipes-bsp/grub/grub-efi_2.14.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-bsp/grub/grub-efi_2.14.bb +2 -0
index e535d99710..8d8671614a 100644
@@ -41,6 +41,8 @@ python __anonymous () {
     d.setVar("GRUB_IMAGE_PREFIX", prefix)
 }
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 inherit deploy
 
 CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
Signature · 1 line
2.54.0
#34 lore raw

PATCH v3 8/8 systemd-boot: Change to MACHINE_ARCH

In reply to Joshua Watt

Machines can change EFI_PROVIDER which changes the way systemd-boot is built, meaning two machine may not build it the same way. As such, the arch should be MACHINE_ARCH.

---
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-core/systemd/systemd-boot_259.5.bb +2 -0
index c887835806..787d4652a2 100644
@@ -8,6 +8,8 @@ DEPENDS = "libcap util-linux gperf-native python3-jinja2-native python3-pyelftoo
 inherit meson pkgconfig gettext
 inherit deploy
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 LDFLAGS =+ "${@ " ".join(d.getVar('LD').split()[1:])} "
 
 EFI_LD = "bfd"
Signature · 1 line
2.54.0
#35 lore raw
In reply to Joshua Watt
Quoted 22 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Quoted 9 lines

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

Hi Joshua,

Thanks for the new version.

We still have a failing selftest here:

2026-06-24 19:12:57,622 - oe-selftest - INFO - sstatetests.SStateHashSameSigs3.test_sstate_sametune_samesigs (subunit.RemotedTestCase)
2026-06-24 19:12:57,624 - oe-selftest - INFO -  ... FAIL
...
2026-06-24 19:12:57,624 - oe-selftest - INFO - 4: 25/26 507/695 (312.34s) (0 failed) (sstatetests.SStateHashSameSigs3.test_sstate_sametune_samesigs)
2026-06-24 19:12:57,624 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/sstatetests.py", line 539, in test_sstate_sametune_samesigs
    self.assertCountEqual(files1, files2)
  File "/usr/lib/python3.12/unittest/case.py", line 1216, in assertCountEqual
    self.fail(msg)
  File "/usr/lib/python3.12/unittest/case.py", line 715, in fail
    raise self.failureException(msg)
AssertionError: Element counts were not equal:
First has 1, Second has 0:  '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-719621/tmp-sstatesamehash/stamps/core2-32-poky-linux/wic-tools/1.0.do_create_spdx.sigdata.85e2be6fe9ccda65abb33aacd4f946a084919518fc0ffc44e3e5698d1c2a98c7'
First has 1, Second has 0:  '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-719621/tmp-sstatesamehash/stamps/core2-32-poky-linux/wic-tools/1.0.do_compile.sigdata.fca66a6aef4d6bda698a57e8297346d610e2b3841dce7f1585dc33bc80d0592e'
First has 1, Second has 0:  '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-719621/tmp-sstatesamehash/stamps/core2-32-poky-linux/wic-tools/1.0.do_prepare_recipe_sysroot.sigdata.377ccf122b60bb2eff57f9c1dbbda056b8d3c687ab594cf2db80c3970706c170'
First has 1, Second has 0:  '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-719621/tmp-sstatesamehash/stamps/core2-32-poky-linux/wic-tools/1.0.do_configure.sigdata.2969439d8a538b9adc3ebf73eb457cce106dbbb1062cc66e9a64cf5a221306dc'
First has 1, Second has 0:  '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-719621/tmp-sstatesamehash/stamps/core2-32-poky-linux/wic-tools/1.0.do_populate_sysroot.sigdata.e8973cc6f00edf67eb1adebfdaa8487edaf137f61b7eec220911b7a1b9afb83c'

...

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/4199
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4140
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3969

Can you have a look at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#36 lore raw

v4 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

Joshua Watt (10):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies Add SPDX deploy tasks to various recipes
spdx: Replace do_create_image_spdx with deploy task
grub-efi: Change to MACHINE_ARCH
systemd-boot: Change to MACHINE_ARCH
multilib: Add systemd-boot to NON_MULTILIB_RECIPES
wic-tools: Change to MACHINE_ARCH

 meta/classes-global/sstate.bbclass            |  38 ++-
 meta/classes-recipe/barebox.bbclass           |   1 +
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/devicetree.bbclass        |   1 +
 meta/classes-recipe/kernel-fit-image.bbclass  |   1 +
 meta/classes-recipe/kernel.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 173 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/conf/multilib.conf                       |   2 +-
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 314 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        |   3 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb     |   1 +
 meta/recipes-bsp/u-boot/u-boot.inc            |   1 +
 meta/recipes-core/meta/wic-tools.bb           |   2 +
 .../systemd/systemd-boot_259.5.bb             |   4 +-
 20 files changed, 537 insertions(+), 101 deletions(-)
Signature · 1 line
2.54.0
#37 lore raw

PATCH v4 1/10 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 79e18db11d..d747a9cf13 100644
@@ -330,13 +330,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.54.0
#38 lore raw

PATCH v4 2/10 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 176 +++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 282 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 448 insertions(+), 65 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index cf79ef5b01..b60cdd826f 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 6ccb93ba01..723194da2d 100644
@@ -12,3 +12,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +176 -0

185 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +237 -45

344 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 6b1a409c40..0337d1deb5 100644
@@ -113,7 +113,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.54.0
#39 lore raw

PATCH v4 3/10 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index 8285189382..af2a9dc236 100644
@@ -443,3 +443,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
                 r'\d',
                 f"Version '{version}' for package '{name}' should contain digits"
             )
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.54.0
#40 lore raw

PATCH v4 4/10 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index 4ad71a70da..4d744a887b 100644
@@ -1119,11 +1119,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1136,6 +1153,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1192,12 +1211,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.54.0
#41 lore raw

PATCH v4 5/10 Add SPDX deploy tasks to various recipes

In reply to Joshua Watt

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass             | 1 +
 meta/classes-recipe/devicetree.bbclass          | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass    | 1 +
 meta/classes-recipe/kernel.bbclass              | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb          | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.8.1.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc              | 1 +
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/barebox.bbclass +1 -0
index 2411fb5caa..60437c1ad1 100644
@@ -158,5 +158,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index ce9d008aac..35c2499bdb 100644
@@ -164,6 +164,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index 448a88ccb1..02dd245d97 100644
@@ -248,3 +248,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 50cef17f69..8d0cb91688 100644
@@ -842,6 +842,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index 6354b43989..e535d99710 100644
@@ -97,6 +97,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.8.1.bb +1 -0
index 0a9652c283..93646a97df 100644
@@ -45,6 +45,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index a75948dfc3..acc2bf9819 100644
@@ -471,3 +471,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_259.5.bb +1 -1
index aa5e57d3dd..9e61dfa3c6 100644
@@ -69,4 +69,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 1 line
2.54.0
#42 lore raw

PATCH v4 6/10 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 21 ++++++++----
 5 files changed, 26 insertions(+), 32 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index b60cdd826f..64cb065632 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom-spdx = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index 723194da2d..fafcdd0a13 100644
@@ -10,6 +10,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index 13d1de2774..919de094f8 100644
@@ -373,9 +373,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +14 -7
index 676eb09888..f3a60e3deb 100644
@@ -1546,19 +1546,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
     image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1651,13 +1651,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1679,7 +1684,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.54.0
#43 lore raw

PATCH v4 7/10 grub-efi: Change to MACHINE_ARCH

In reply to Joshua Watt

Machines can change EFI_PROVIDER which changes the way grub-efi is built, meaning two machine may not build it the same way. As such, the arch should be MACHINE_ARCH.

---
 meta/recipes-bsp/grub/grub-efi_2.14.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-bsp/grub/grub-efi_2.14.bb +2 -0
index e535d99710..8d8671614a 100644
@@ -41,6 +41,8 @@ python __anonymous () {
     d.setVar("GRUB_IMAGE_PREFIX", prefix)
 }
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 inherit deploy
 
 CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
Signature · 1 line
2.54.0
#44 lore raw

PATCH v4 8/10 systemd-boot: Change to MACHINE_ARCH

In reply to Joshua Watt

Machines can change EFI_PROVIDER which changes the way systemd-boot is built, meaning two machine may not build it the same way. As such, the arch should be MACHINE_ARCH.

---
 meta/recipes-core/systemd/systemd-boot_259.5.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-core/systemd/systemd-boot_259.5.bb +2 -0
index 9e61dfa3c6..c9bc3e2a91 100644
@@ -8,6 +8,8 @@ DEPENDS = "libcap util-linux gperf-native python3-jinja2-native python3-pyelftoo
 inherit meson pkgconfig gettext
 inherit deploy
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 LDFLAGS =+ "${@ " ".join(d.getVar('LD').split()[1:])} "
 
 EFI_LD = "bfd"
Signature · 1 line
2.54.0
#45 lore raw

PATCH v4 9/10 multilib: Add systemd-boot to NON_MULTILIB_RECIPES

In reply to Joshua Watt

systemd-boot is EFI firmware (like grub-efi) and doesn't make sense to be multilib

---
 meta/conf/multilib.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/multilib.conf +1 -1
index 6163405be4..aff55c1e9d 100644
@@ -23,4 +23,4 @@ APT_ARGS:append = " -o Dpkg::Options::=--force-confnew -o Dpkg::Options::=--forc
 
 # These recipes don't need multilib variants, the ${BPN} PROVIDES/RPROVIDES
 # ${MLPREFIX}${BPN}
-NON_MULTILIB_RECIPES = "grub grub-efi make-mod-scripts ovmf u-boot gcc-source llvm-project-source"
+NON_MULTILIB_RECIPES = "grub grub-efi make-mod-scripts ovmf u-boot gcc-source llvm-project-source systemd-boot"
Signature · 1 line
2.54.0
#46 lore raw

PATCH v4 10/10 wic-tools: Change to MACHINE_ARCH

In reply to Joshua Watt

Changes wic-tools to be MACHINE_ARCH. This isn't exactly an ideal, but wic-tools is attempting to provide a target sysroot that (potentially) contains the EFI binaries for wic (and, this is the only way wic is willing to find those binaries). Since the EFI binaries are MACHINE_ARCH, wic-tools must also be MACHINE_ARCH otherwise it causes problems.

---
 meta/recipes-core/meta/wic-tools.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-core/meta/wic-tools.bb +2 -0
index 45fb873dd6..823dbe6db6 100644
@@ -17,6 +17,8 @@ DEPENDS:append:aarch64 = " grub-efi systemd-boot"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 inherit nopackages
 
 # The sysroot of wic-tools is needed for wic, but if rm_work is enabled, it will
Signature · 1 line
2.54.0
#47 lore raw
In reply to Joshua Watt
Quoted 28 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

Quoted 6 lines

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

Hi Joshua,

Thanks for the new version. We now have just one warning remaining:

WARNING: core-image-full-cmdline-1.0-r0 do_create_image_sbom_spdx: The following SPDX IDs were unable to be resolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/6e0461f8d0ebcd6cab741ff4175cb1256279c1657d809f71c257fb2a0991e7ca/eudev/UNIHASH/package/eudev
...
WARNING: core-image-sato-1.0-r0 do_create_image_sbom_spdx: The following SPDX IDs were unable to be resolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/6e0461f8d0ebcd6cab741ff4175cb1256279c1657d809f71c257fb2a0991e7ca/eudev/UNIHASH/package/eudev

https://autobuilder.yoctoproject.org/valkyrie/#/builders/22/builds/4059

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#48 lore raw
In reply to Joshua Watt
Quoted 34 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

Quoted 11 lines

Joshua Watt (10):
  spdx: Skip dependencies that are not in the taskhash
  spdx: Add ability for deploy tasks to create SPDX
  oeqa: Add SPDX deploy SBoM test
  classes-global/sstate: Keep SPDX generating setscene dependencies Add SPDX deploy tasks to various recipes
  spdx: Replace do_create_image_spdx with deploy task
  grub-efi: Change to MACHINE_ARCH
  systemd-boot: Change to MACHINE_ARCH
  multilib: Add systemd-boot to NON_MULTILIB_RECIPES
  wic-tools: Change to MACHINE_ARCH

There is something not quite right in here which I suspect, but havve't currently conclusively prove caused:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/4276
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4216

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#50 lore raw
Quoted 67 lines · Richard Purdie via lists.openembedded.org
Quoted 53 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX
was first implemented, however there has always been a desire to also
express SPDX output for other non-image deliverables (primarily, those
that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that
runs to create their SPDX output as this causes lots of problems with
the way dependencies are specified. Instead, it is desirable for these
tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts
with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it
will run a postfunc to generate SPDX output that describes what is being
deployed. For classical do_deploy tasks, this is setup to be easy by
automatically capturing all the deployed output files in the SPDX data,
but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a
SPDX deploy postfunc using this new system. This means that any task
that depends on do_image_complete will automatically also get the SPDX
output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in
a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are
restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be
missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to
be MACHINE_ARCH (and consequently, wic-tools)

Quoted 11 lines

Joshua Watt (10):
  spdx: Skip dependencies that are not in the taskhash
  spdx: Add ability for deploy tasks to create SPDX
  oeqa: Add SPDX deploy SBoM test
  classes-global/sstate: Keep SPDX generating setscene dependencies Add SPDX deploy tasks to various recipes
  spdx: Replace do_create_image_spdx with deploy task
  grub-efi: Change to MACHINE_ARCH
  systemd-boot: Change to MACHINE_ARCH
  multilib: Add systemd-boot to NON_MULTILIB_RECIPES
  wic-tools: Change to MACHINE_ARCH

Quoted 6 lines

There is something not quite right in here which I suspect, but havve't
currently conclusively prove caused:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/4276
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4216

Those failures were not related to this series...

Cheers,

Richard

#51 lore raw

v5 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

he SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

Joshua Watt (6):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies Add SPDX deploy tasks to various recipes
spdx: Replace do_create_image_spdx with deploy task

 meta/classes-global/sstate.bbclass            |  38 ++-
 meta/classes-recipe/barebox.bbclass           |   1 +
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/devicetree.bbclass        |   1 +
 meta/classes-recipe/kernel-fit-image.bbclass  |   1 +
 meta/classes-recipe/kernel.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 178 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 316 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        |   1 +
 meta/recipes-bsp/opensbi/opensbi_1.9.bb       |   1 +
 meta/recipes-bsp/u-boot/u-boot.inc            |   1 +
 meta/recipes-core/systemd/systemd-boot_262.bb |   2 +-
 18 files changed, 536 insertions(+), 101 deletions(-)
Signature · 1 line
2.56.0
#52 lore raw

PATCH v5 1/6 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 1d11d8d1d2..3dd87c2a75 100644
@@ -306,13 +306,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.56.0
#53 lore raw

PATCH v5 2/6 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 181 +++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 282 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 453 insertions(+), 65 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index cf79ef5b01..b60cdd826f 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 6ccb93ba01..723194da2d 100644
@@ -12,3 +12,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +181 -0

190 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +237 -45

344 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 07bf9650e2..9a862d9f5a 100644
@@ -118,7 +118,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.56.0
#54 lore raw

PATCH v5 3/6 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index c900558b44..8cc51c1369 100644
@@ -485,3 +485,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
 
         for candidate in objset.foreach_type(oe.spdx30.software_Package):
             self.assertIsNone(candidate.releaseTime)
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.56.0
#55 lore raw

PATCH v5 4/6 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index b2fa93650a..c6d9459182 100644
@@ -1125,11 +1125,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1142,6 +1159,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1198,12 +1217,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.56.0
#56 lore raw

PATCH v5 5/6 Add SPDX deploy tasks to various recipes

In reply to Joshua Watt

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

---
 meta/classes-recipe/barebox.bbclass           | 1 +
 meta/classes-recipe/devicetree.bbclass        | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass  | 1 +
 meta/classes-recipe/kernel.bbclass            | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.9.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc            | 1 +
 meta/recipes-core/systemd/systemd-boot_262.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/barebox.bbclass +1 -0
index 3980849b53..252e97fa65 100644
@@ -165,5 +165,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index 4fe389bed8..affbf115c2 100644
@@ -166,6 +166,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index 7b2bcd4673..d0f7274e70 100644
@@ -260,3 +260,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 0a6d754108..14c71dec54 100644
@@ -840,6 +840,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index d19b33b504..8d8671614a 100644
@@ -99,6 +99,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.9.bb +1 -0
index 96167f7c73..bb35f906b2 100644
@@ -49,6 +49,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index b9f61a185c..1c9911ff6e 100644
@@ -474,3 +474,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_262.bb +1 -1
index bab2e7ae27..c9bc3e2a91 100644
@@ -71,4 +71,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 1 line
2.56.0
#57 lore raw

Patchtest results for [OE-core][PATCH v5 5/6] Add SPDX deploy tasks to various recipes

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/v5-5-6-Add-SPDX-deploy-tasks-to-various-recipes.patch

FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)

PASS: pretest src uri left files (test_metadata.TestMetadata.pretest_src_uri_left_files)
PASS: test CVE check ignore (test_metadata.TestMetadata.test_cve_check_ignore)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test auh changelog truncation notice (test_mbox.TestMbox.test_auh_changelog_truncation_notice)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test lic files chksum modified not mentioned (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test src uri left files (test_metadata.TestMetadata.test_src_uri_left_files)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new source patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new source patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new source patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#58 lore raw

Re: [OE-core][PATCH v5 5/6] Add SPDX deploy tasks to various recipes

In reply to Joshua Watt
Quoted 2 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

I think this should be the default in deploy.bbclass.

The class is used to deploy files to "build output". A lot of BSP etc recipes use the class for this purpose and they are currently missing in SPDX output unless some output packages go to image rootfs.

I think capturing too much data in SPDX is less of a problem than not capturing enough. Thus deploy.bbclass should support SPDX output by default, when SPDX is enabled.

If there are other very good reasons for not enabling this by default, then I think the commit message should say that.

Cheers,

-Mikko

Quoted 112 lines
---
 meta/classes-recipe/barebox.bbclass           | 1 +
 meta/classes-recipe/devicetree.bbclass        | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass  | 1 +
 meta/classes-recipe/kernel.bbclass            | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.9.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc            | 1 +
 meta/recipes-core/systemd/systemd-boot_262.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/barebox.bbclass +1 -0
index 3980849b53..252e97fa65 100644
@@ -165,5 +165,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
meta/classes-recipe/devicetree.bbclass +1 -0
index 4fe389bed8..affbf115c2 100644
@@ -166,6 +166,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
meta/classes-recipe/kernel-fit-image.bbclass +1 -0
index 7b2bcd4673..d0f7274e70 100644
@@ -260,3 +260,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/classes-recipe/kernel.bbclass +1 -0
index 0a6d754108..14c71dec54 100644
@@ -840,6 +840,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
index d19b33b504..8d8671614a 100644
@@ -99,6 +99,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
meta/recipes-bsp/opensbi/opensbi_1.9.bb +1 -0
index 96167f7c73..bb35f906b2 100644
@@ -49,6 +49,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
meta/recipes-bsp/u-boot/u-boot.inc +1 -0
index b9f61a185c..1c9911ff6e 100644
@@ -474,3 +474,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
meta/recipes-core/systemd/systemd-boot_262.bb +1 -1
index bab2e7ae27..c9bc3e2a91 100644
@@ -71,4 +71,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
Signature · 11 lines
2.56.0



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#248698): https://lists.openembedded.org/g/openembedded-core/message/248698
Mute This Topic: https://lists.openembedded.org/mt/121950655/7159507
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#59 lore raw

Re: [OE-core][PATCH v5 5/6] Add SPDX deploy tasks to various recipes

Quoted 7 lines · Mikko Rapeli via lists.openembedded.org
Quoted 2 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

I think this should be the default in deploy.bbclass.

I also think that would be preferable, rather than having to spread the SPDX_DEPLOY_TASKS all over the place.
Everything that will use SPDX_DEPLOY_TASKS must already be using the deploy.bbclass.

Jose

Quoted 146 lines

The class is used to deploy files to "build output". A lot of BSP etc recipes use the class for this purpose and they are currently missing in SPDX
output unless some output packages go to image rootfs.

I think capturing too much data in SPDX is less of a problem than not capturing
enough. Thus deploy.bbclass should support SPDX output by default, when SPDX
is enabled.

If there are other very good reasons for not enabling this by default, then I think the commit message should say that.

Cheers,

-Mikko

Quoted 12 lines
---
 meta/classes-recipe/barebox.bbclass           | 1 +
 meta/classes-recipe/devicetree.bbclass        | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass  | 1 +
 meta/classes-recipe/kernel.bbclass            | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.9.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc            | 1 +
 meta/recipes-core/systemd/systemd-boot_262.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)

Review

Quoted 1 line
(quoted diff) +0 -0

b/meta/classes-recipe/barebox.bbclass

Review

Quoted 11 lines

index 3980849b53..252e97fa65 100644

meta/classes-recipe/barebox.bbclass +1 -0
@@ -165,5 +165,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
(quoted diff) +0 -0

b/meta/classes-recipe/devicetree.bbclass

Review

Quoted 12 lines

index 4fe389bed8..affbf115c2 100644

meta/classes-recipe/devicetree.bbclass +1 -0
@@ -166,6 +166,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
(quoted diff) +0 -0

b/meta/classes-recipe/kernel-fit-image.bbclass

Review

Quoted 9 lines

index 7b2bcd4673..d0f7274e70 100644

meta/classes-recipe/kernel-fit-image.bbclass +1 -0
@@ -260,3 +260,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
(quoted diff) +0 -0

b/meta/classes-recipe/kernel.bbclass

Review

Quoted 12 lines

index 0a6d754108..14c71dec54 100644

meta/classes-recipe/kernel.bbclass +1 -0
@@ -840,6 +840,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
(quoted diff) +0 -0

b/meta/recipes-bsp/grub/grub-efi_2.14.bb

Review

Quoted 12 lines

index d19b33b504..8d8671614a 100644

meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
@@ -99,6 +99,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
(quoted diff) +0 -0

b/meta/recipes-bsp/opensbi/opensbi_1.9.bb

meta/recipes-bsp/opensbi/opensbi_1.9.bb do_deploy () { · line 55

Quoted 11 lines

index 96167f7c73..bb35f906b2 100644

meta/recipes-bsp/opensbi/opensbi_1.9.bb +1 -0
@@ -49,6 +49,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} +=

"/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"

Review

Quoted 1 line
(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc

Review

Quoted 9 lines

index b9f61a185c..1c9911ff6e 100644

meta/recipes-bsp/u-boot/u-boot.inc +1 -0
@@ -474,3 +474,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
(quoted diff) +0 -0

b/meta/recipes-core/systemd/systemd-boot_262.bb

Quoted 10 lines

index bab2e7ae27..c9bc3e2a91 100644

meta/recipes-core/systemd/systemd-boot_262.bb +1 -2
@@ -71,4 +71,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
--
Quoted 6 lines

2.56.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#248711):
https://lists.openembedded.org/g/openembedded-core/message/248711
Mute This Topic: https://lists.openembedded.org/mt/121950655/10043485
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#60 lore raw

Re: [OE-core][PATCH v5 5/6] Add SPDX deploy tasks to various recipes

Quoted 10 lines · Jose Quaresma
Quoted 5 lines · Mikko Rapeli via lists.openembedded.org
Quoted 2 lines · Joshua Watt via lists.openembedded.org

Adds SPDX deploy tasks to many recipes to record their output when consumed in an SBoM

Quoted 8 lines
Quoted 2 lines

I think this should be the default in deploy.bbclass.

I also think that would be preferable, rather than having to spread the SPDX_DEPLOY_TASKS all over the place.
Everything that will use SPDX_DEPLOY_TASKS must already be using the deploy.bbclass.

I'm fine with that. I will make that change

Quoted 151 lines

Jose

Quoted 147 lines

The class is used to deploy files to "build output". A lot of BSP etc recipes use the class for this purpose and they are currently missing in SPDX
output unless some output packages go to image rootfs.

I think capturing too much data in SPDX is less of a problem than not capturing
enough. Thus deploy.bbclass should support SPDX output by default, when SPDX
is enabled.

If there are other very good reasons for not enabling this by default, then
I think the commit message should say that.

Cheers,

-Mikko

Quoted 12 lines
---
 meta/classes-recipe/barebox.bbclass           | 1 +
 meta/classes-recipe/devicetree.bbclass        | 1 +
 meta/classes-recipe/kernel-fit-image.bbclass  | 1 +
 meta/classes-recipe/kernel.bbclass            | 1 +
 meta/recipes-bsp/grub/grub-efi_2.14.bb        | 1 +
 meta/recipes-bsp/opensbi/opensbi_1.9.bb       | 1 +
 meta/recipes-bsp/u-boot/u-boot.inc            | 1 +
 meta/recipes-core/systemd/systemd-boot_262.bb | 2 +-
 8 files changed, 8 insertions(+), 1 deletion(-)

Review

Quoted 1 line
(quoted diff) +0 -0

b/meta/classes-recipe/barebox.bbclass

Review

Quoted 11 lines

index 3980849b53..252e97fa65 100644

meta/classes-recipe/barebox.bbclass +1 -0
@@ -165,5 +165,6 @@ barebox_do_deploy () {
         fi
 }
 addtask deploy after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_deploy
(quoted diff) +0 -0

b/meta/classes-recipe/devicetree.bbclass

Review

Quoted 12 lines

index 4fe389bed8..affbf115c2 100644

meta/classes-recipe/devicetree.bbclass +1 -0
@@ -166,6 +166,7 @@ devicetree_do_deploy() {
     done
 }
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_compile do_install do_deploy
 
(quoted diff) +0 -0

b/meta/classes-recipe/kernel-fit-image.bbclass

Review

Quoted 9 lines

index 7b2bcd4673..d0f7274e70 100644

meta/classes-recipe/kernel-fit-image.bbclass +1 -0
@@ -260,3 +260,4 @@ do_deploy() {
     fi
 }
 addtask deploy after do_compile before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
(quoted diff) +0 -0

b/meta/classes-recipe/kernel.bbclass

Review

Quoted 12 lines

index 0a6d754108..14c71dec54 100644

meta/classes-recipe/kernel.bbclass +1 -0
@@ -840,6 +840,7 @@ kernel_do_deploy() {
 do_deploy[prefuncs] += "read_subpackage_metadata"
 
 addtask deploy after do_install do_populate_sysroot do_packagedata
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 EXPORT_FUNCTIONS do_deploy
 
(quoted diff) +0 -0

b/meta/recipes-bsp/grub/grub-efi_2.14.bb

Review

Quoted 12 lines

index d19b33b504..8d8671614a 100644

meta/recipes-bsp/grub/grub-efi_2.14.bb +1 -0
@@ -99,6 +99,7 @@ do_deploy() {
 }
 
 addtask deploy after do_install before do_build
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
                ${datadir}/grub \
(quoted diff) +0 -0

b/meta/recipes-bsp/opensbi/opensbi_1.9.bb

meta/recipes-bsp/opensbi/opensbi_1.9.bb do_deploy () { · line 55

Quoted 11 lines

index 96167f7c73..bb35f906b2 100644

meta/recipes-bsp/opensbi/opensbi_1.9.bb +1 -0
@@ -49,6 +49,7 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_install
+SPDX_DEPLOY_TASKS += "do_deploy"
 
 FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 FILES:${PN} +=

"/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"

Review

Quoted 1 line
(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc

Review

Quoted 9 lines

index b9f61a185c..1c9911ff6e 100644

meta/recipes-bsp/u-boot/u-boot.inc +1 -0
@@ -474,3 +474,4 @@ uboot_deploy_spl () {
 }
 
 addtask deploy before do_build after do_compile
+SPDX_DEPLOY_TASKS += "do_deploy"
(quoted diff) +0 -0

b/meta/recipes-core/systemd/systemd-boot_262.bb

Quoted 10 lines

index bab2e7ae27..c9bc3e2a91 100644

meta/recipes-core/systemd/systemd-boot_262.bb +1 -2
@@ -71,4 +71,4 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
-
+SPDX_DEPLOY_TASKS += "do_deploy"
--
Quoted 6 lines

2.56.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#248711):
https://lists.openembedded.org/g/openembedded-core/message/248711
Mute This Topic: https://lists.openembedded.org/mt/121950655/10043485
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#61 lore raw

PATCH v5 6/6 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 23 ++++++++-----
 5 files changed, 27 insertions(+), 33 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index b60cdd826f..64cb065632 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom-spdx = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index 723194da2d..fafcdd0a13 100644
@@ -10,6 +10,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index 6077105094..f79ecac153 100644
@@ -375,9 +375,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +15 -8
index c1c0733508..567613cebc 100644
@@ -1544,19 +1544,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
-    image_deploy_dir = Path(d.getVar("DEPLOY_DIR_IMAGE"))
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
+    image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1649,13 +1649,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1677,7 +1682,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.56.0
#62 lore raw
In reply to Joshua Watt
Quoted 17 lines · Joshua Watt via lists.openembedded.org

he SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Quoted 5 lines

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Hi Joshua,

Thanks for the new version.

I believe this is the source of this warning:

WARNING: core-image-full-cmdline-1.0-r0 do_create_image_sbom_spdx: The following SPDX IDs were unable to be resolved:
http://spdxdocs.org/openembedded-alias/by-doc-hash/6e0461f8d0ebcd6cab741ff4175cb1256279c1657d809f71c257fb2a0991e7ca/eudev/UNIHASH/package/eudev

https://autobuilder.yoctoproject.org/valkyrie/#/builders/22/builds/4908

Can you have a look at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#63 lore raw

v6 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

V6: Fixed a bug where eudev/systemd initramfs-framework was not being properly detected and the wrong link was in the SPDX due to the switch between the two not being detected.

Also, deploy.bbclass now always adds do_deploy to SPDX_DEPLOY_TASKS, so any recipe inheriting that class gets it automatically.

Joshua Watt (7):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS
spdx: Replace do_create_image_spdx with deploy task layer.conf: Fix initramfs-framework not knowing which udev it has

 meta/classes-global/sstate.bbclass            |  38 ++-
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   2 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 178 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/conf/layer.conf                          |   2 -
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 316 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 11 files changed, 529 insertions(+), 102 deletions(-)
Signature · 1 line
2.56.0
#64 lore raw

PATCH v6 1/7 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 1d11d8d1d2..3dd87c2a75 100644
@@ -306,13 +306,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.56.0
#65 lore raw

PATCH v6 2/7 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 181 +++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 282 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 453 insertions(+), 65 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index cf79ef5b01..b60cdd826f 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 6ccb93ba01..723194da2d 100644
@@ -12,3 +12,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +181 -0

190 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +237 -45

344 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 07bf9650e2..9a862d9f5a 100644
@@ -118,7 +118,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.56.0
#66 lore raw

PATCH v6 3/7 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index c900558b44..8cc51c1369 100644
@@ -485,3 +485,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
 
         for candidate in objset.foreach_type(oe.spdx30.software_Package):
             self.assertIsNone(candidate.releaseTime)
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.56.0
#67 lore raw

PATCH v6 4/7 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index b2fa93650a..c6d9459182 100644
@@ -1125,11 +1125,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1142,6 +1159,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1198,12 +1217,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.56.0
#68 lore raw

PATCH v6 5/7 classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS

In reply to Joshua Watt

Any recipe that inherits this class will automatically generate deploy SPDX data for the do_deploy task

---
 meta/classes-recipe/deploy.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes-recipe/deploy.bbclass +1 -0
index f222a8560f..a3b48d6f7a 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_TASKS += "do_deploy"
 SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Signature · 1 line
2.56.0
#69 lore raw

PATCH v6 6/7 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 23 ++++++++-----
 5 files changed, 27 insertions(+), 33 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index b60cdd826f..64cb065632 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom-spdx = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index 723194da2d..fafcdd0a13 100644
@@ -10,6 +10,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index 6077105094..f79ecac153 100644
@@ -375,9 +375,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +15 -8
index c1c0733508..567613cebc 100644
@@ -1544,19 +1544,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
-    image_deploy_dir = Path(d.getVar("DEPLOY_DIR_IMAGE"))
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
+    image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1649,13 +1649,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1677,7 +1682,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.56.0
#70 lore raw

PATCH v6 7/7 layer.conf: Fix initramfs-framework not knowing which udev it has

In reply to Joshua Watt

The SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS from initramfs-framework to eudev and systemd meant that it would not correctly update when switching udev providers (for example, when switching from the "poky" distro to "poky-altcfg" distro). Fix this by removing both entries.

---
 meta/conf/layer.conf | 2 --
 1 file changed, 2 deletions(-)
meta/conf/layer.conf +0 -2
index 13c920be6c..b55d50c60c 100644
@@ -59,8 +59,6 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   docbook-xsl-stylesheets->perl \
   ca-certificates->openssl \
   initramfs-framework->${VIRTUAL-RUNTIME_base-utils} \
-  initramfs-framework->eudev \
-  initramfs-framework->systemd \
   initramfs-module-install-efi->dosfstools \
   initramfs-module-install-efi->e2fsprogs \
   initramfs-module-install-efi->parted \
Signature · 1 line
2.56.0
#71 lore raw
In reply to Joshua Watt
Quoted 17 lines · Joshua Watt via lists.openembedded.org

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Quoted 5 lines

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Hi Joshua,

It looks like the last fix broke something:

ERROR: ovmf-native-edk2-stable202605-r0 do_deploy: No deployed artifacts found in /srv/pokybuild/yocto-worker/qemux86-world-alt/build/build/tmp/work/x86_64-linux/ovmf-native/edk2-stable202605/deploy-ovmf-native

https://autobuilder.yoctoproject.org/valkyrie/#/builders/17/builds/4759
https://autobuilder.yoctoproject.org/valkyrie/#/builders/25/builds/4914
https://autobuilder.yoctoproject.org/valkyrie/#/builders/59/builds/4934
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/5144

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#72 lore raw

v7 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

V6: Fixed a bug where eudev/systemd initramfs-framework was not being properly detected and the wrong link was in the SPDX due to the switch between the two not being detected.

Also, deploy.bbclass now always adds do_deploy to SPDX_DEPLOY_TASKS, so any recipe inheriting that class gets it automatically.

V7: Add SPDX_DEPLOY_ALLOW_EMPTY variable, and set it on ovmf to fix it erroring out for native builds.

Joshua Watt (8):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS
spdx: Replace do_create_image_spdx with deploy task layer.conf: Fix initramfs-framework not knowing which udev it has
ovmf: Allow empty SPDX deploy artifacts

 meta/classes-global/sstate.bbclass            |  38 ++-
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   2 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 185 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/conf/layer.conf                          |   2 -
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 323 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 meta/recipes-core/ovmf/ovmf_git.bb            |   1 +
 12 files changed, 543 insertions(+), 103 deletions(-)
Signature · 1 line
2.56.0
#73 lore raw

PATCH v7 1/8 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 1d11d8d1d2..3dd87c2a75 100644
@@ -306,13 +306,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.56.0
#74 lore raw

PATCH v7 2/8 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 188 ++++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 289 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 466 insertions(+), 66 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index cf79ef5b01..b60cdd826f 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 6ccb93ba01..723194da2d 100644
@@ -12,3 +12,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +188 -0

197 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +243 -46

357 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 07bf9650e2..9a862d9f5a 100644
@@ -118,7 +118,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.56.0
#75 lore raw

PATCH v7 3/8 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index c900558b44..8cc51c1369 100644
@@ -485,3 +485,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
 
         for candidate in objset.foreach_type(oe.spdx30.software_Package):
             self.assertIsNone(candidate.releaseTime)
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.56.0
#76 lore raw

PATCH v7 4/8 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index b2fa93650a..c6d9459182 100644
@@ -1125,11 +1125,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1142,6 +1159,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1198,12 +1217,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.56.0
#77 lore raw

PATCH v7 5/8 classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS

In reply to Joshua Watt

Any recipe that inherits this class will automatically generate deploy SPDX data for the do_deploy task

---
 meta/classes-recipe/deploy.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes-recipe/deploy.bbclass +1 -0
index f222a8560f..a3b48d6f7a 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_TASKS += "do_deploy"
 SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Signature · 1 line
2.56.0
#78 lore raw

PATCH v7 6/8 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 23 ++++++++-----
 5 files changed, 27 insertions(+), 33 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index b60cdd826f..64cb065632 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom-spdx = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index 723194da2d..fafcdd0a13 100644
@@ -10,6 +10,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index fb6a4f249e..0d0bddcc67 100644
@@ -381,9 +381,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +15 -8
index ce28ab4500..6010fe7230 100644
@@ -1546,19 +1546,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
-    image_deploy_dir = Path(d.getVar("DEPLOY_DIR_IMAGE"))
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
+    image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1651,13 +1651,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1679,7 +1684,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.56.0
#79 lore raw

PATCH v7 7/8 layer.conf: Fix initramfs-framework not knowing which udev it has

In reply to Joshua Watt

The SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS from initramfs-framework to eudev and systemd meant that it would not correctly update when switching udev providers (for example, when switching from the "poky" distro to "poky-altcfg" distro). Fix this by removing both entries.

---
 meta/conf/layer.conf | 2 --
 1 file changed, 2 deletions(-)
meta/conf/layer.conf +0 -2
index 13c920be6c..b55d50c60c 100644
@@ -59,8 +59,6 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   docbook-xsl-stylesheets->perl \
   ca-certificates->openssl \
   initramfs-framework->${VIRTUAL-RUNTIME_base-utils} \
-  initramfs-framework->eudev \
-  initramfs-framework->systemd \
   initramfs-module-install-efi->dosfstools \
   initramfs-module-install-efi->e2fsprogs \
   initramfs-module-install-efi->parted \
Signature · 1 line
2.56.0
#80 lore raw

Re: [OE-core][PATCH v7 7/8] layer.conf: Fix initramfs-framework not knowing which udev it has

Quoted 7 lines · Joshua Watt via lists.openembedded.org

The SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS from initramfs-framework to eudev and systemd meant that it would not correctly update when switching udev providers (for example, when switching from the "poky" distro to "poky-altcfg" distro). Fix this by removing both entries.

---

Hi Joshua,

It looks like we have two failing ptests:

2026-10-29 13:59:49,255 - oe-selftest - INFO - containerimage.ContainerImageTests.test_expected_files (subunit.RemotedTestCase)
2026-10-29 13:59:49,258 - oe-selftest - INFO -  ... FAIL
...
2026-10-29 16:43:44,508 - oe-selftest - INFO - FAIL: containerimage.ContainerImageTests.test_expected_files (subunit.RemotedTestCase)
2026-10-29 16:43:44,508 - oe-selftest - INFO - ----------------------------------------------------------------------
2026-10-29 16:43:44,511 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/containerimage.py", line 79, in test_expected_files
    bitbake('container-test-image')
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/utils/commands.py", line 247, in bitbake
    return runCmd(cmd, ignore_status, timeout, output_log=output_log, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/utils/commands.py", line 214, in runCmd
    raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))

AssertionError: Command 'bitbake container-test-image' returned non-zero exit status 1:
...
ERROR: linux-dummy-1.0-r0 do_deploy: No deployed artifacts found in /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-2057211/tmp/work/x86-64-v3-poky-linux/linux-dummy/1.0/deploy-linux-dummy

2026-10-29 16:06:26,004 - oe-selftest - INFO - sstatetests.SStateHashSameSigs2.test_sstate_allarch_samesigs (subunit.RemotedTestCase)
2026-10-29 16:06:26,009 - oe-selftest - INFO -  ... FAIL

...
AssertionError: {'nat[236063 chars]/do_package_write_rpm': '1c255309c294370cd4b42[66420 chars]25f'} != {'nat[236063 chars]/do_prepare_recipe_sysroot': 'ec112619862bfba2[66420 chars]25f'}
{'adwaita-icon-theme/do_compile': 'a25b554f7e8661288308f43852443b92aab5f2645308eb21ab8bcce1c016f7b7',
'adwaita-icon-theme/do_configure': '75e61587201815e441c95207df638178c3c25a68b31df2f59ea53262001118b6',
'adwaita-icon-theme/do_create_package_spdx': 'f835ed6c0081ae4a047aa7e79cc8a9e6e655ec760e615afc1960f3aec4779703', 'adwaita-icon-theme/do_create_recipe_spdx': '4dbac02267e196c377e849a6b6c12e8474f35e7d53ea5fe02a9dff6f3da5a78c',
'adwaita-icon-theme/do_create_spdx': '5a1f1516ddb2b6fdbd73bf4a07a60e0c5e89d29e27a4f2be776071d15f34efd7',

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/5152
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/5184
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4968

Can you have a look at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#81 lore raw

PATCH v7 8/8 ovmf: Allow empty SPDX deploy artifacts

In reply to Joshua Watt

In native builds, ovfm do_deploy doesn't produce any artifacts. Set the SPDX_DEPLOY_ALLOW_EMPTY flag to prevent SPDX from erroring when this occurs.

---
 meta/recipes-core/ovmf/ovmf_git.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-core/ovmf/ovmf_git.bb +1 -0
index bf69108f0a..7cc844dfa6 100644
@@ -249,5 +249,6 @@ do_deploy:class-target() {
     fi
 }
 addtask do_deploy after do_compile before do_build
+SPDX_DEPLOY_ALLOW_EMPTY:task-deploy = "1"
 
 BBCLASSEXTEND = "native"
Signature · 1 line
2.56.0
#82 lore raw

v8 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

V6: Fixed a bug where eudev/systemd initramfs-framework was not being properly detected and the wrong link was in the SPDX due to the switch between the two not being detected.

Also, deploy.bbclass now always adds do_deploy to SPDX_DEPLOY_TASKS, so any recipe inheriting that class gets it automatically.

V7: Add SPDX_DEPLOY_ALLOW_EMPTY variable, and set it on ovmf to fix it erroring out for native builds.

V8: Fix deploy error for linux-dummy, and allarch signature error for initramfs-framework

Joshua Watt (9):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS
spdx: Replace do_create_image_spdx with deploy task layer.conf: Fix initramfs-framework not knowing which udev it has
ovmf: Allow empty SPDX deploy artifacts
linux-dummy: Allow empty SPDX deploy artifacts

 meta/classes-global/sstate.bbclass            |  38 ++-
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   2 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 185 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/conf/layer.conf                          |   2 -
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 323 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 .../initrdscripts/initramfs-framework_1.0.bb  |   2 -
 meta/recipes-core/ovmf/ovmf_git.bb            |   1 +
 meta/recipes-kernel/linux/linux-dummy.bb      |   2 +
 14 files changed, 545 insertions(+), 105 deletions(-)
Signature · 1 line
2.56.0
#83 lore raw

PATCH v8 1/9 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 646ec7d074..3c3ba15e74 100644
@@ -306,13 +306,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.56.0
#84 lore raw

PATCH v8 2/9 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 188 ++++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 289 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 466 insertions(+), 66 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index cf79ef5b01..b60cdd826f 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 6ccb93ba01..723194da2d 100644
@@ -12,3 +12,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +188 -0

197 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +243 -46

357 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 07bf9650e2..9a862d9f5a 100644
@@ -118,7 +118,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.56.0
#85 lore raw

PATCH v8 3/9 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index c900558b44..8cc51c1369 100644
@@ -485,3 +485,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
 
         for candidate in objset.foreach_type(oe.spdx30.software_Package):
             self.assertIsNone(candidate.releaseTime)
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.56.0
#86 lore raw

PATCH v8 4/9 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index b2fa93650a..c6d9459182 100644
@@ -1125,11 +1125,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1142,6 +1159,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1198,12 +1217,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.56.0
#87 lore raw

PATCH v8 5/9 classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS

In reply to Joshua Watt

Any recipe that inherits this class will automatically generate deploy SPDX data for the do_deploy task

---
 meta/classes-recipe/deploy.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes-recipe/deploy.bbclass +1 -0
index f222a8560f..a3b48d6f7a 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_TASKS += "do_deploy"
 SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Signature · 1 line
2.56.0
#88 lore raw

PATCH v8 6/9 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 23 ++++++++-----
 5 files changed, 27 insertions(+), 33 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index b60cdd826f..64cb065632 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom-spdx = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index 723194da2d..fafcdd0a13 100644
@@ -10,6 +10,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index fb6a4f249e..0d0bddcc67 100644
@@ -381,9 +381,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +15 -8
index 43e196806f..069c759523 100644
@@ -1546,19 +1546,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
-    image_deploy_dir = Path(d.getVar("DEPLOY_DIR_IMAGE"))
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
+    image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1651,13 +1651,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1679,7 +1684,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.56.0
#89 lore raw

PATCH v8 7/9 layer.conf: Fix initramfs-framework not knowing which udev it has

In reply to Joshua Watt

The SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS from initramfs-framework to eudev and systemd meant that it would not correctly update when switching udev providers (for example, when switching from the "poky" distro to "poky-altcfg" distro). Fix this by removing both entries.

This also requires that the recipe no longer be allarch since it will change based on distro.

---
 meta/conf/layer.conf                                       | 2 --
 meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb | 2 --
 2 files changed, 4 deletions(-)
meta/conf/layer.conf +0 -2
index 13c920be6c..b55d50c60c 100644
@@ -59,8 +59,6 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   docbook-xsl-stylesheets->perl \
   ca-certificates->openssl \
   initramfs-framework->${VIRTUAL-RUNTIME_base-utils} \
-  initramfs-framework->eudev \
-  initramfs-framework->systemd \
   initramfs-module-install-efi->dosfstools \
   initramfs-module-install-efi->e2fsprogs \
   initramfs-module-install-efi->parted \
meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb +0 -2
index 2ec03bc34c..2c5ff10813 100644
@@ -4,8 +4,6 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384
 RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_base-utils}"
 RRECOMMENDS:${PN} = "${VIRTUAL-RUNTIME_base-utils-syslog}"
 
-inherit allarch
-
 SRC_URI = "file://init \
            file://exec \
            file://nfsrootfs \
Signature · 1 line
2.56.0
#90 lore raw

PATCH v8 8/9 ovmf: Allow empty SPDX deploy artifacts

In reply to Joshua Watt

In native builds, ovfm do_deploy doesn't produce any artifacts. Set the SPDX_DEPLOY_ALLOW_EMPTY flag to prevent SPDX from erroring when this occurs.

---
 meta/recipes-core/ovmf/ovmf_git.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-core/ovmf/ovmf_git.bb +1 -0
index bf69108f0a..7cc844dfa6 100644
@@ -249,5 +249,6 @@ do_deploy:class-target() {
     fi
 }
 addtask do_deploy after do_compile before do_build
+SPDX_DEPLOY_ALLOW_EMPTY:task-deploy = "1"
 
 BBCLASSEXTEND = "native"
Signature · 1 line
2.56.0
#91 lore raw

PATCH v8 9/9 linux-dummy: Allow empty SPDX deploy artifacts

In reply to Joshua Watt

The recipe doesn't deploy anything so set SPDX_DEPLOY_ALLOW_EMPTY so that it doesn't generate an error

---
 meta/recipes-kernel/linux/linux-dummy.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-kernel/linux/linux-dummy.bb +2 -0
index d7f39a452d..c45352aab2 100644
@@ -23,6 +23,8 @@ FILES:kernel-vmlinux = ""
 ALLOW_EMPTY:kernel-vmlinux = "1"
 DESCRIPTION:kernel-vmlinux = "Kernel vmlinux meta package"
 
+SPDX_DEPLOY_ALLOW_EMPTY:task-deploy = "1"
+
 INHIBIT_DEFAULT_DEPS = "1"
 
 COMPATIBLE_HOST = ".*-linux"
Signature · 1 line
2.56.0
#92 lore raw
In reply to Joshua Watt
Quoted 17 lines · Joshua Watt via openembedded-core

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Quoted 5 lines

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

Hi Joshua,

Sorry, it looks like one of the selftests is still failing:

2026-11-04 20:54:56,255 - oe-selftest - INFO - sstatetests.SStateHashSameSigs2.test_sstate_allarch_samesigs (subunit.RemotedTestCase)
2026-11-04 20:54:56,256 - oe-selftest - INFO -  ... FAIL
...
2026-11-04 20:54:56,257 - oe-selftest - INFO - 14: 40/74 566/796 (126.20s) (0 failed) (sstatetests.SStateHashSameSigs2.test_sstate_allarch_samesigs)
2026-11-04 20:54:56,257 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/sstatetests.py", line 474, in test_sstate_allarch_samesigs
    self.sstate_common_samesigs(configA, configB, allarch=True)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/sstatetests.py", line 207, in sstate_common_samesigs
    self.assertEqual(files1, files2)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/unittest/case.py", line 907, in assertEqual
    assertion_func(first, second, msg=msg)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/unittest/case.py", line 1206, in assertDictEqual
    self.fail(self._formatMessage(msg, standardMsg))
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/unittest/case.py", line 732, in fail
    raise self.failureException(msg)

AssertionError: {'nat[270260 chars]do_package_qa': '857626b7bdd74c4b2507f085ec1d3[30298 chars]ccf'} != {'nat[270260 chars]do_patch': '58d5b3102c4ba7a2388712a2a7f962d88e[30298 chars]ccf'}
{'adwaita-icon-theme/do_compile': '5390f85c42205bb5a14f7d92537a8420867861c0ef9adc409863aa1a1cd61709',
'adwaita-icon-theme/do_configure': 'a280235b7d74824b3743f9490b3549add607d66c38976212ef67a5598819592e',
'adwaita-icon-theme/do_create_package_spdx': 'e62d8265977d1a7e3ad698899be0f643a79e7a5a7b7b6f10292c8959a58fc267', 'adwaita-icon-theme/do_create_recipe_spdx': 'efe776c196e9c591367785ce9a32d02228af827c2995ce26df1885b88065da9d',
'adwaita-icon-theme/do_create_spdx': 'bde607fa1590084bb0b587b76f48bec54b0ecff13a4a437385558eeb7a5595dd', 'adwaita-icon-theme/do_deploy_source_date_epoch': '8de41ddc1f7abb948c161ec6591dbe887186eafe18890b24a13568793ab8e897',
'adwaita-icon-theme/do_fetch': '21febaeb8a75763a5eed0a68a22d15a4cb491f25c5d59a086c5d3a48c6ac7176',
'adwaita-icon-theme/do_install': '7d74cc9d42787eb59d2185a92d974e5a61d7cb8e60a23319fdb947cb42389739',
'adwaita-icon-theme/do_package': '435d8e3412602a492d7b016d3b8615f78fc4de88113bd8180ed8e2c420a55ca2',
'adwaita-icon-theme/do_package_qa': '497742679e6ab012cb1050d1f6358737f312fe0520b3ab55a8329924af0b42a8',
'adwaita-icon-theme/do_package_write_rpm': '7d5c34df18018681012fc3544d90fa227d311c18c0093459cf9082c9cddb9e6c',
'adwaita-icon-theme/do_packagedata': 'eb4f146bb2fed70fb92c69bf02d1e4478429b02ea6a9354442cb1af3a34edd2b',
'adwaita-icon-theme/do_patch': 'ee2331e00fd0a461aece4ec16f69cecb8463aac4b5a01e07858a515b85c39c53',
'adwaita-icon-theme/do_populate_lic': 'e41b536e4515805e401b974e48c25168b7e95d523f38806bf101aa4b923d3dfc',
'adwaita-icon-theme/do_populate_sysroot': 'b5ff360309b0769e840d56103b8036fa882da881d7bfcd0fc89d93a0e460b5d8', 'adwaita-icon-theme/do_prepare_recipe_sysroot': 'd82174494f146d0936439e3c5bb1a3d85759fe369008ad968017194f4b03733e',
'adwaita-icon-theme/do_recipe_qa': 'b63675adc7d32dfccfe8a0a8b3be5a5aa892fcfb7a09288714502274ca318d0f',
'adwaita-icon-theme/do_unpack': '04087c36f3690f91199bbe4e6a61a01bbf32550f289cdccdbc382227566aa54e',
'adwaita-icon-theme/do_write_config': '3a0d46da99ab5c777732a0143eaedf2319bc385163d544a538ab918bc10ef664',
'alsa-topology-conf/do_compile': '310c99f93ad20956d61fff0b5a8a18d8b84a175c415110986f4a439023dba11b',
...

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/5193
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/5006
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/5221

Can you have a look at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#93 lore raw

v9 cover Implement SPDX for deploy tasks

In reply to Joshua Watt

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

V6: Fixed a bug where eudev/systemd initramfs-framework was not being properly detected and the wrong link was in the SPDX due to the switch between the two not being detected.

Also, deploy.bbclass now always adds do_deploy to SPDX_DEPLOY_TASKS, so any recipe inheriting that class gets it automatically.

V7: Add SPDX_DEPLOY_ALLOW_EMPTY variable, and set it on ovmf to fix it erroring out for native builds.

V8: Fix deploy error for linux-dummy, and allarch signature error for initramfs-framework

V9: Fix initramfs-module-setup-live allarch signature error now that initramfs-framwork is no longer allarch.

Joshua Watt (9):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS
spdx: Replace do_create_image_spdx with deploy task layer.conf: Fix initramfs-framework not knowing which udev it has
ovmf: Allow empty SPDX deploy artifacts
linux-dummy: Allow empty SPDX deploy artifacts

 meta/classes-global/sstate.bbclass            |  38 ++-
 .../create-spdx-image-3.0.bbclass             |  32 +-
 meta/classes-recipe/deploy.bbclass            |   2 +
 meta/classes-recipe/nospdx.bbclass            |   2 +-
 meta/classes/create-spdx-3.0.bbclass          | 185 ++++++++++
 meta/classes/spdx-common.bbclass              |   2 +-
 meta/conf/layer.conf                          |   3 +-
 meta/lib/oe/sbom30.py                         |  46 ++-
 meta/lib/oe/spdx30_tasks.py                   | 323 ++++++++++++++----
 meta/lib/oe/spdx_common.py                    |   2 +-
 meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
 .../initrdscripts/initramfs-framework_1.0.bb  |   2 -
 meta/recipes-core/ovmf/ovmf_git.bb            |   1 +
 meta/recipes-kernel/linux/linux-dummy.bb      |   2 +
 14 files changed, 546 insertions(+), 105 deletions(-)
Signature · 1 line
2.56.0
#94 lore raw

PATCH v9 1/9 spdx: Skip dependencies that are not in the taskhash

If a dependency is not in the taskhash, it cannot be included in the SPDX data because the dependency may not trigger the recipe to rebuild if it changes (although aliases help with this), but more importantly bitbake may not restore the sstate object associated with the dependency which causes errors when constructing the final SBoM

---
 meta/lib/oe/spdx30_tasks.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oe/spdx30_tasks.py +7 -6
index 646ec7d074..3c3ba15e74 100644
@@ -306,13 +306,14 @@ def collect_dep_objsets(d, direct_deps, subdir, fn_prefix, obj_type, **attr_filt
         dep_obj, dep_objset = oe.sbom30.find_root_obj_in_jsonld(
             d, subdir, fn_prefix + dep.pn, obj_type, **attr_filter
         )
-        # If the dependency is part of the taskhash, return it to be linked
-        # against. Otherwise, it cannot be linked against because this recipe
-        # will not rebuilt if dependency changes
-        if dep.in_taskhash:
-            dep_objsets.append(dep_objset)
+        # If the dependency is not part of the task hash, do not include it
+        # since the dependency may not be present in subsequent runs, and may
+        # not rebuild if it changes
+        if not dep.in_taskhash:
+            bb.debug(1, f"Skipping dependency {dep.pn} (not in taskhash)")
+            continue
 
-        # The object _can_ be linked against (by alias)
+        dep_objsets.append(dep_objset)
         dep_objs.add(dep_obj)
 
     return dep_objsets, dep_objs
Signature · 1 line
2.56.0
#95 lore raw

PATCH v9 2/9 spdx: Add ability for deploy tasks to create SPDX

In reply to Joshua Watt

Adds support for "deploy" tasks (like do_deploy) to write out SPDX documents that describe what has been deployed.

Deploy tasks will automatically detect many dependencies on other recipes; specifically they will correctly detect dependencies on any do_create_spdx task, and also other deploy tasks that generate SPDX output. The only known notable exception are transitive (e.g. originating from other upstream tasks) dependencies on do_image_complete, and do_populate_sysroot. However, these are detected if a direct dependency of the deploy task (via translation of the task dependencies).

This same dependency finding algorithm is now applied to the image generation SBoM; this means that if an image creation task depends on a task that generates a deploy SBoM, it will show up in the dependency graph of the image. A typical example is a wic file that consumes the kernel, u-boot, etc. will now correctly list those as a dependency, as long as their do_deploy step is added to SPDX_DEPLOY_TASKS.

---
 .../create-spdx-image-3.0.bbclass             |   4 +-
 meta/classes-recipe/deploy.bbclass            |   1 +
 meta/classes-recipe/nospdx.bbclass            |   1 +
 meta/classes/create-spdx-3.0.bbclass          | 188 ++++++++++++
 meta/classes/spdx-common.bbclass              |   1 +
 meta/lib/oe/sbom30.py                         |  46 +--
 meta/lib/oe/spdx30_tasks.py                   | 289 +++++++++++++++---
 meta/lib/oe/spdx_common.py                    |   2 +-
 8 files changed, 466 insertions(+), 66 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +2 -2
index cf79ef5b01..b60cdd826f 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -47,7 +47,7 @@ python do_create_image_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_spdx(d)
 }
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx before do_build
+addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
 SSTATETASKS += "do_create_image_spdx"
 SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
 do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
meta/classes-recipe/deploy.bbclass +1 -0
index f56fe98d6d..f222a8560f 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 
meta/classes-recipe/nospdx.bbclass +1 -0
index 6ccb93ba01..723194da2d 100644
@@ -12,3 +12,4 @@ deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
 deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
+deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +188 -0

197 lines not on this page · raw message

meta/classes/spdx-common.bbclass +1 -0
index 40701730a6..bca169670d 100644
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
 SPDXRECIPEDEPLOY = "${SPDXDIR}/recipe-deploy"
 SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
 SPDXRECIPESBOMDEPLOY = "${SPDXDIR}/recipes-bom-deploy"
+SPDXDEPLOYSBOMDEPLOY = "${SPDXDIR}/deploy-bom-deploy"
 
 SPDX_INCLUDE_SOURCES ??= "0"
 SPDX_INCLUDE_SOURCES[doc] = "If set to '1', include source code files in the \
meta/lib/oe/sbom30.py +29 -17

70 lines not on this page · raw message

meta/lib/oe/spdx30_tasks.py +243 -46

357 lines not on this page · raw message

meta/lib/oe/spdx_common.py +1 -1
index 07bf9650e2..9a862d9f5a 100644
@@ -118,7 +118,7 @@ def collect_direct_deps(d, dep_task):
         )
 
     for this_dep in taskdepdata.values():
-        if this_dep[0] == pn and this_dep[1] == current_task:
+        if this_dep.pn == pn and this_dep.taskname == current_task:
             break
     else:
         bb.fatal(f"Unable to find this {pn}:{current_task} in taskdepdata")
Signature · 1 line
2.56.0
#96 lore raw

PATCH v9 3/9 oeqa: Add SPDX deploy SBoM test

In reply to Joshua Watt

Adds a test that verifies that the deploy SBoM is created correctly

---
 meta/lib/oeqa/selftest/cases/spdx.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/spdx.py +11 -0
index c900558b44..8cc51c1369 100644
@@ -485,3 +485,14 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
 
         for candidate in objset.foreach_type(oe.spdx30.software_Package):
             self.assertIsNone(candidate.releaseTime)
+
+    def test_deploy_sbom(self):
+        kernel_recipe = get_bb_var("PREFERRED_PROVIDER_virtual/kernel")
+
+        objset = self.check_recipe_spdx(
+            "virtual/kernel",
+            f"{{DEPLOY_DIR_IMAGE}}/{kernel_recipe}-deploy-sbom.spdx.json",
+        )
+
+        # Document should be fully linked
+        self.check_objset_missing_ids(objset)
Signature · 1 line
2.56.0
#97 lore raw

PATCH v9 4/9 classes-global/sstate: Keep SPDX generating setscene dependencies

In reply to Joshua Watt

Tasks that create SPDX documents can reference SPDX ids from documents created by any task they depend on. When it comes time to create the final SBoM, these referenced SPDX ids must be present so that they can be merged into the SBoM. Specifically, when a task that restores from sstate (a setscene task) is one that can create an SPDX document, and that task is depended on by at least one other task that can create an SPDX document, it must always be restored.

---
 meta/classes-global/sstate.bbclass | 38 ++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
meta/classes-global/sstate.bbclass +36 -2
index b2fa93650a..c6d9459182 100644
@@ -1125,11 +1125,28 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
 
     logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
-    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_create_spdx", "do_create_recipe_spdx", "do_deploy_archives"]
+    directtasks = ["do_populate_lic", "do_deploy_source_date_epoch", "do_shared_workdir", "do_stash_locale", "do_gcc_stash_builddir", "do_deploy_archives"]
+
+    # SPDX tasks are only needed if depended on directly, unless they are
+    # needed by another task that is creating SPDX documents
+    SPDX_TASKS = {"do_create_spdx", "do_create_recipe_spdx", "do_create_package_spdx"}
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
 
+    def isSpdxTask(key):
+        taskname = taskdependees[key][1]
+        # Tasks that start with "do_deploy" might be included in
+        # SPDX_DEPLOY_TASKS and should be kept
+        if taskname.startswith("do_deploy"):
+            return True
+
+        # Tasks that are don't start with do_deploy, but still deploy SPDX data
+        if taskname in {"do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"}:
+            return True
+
+        return taskname in SPDX_TASKS
+
     # We only need to trigger deploy_source_date_epoch through direct dependencies
     if taskdependees[task][1] in directtasks:
         return True
@@ -1142,6 +1159,8 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
                 return False
         return True
 
+    spdx_deps = []
+
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
@@ -1198,12 +1217,27 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # Target populate_sysroot need their dependencies
             return False
 
-        if taskdependees[dep][1] in directtasks:
+        # Collect dependees that create SPDX documents
+        if isSpdxTask(dep):
+            spdx_deps.append(dep)
+            continue
+
+        if taskdependees[dep][1] in directtasks or taskdependees[dep][1] in SPDX_TASKS:
             continue
 
         # Safe fallthrough default
         logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
+
+    # SPDX generating tasks can refer to the SPDXID from the SPDX output of
+    # their dependencies. Therefore if the current task can generate SPDX and
+    # is depended on by another SPDX generating task, it must be kept so that
+    # the IDs can be correctly resolved when merging SPDX output into a
+    # complete SBoM
+    if spdx_deps and isSpdxTask(task):
+        logit(f"Keeping SPDX task {taskdependees[task]} needed by SPDX task(s) {', '.join(str(taskdependees[k]) for k in spdx_deps)}", log)
+        return False
+
     return True
 
 addhandler sstate_eventhandler
Signature · 1 line
2.56.0
#98 lore raw

PATCH v9 5/9 classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS

In reply to Joshua Watt

Any recipe that inherits this class will automatically generate deploy SPDX data for the do_deploy task

---
 meta/classes-recipe/deploy.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes-recipe/deploy.bbclass +1 -0
index f222a8560f..a3b48d6f7a 100644
@@ -6,6 +6,7 @@
 
 DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
 SSTATETASKS += "do_deploy"
+SPDX_DEPLOY_TASKS += "do_deploy"
 SPDX_DEPLOY_ARTIFACTS_DIR:task-deploy = "${DEPLOYDIR}"
 do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
 do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Signature · 1 line
2.56.0
#99 lore raw

Re: [OE-core][PATCH v9 5/9] classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS

Quoted 5 lines · Joshua Watt via openembedded-core

Any recipe that inherits this class will automatically generate deploy SPDX data for the do_deploy task

---

Hi Bruce, Joshua,

I just note this is breaking meta-virt builds:

ERROR: xen-tools-4.21.1+stable-r0 do_deploy: No deployed artifacts found in /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/deploy-xen-tools
...
ERROR: Logfile of failure stored in: /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/temp/log.do_deploy.2548044
NOTE: recipe xen-tools-4.21.1+stable-r0: task do_deploy: Failed

https://autobuilder.yoctoproject.org/valkyrie/#/builders/89/builds/4815

Here is the full content of the said log file:

DEBUG: Executing python function sstate_task_prefunc
DEBUG: Python function sstate_task_prefunc finished
DEBUG: Executing shell function do_deploy
NOTE: make STDVGA_ROM=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/vgabios-0.8a.bin CIRRUSVGA_ROM=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/vgabios-0.8a.cirrus.bin SEABIOS_ROM=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/bios.bin ETHERBOOT_ROMS=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/rtl8139.rom WGET=/bin/false GIT=/bin/false XEN_BUILD_DATE=2026-09-10 XEN_BUILD_TIME=10:36:15 XEN_CONFIG_EXPERT=y debug=n -C /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/sources/xen-tools-4.21.1+stable/xen xenversion --no-print-directory Makefile:57: "You must use e.g. 'make menuconfig' to enable/disable debug now."
DEBUG: Shell function do_deploy finished
DEBUG: Executing python function create_deploy_spdx
ERROR: No deployed artifacts found in /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/deploy-xen-tools
DEBUG: Python function create_deploy_spdx finished

So this will not block merge in oe-core, but will probably need a fix in meta-virt.

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#100 lore raw

Re: [OE-core][PATCH v9 5/9] classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS

I sent a patch to meta-virt

Quoted 55 lines · Mathieu Dubois-Briand
Quoted 5 lines · Joshua Watt via openembedded-core

Any recipe that inherits this class will automatically generate deploy SPDX data for the do_deploy task

---

Hi Bruce, Joshua,

I just note this is breaking meta-virt builds:

ERROR: xen-tools-4.21.1+stable-r0 do_deploy: No deployed artifacts found
in /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/deploy-xen-tools
...
ERROR: Logfile of failure stored in:
/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/temp/log.do_deploy.2548044
NOTE: recipe xen-tools-4.21.1+stable-r0: task do_deploy: Failed

https://autobuilder.yoctoproject.org/valkyrie/#/builders/89/builds/4815

Here is the full content of the said log file:

DEBUG: Executing python function sstate_task_prefunc
DEBUG: Python function sstate_task_prefunc finished
DEBUG: Executing shell function do_deploy
NOTE: make STDVGA_ROM=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/vgabios-0.8a.bin CIRRUSVGA_ROM=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/vgabios-0.8a.cirrus.bin SEABIOS_ROM=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/bios.bin ETHERBOOT_ROMS=/srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/recipe-sysroot/usr/share/firmware/rtl8139.rom WGET=/bin/false GIT=/bin/false XEN_BUILD_DATE=2026-09-10
XEN_BUILD_TIME=10:36:15 XEN_CONFIG_EXPERT=y debug=n -C /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/sources/xen-tools-4.21.1+stable/xen xenversion --no-print-directory
Makefile:57: "You must use e.g. 'make menuconfig' to enable/disable debug
now."
DEBUG: Shell function do_deploy finished
DEBUG: Executing python function create_deploy_spdx
ERROR: No deployed artifacts found in /srv/pokybuild/yocto-worker/meta-virt/build/build/tmp/work/x86-64-v3-poky-linux/xen-tools/4.21.1+stable/deploy-xen-tools
DEBUG: Python function create_deploy_spdx finished

So this will not block merge in oe-core, but will probably need a fix in meta-virt.

Thanks,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#101 lore raw

PATCH v9 6/9 spdx: Replace do_create_image_spdx with deploy task

In reply to Joshua Watt

Replaces the dedicated do_create_image_spdx task with a deploy task tied to do_image_complete (which is task that deploys images).

This has the advantage that images recipe SPDX dependencies are now completely automatically detected in the task graph, and the SPDX documents are merged in automatically when dependencies on do_image_complete are detected

---
 .../create-spdx-image-3.0.bbclass             | 32 +++++++------------
 meta/classes-recipe/nospdx.bbclass            |  1 -
 meta/classes/create-spdx-3.0.bbclass          |  3 --
 meta/classes/spdx-common.bbclass              |  1 -
 meta/lib/oe/spdx30_tasks.py                   | 23 ++++++++-----
 5 files changed, 27 insertions(+), 33 deletions(-)
meta/classes-recipe/create-spdx-image-3.0.bbclass +12 -20
index b60cdd826f..64cb065632 100644
@@ -30,7 +30,7 @@ python do_create_rootfs_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_rootfs_spdx(d)
 }
-addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image
+addtask do_create_rootfs_spdx after do_rootfs do_create_recipe_spdx before do_image do_image_complete
 SSTATETASKS += "do_create_rootfs_spdx"
 do_create_rootfs_spdx[sstate-inputdirs] = "${SPDXROOTFSDEPLOY}"
 do_create_rootfs_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
@@ -43,33 +43,25 @@ python do_create_rootfs_spdx_setscene() {
 }
 addtask do_create_rootfs_spdx_setscene
 
-python do_create_image_spdx() {
+python create_image_spdx() {
     import oe.spdx30_tasks
-    oe.spdx30_tasks.create_image_spdx(d)
-}
-addtask do_create_image_spdx after do_image_complete do_create_rootfs_spdx do_create_recipe_spdx before do_build
-SSTATETASKS += "do_create_image_spdx"
-SSTATE_SKIP_CREATION:task-create-image-spdx = "1"
-do_create_image_spdx[sstate-inputdirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[sstate-outputdirs] = "${DEPLOY_DIR_SPDX}"
-do_create_image_spdx[cleandirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[dirs] = "${SPDXIMAGEWORK}"
-do_create_image_spdx[file-checksums] += "${SPDX3_DEP_FILES}"
-do_create_image_spdx[vardeps] += "\
-    SPDX_IMAGE_PURPOSE \
-    "
+    from pathlib import Path
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
 
-python do_create_image_spdx_setscene() {
-    sstate_setscene(d)
-}
-addtask do_create_image_spdx_setscene
+    spdxdeploydir = Path(d.getVar("SPDXDIR") + "/deploy-" + current_task)
 
+    oe.spdx30_tasks.create_image_spdx(d, spdxdeploydir)
+}
+oe.spdx30_tasks.create_image_spdx[vardeps] += "SPDX_IMAGE_PURPOSE"
+SPDX_DEPLOY_TASKS += "do_image_complete:create_image_spdx"
+# No deploy sbom is needed since do_create_image_sbom_spdx() is used instead
+SPDX_DEPLOY_SBOM = "0"
 
 python do_create_image_sbom_spdx() {
     import oe.spdx30_tasks
     oe.spdx30_tasks.create_image_sbom_spdx(d)
 }
-addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_create_image_spdx before do_build
+addtask do_create_image_sbom_spdx after do_create_rootfs_spdx do_image_complete before do_build
 SSTATETASKS += "do_create_image_sbom_spdx"
 SSTATE_SKIP_CREATION:task-create-image-sbom-spdx = "1"
 do_create_image_sbom_spdx[sstate-inputdirs] = "${SPDXIMAGEDEPLOYDIR}"
meta/classes-recipe/nospdx.bbclass +0 -1
index 723194da2d..fafcdd0a13 100644
@@ -10,6 +10,5 @@ deltask do_create_spdx
 deltask do_create_spdx_runtime
 deltask do_create_package_spdx
 deltask do_create_rootfs_spdx
-deltask do_create_image_spdx
 deltask do_create_image_sbom_spdx
 deltask do_create_deploy_sbom
meta/classes/create-spdx-3.0.bbclass +0 -3
index fb6a4f249e..0d0bddcc67 100644
@@ -381,9 +381,6 @@ python () {
         # for the recipe, at least until it's possible for do_populate_sysroot
         # to describe it's own output.
         "do_populate_sysroot": "do_create_spdx",
-        # If an image is needed, also depend on the task to create the SBoM for
-        # the image
-        "do_image_complete": "do_create_image_spdx",
     }
 
     def map_task_deps(task, flag):
meta/classes/spdx-common.bbclass +0 -1
index bca169670d..13839aac3a 100644
@@ -15,7 +15,6 @@ CVE_VERSION ??= "${PV}"
 SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
 SPDXDEPLOY = "${SPDXDIR}/deploy"
 SPDXWORK = "${SPDXDIR}/work"
-SPDXIMAGEWORK = "${SPDXDIR}/image-work"
 SPDXSDKWORK = "${SPDXDIR}/sdk-work"
 SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
 SPDXDEPS = "${SPDXDIR}/deps.json"
meta/lib/oe/spdx30_tasks.py +15 -8
index 43e196806f..069c759523 100644
@@ -1546,19 +1546,19 @@ def create_rootfs_spdx(d):
     )
 
 
-def create_image_spdx(d):
+def create_image_spdx(d, spdx_deploy_dir):
     import oe.sbom30
 
-    image_deploy_dir = Path(d.getVar("DEPLOY_DIR_IMAGE"))
+    pn = d.getVar("PN")
+    current_task = "do_" + d.getVar("BB_CURRENTTASK")
+
+    image_deploy_dir = Path(d.getVar("IMGDEPLOYDIR"))
     manifest_path = Path(d.getVar("IMAGE_OUTPUT_MANIFEST"))
-    spdx_work_dir = Path(d.getVar("SPDXIMAGEWORK"))
 
     image_basename = d.getVar("IMAGE_BASENAME")
     machine = d.getVar("MACHINE")
 
-    objset = oe.sbom30.ObjectSet.new_objset(
-        d, "%s-%s-image" % (image_basename, machine)
-    )
+    objset = oe.sbom30.ObjectSet.new_objset(d, f"{pn}-{current_task}-deploy")
 
     with manifest_path.open("r") as f:
         manifest = json.load(f)
@@ -1651,13 +1651,18 @@ def create_image_spdx(d):
     objset.add_aliases()
     objset.link()
     oe.sbom30.write_recipe_jsonld_doc(
-        d, objset, "image", spdx_work_dir, create_task_link=True
+        d,
+        objset,
+        "deploy",
+        spdx_deploy_dir,
+        create_task_link=True,
     )
 
 
 def create_image_sbom_spdx(d):
     import oe.sbom30
 
+    pn = d.getVar("PN")
     image_name = d.getVar("IMAGE_NAME")
     image_basename = d.getVar("IMAGE_BASENAME")
     image_link_name = d.getVar("IMAGE_LINK_NAME")
@@ -1679,7 +1684,9 @@ def create_image_sbom_spdx(d):
     root_elements.append(oe.sbom30.get_element_link_id(rootfs_image))
 
     image_objset, _ = oe.sbom30.find_jsonld(
-        d, "image", "%s-%s-image" % (image_basename, machine), required=True
+        d,
+        "deploy",
+        f"{pn}-do_image_complete-deploy",
     )
     for o in image_objset.foreach_root(oe.spdx30.software_File):
         root_elements.append(oe.sbom30.get_element_link_id(o))
Signature · 1 line
2.56.0
#102 lore raw

PATCH v9 7/9 layer.conf: Fix initramfs-framework not knowing which udev it has

In reply to Joshua Watt

The SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS from initramfs-framework to eudev and systemd meant that it would not correctly update when switching udev providers (for example, when switching from the "poky" distro to "poky-altcfg" distro). Fix this by removing both entries.

This also requires that the recipe no longer be allarch since it will change based on distro, which in turn requires initramfs-module-setup-live to exclude it from signature generation so that it can remain allarch.

---
 meta/conf/layer.conf                                       | 3 +--
 meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)
meta/conf/layer.conf +1 -2
index 13c920be6c..67fef79154 100644
@@ -59,8 +59,6 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   docbook-xsl-stylesheets->perl \
   ca-certificates->openssl \
   initramfs-framework->${VIRTUAL-RUNTIME_base-utils} \
-  initramfs-framework->eudev \
-  initramfs-framework->systemd \
   initramfs-module-install-efi->dosfstools \
   initramfs-module-install-efi->e2fsprogs \
   initramfs-module-install-efi->parted \
@@ -69,6 +67,7 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   initramfs-module-install->grub \
   initramfs-module-install->parted \
   initramfs-module-install->util-linux \
+  initramfs-module-setup-live->initramfs-framework \
   initramfs-module-setup-live->udev-extraconf \
   grub-efi->grub-bootconf \
   liberation-fonts->fontconfig \
meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb +0 -2
index 2ec03bc34c..2c5ff10813 100644
@@ -4,8 +4,6 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384
 RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_base-utils}"
 RRECOMMENDS:${PN} = "${VIRTUAL-RUNTIME_base-utils-syslog}"
 
-inherit allarch
-
 SRC_URI = "file://init \
            file://exec \
            file://nfsrootfs \
Signature · 1 line
2.56.0
#103 lore raw

PATCH v9 8/9 ovmf: Allow empty SPDX deploy artifacts

In reply to Joshua Watt

In native builds, ovfm do_deploy doesn't produce any artifacts. Set the SPDX_DEPLOY_ALLOW_EMPTY flag to prevent SPDX from erroring when this occurs.

---
 meta/recipes-core/ovmf/ovmf_git.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-core/ovmf/ovmf_git.bb +1 -0
index bf69108f0a..7cc844dfa6 100644
@@ -249,5 +249,6 @@ do_deploy:class-target() {
     fi
 }
 addtask do_deploy after do_compile before do_build
+SPDX_DEPLOY_ALLOW_EMPTY:task-deploy = "1"
 
 BBCLASSEXTEND = "native"
Signature · 1 line
2.56.0
#104 lore raw

PATCH v9 9/9 linux-dummy: Allow empty SPDX deploy artifacts

In reply to Joshua Watt

The recipe doesn't deploy anything so set SPDX_DEPLOY_ALLOW_EMPTY so that it doesn't generate an error

---
 meta/recipes-kernel/linux/linux-dummy.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-kernel/linux/linux-dummy.bb +2 -0
index d7f39a452d..c45352aab2 100644
@@ -23,6 +23,8 @@ FILES:kernel-vmlinux = ""
 ALLOW_EMPTY:kernel-vmlinux = "1"
 DESCRIPTION:kernel-vmlinux = "Kernel vmlinux meta package"
 
+SPDX_DEPLOY_ALLOW_EMPTY:task-deploy = "1"
+
 INHIBIT_DEFAULT_DEPS = "1"
 
 COMPATIBLE_HOST = ".*-linux"
Signature · 1 line
2.56.0
#105 lore raw
In reply to Joshua Watt

This set appears have triggered a failure in my usage in master.

The easiest way to reproduce it is to run:

MACHINE=qemux86-64 bitbake ovmf-native -c deploy
MACHINE=qemuarm64 bitbake ovmf-native -c deploy

The first machine will work fine, the second will fail with a manifest error. It basically says that the manifest file that's part of the SPDX work conflicts between the two machines. I've looked at the code, but I don't really understand what is supposed to happen here to suggested a fix.

Adding the following to the local.conf seems to at least avoid the error for me:

SPDX_DEPLOY_TASKS:remove = "do_deploy"

This is far from a fix, as it pretty much disables the who point of these changes, but it might be useful to get someone unstuck.

Quoted 87 lines · Joshua Watt via openembedded-core

The SPDX use case for file system image has been well defined since SPDX was first implemented, however there has always been a desire to also express SPDX output for other non-image deliverables (primarily, those that have a do_deploy task or similar). These types of tasks cannot easily use the traditional method of having a separate SPDX task that runs to create their SPDX output as this causes lots of problems with the way dependencies are specified. Instead, it is desirable for these tasks to directly produce SPDX output that can be consumed by other tasks that depend on them.

This patch series adds support for this. Any sstate task that starts with "do_deploy" can now be added to the SPDX_DEPLOY_TASKS list and it will run a postfunc to generate SPDX output that describes what is being deployed. For classical do_deploy tasks, this is setup to be easy by automatically capturing all the deployed output files in the SPDX data, but other tasks can be added as well.

Finally, the do_create_image_spdx task is removed and replaced with a SPDX deploy postfunc using this new system. This means that any task that depends on do_image_complete will automatically also get the SPDX output for the image, simplifying the dependency handling.

V2: Fixed SPDX documents missing at SBoM creation time when the documents were not a direct dependency of the SBoM, and were present in a sstate object. Previously, these sstate objects were not restored because they were "covered" by the later sstate tasks, but now they are restored if they are depended on by a task that creates SPDX output.

V3: Fixed a bug where dependencies that are not in the taskhash could be missing when the final SBoM is created and added tests.

V4: Fixed some testing errors that revealed that EFI providers have to be MACHINE_ARCH (and consequently, wic-tools)

V6: Fixed a bug where eudev/systemd initramfs-framework was not being properly detected and the wrong link was in the SPDX due to the switch between the two not being detected.

Also, deploy.bbclass now always adds do_deploy to SPDX_DEPLOY_TASKS, so any recipe inheriting that class gets it automatically.

V7: Add SPDX_DEPLOY_ALLOW_EMPTY variable, and set it on ovmf to fix it erroring out for native builds.

V8: Fix deploy error for linux-dummy, and allarch signature error for initramfs-framework

V9: Fix initramfs-module-setup-live allarch signature error now that initramfs-framwork is no longer allarch.

Joshua Watt (9):
spdx: Skip dependencies that are not in the taskhash
spdx: Add ability for deploy tasks to create SPDX
oeqa: Add SPDX deploy SBoM test
classes-global/sstate: Keep SPDX generating setscene dependencies classes-recipe/deploy: Add do_deploy to SPDX_DEPLOY_TASKS
spdx: Replace do_create_image_spdx with deploy task layer.conf: Fix initramfs-framework not knowing which udev it has
ovmf: Allow empty SPDX deploy artifacts
linux-dummy: Allow empty SPDX deploy artifacts

  meta/classes-global/sstate.bbclass            |  38 ++-
  .../create-spdx-image-3.0.bbclass             |  32 +-
  meta/classes-recipe/deploy.bbclass            |   2 +
  meta/classes-recipe/nospdx.bbclass            |   2 +-
  meta/classes/create-spdx-3.0.bbclass          | 185 ++++++++++
  meta/classes/spdx-common.bbclass              |   2 +-
  meta/conf/layer.conf                          |   3 +-
  meta/lib/oe/sbom30.py                         |  46 ++-
  meta/lib/oe/spdx30_tasks.py                   | 323 ++++++++++++++----
  meta/lib/oe/spdx_common.py                    |   2 +-
  meta/lib/oeqa/selftest/cases/spdx.py          |  11 +
  .../initrdscripts/initramfs-framework_1.0.bb  |   2 -
  meta/recipes-core/ovmf/ovmf_git.bb            |   1 +
  meta/recipes-kernel/linux/linux-dummy.bb      |   2 +
  14 files changed, 546 insertions(+), 105 deletions(-)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#249865): https://lists.openembedded.org/g/openembedded-core/message/249865
Mute This Topic: https://lists.openembedded.org/mt/122181587/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-