classes/sbom-cve-check: fall back to the stable SBOM symlink
PATCH 1/1 classes/sbom-cve-check: fall back to the stable SBOM symlink
do_sbom_cve_check builds its input path from ${IMAGE_NAME}, which carries ${IMAGE_VERSION_SUFFIX} and so ${DATETIME}. That value is excluded from task hashes but changes on every bitbake invocation, so the path is only correct when do_create_image_sbom_spdx ran in the same invocation.
It does not when the class is newly enabled on an existing build tree: the image SBOM is already deployed and stamped from an earlier build, do_sbom_cve_check has never run, so bitbake executes only the latter and it looks for a file whose timestamp belongs to the current invocation. The same happens on any forced re-run of just this task:
$ bitbake -f -c sbom_cve_check core-image-minimal
ERROR: core-image-minimal-1.0-r0 do_sbom_cve_check: sbom-cve-check failed: [...]
sbom-cve-check: error: [Errno 2] No such file or directory:
'.../core-image-minimal-qemux86-64.rootfs-20260804101106.spdx.json'$ ls tmp/deploy/images/qemux86-64/*.spdx.json core-image-minimal-qemux86-64.rootfs-20260804095834.spdx.json core-image-minimal-qemux86-64.rootfs.spdx.json -> ...-20260804095834.spdx.json
The file is there under ${IMAGE_LINK_NAME}, the symlink do_create_image_sbom_spdx maintains. Keep preferring the timestamped name, so behaviour is unchanged whenever it exists, and fall back to the symlink rather than failing. Guarded on link_name being set, since IMAGE_LINK_NAME can be empty.
--- meta/classes-recipe/sbom-cve-check.bbclass | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
meta/classes-recipe/sbom-cve-check.bbclass +12 -1
@@ -14,9 +14,20 @@ python do_sbom_cve_check() { """ Task: Run sbom-cve-check analysis on SBOM. """ - sbom_path = d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.spdx.json") + import os + image_name = d.getVar("IMAGE_NAME") link_name = d.getVar("IMAGE_LINK_NAME") + deploy_dir = d.getVar("DEPLOY_DIR_IMAGE") + + # IMAGE_NAME carries DATETIME, which changes on every invocation while being + # excluded from task hashes, so this path is only valid when + # do_create_image_sbom_spdx ran in the same invocation. Fall back to the + # symlink it maintains, which is stable across builds. + sbom_path = os.path.join(deploy_dir, "%s.spdx.json" % image_name) + if not os.path.exists(sbom_path) and link_name: + sbom_path = os.path.join(deploy_dir, "%s.spdx.json" % link_name) + run_sbom_cve_check(d, sbom_path, image_name, link_name) }
Signature · 1 line
2.55.0
Quoted 20 lines · On Tue, 2026-08-04 at 13:24 +0200, [email protected] wrote:
do_sbom_cve_checkbuilds its input path from ${IMAGE_NAME}, which carries ${IMAGE_VERSION_SUFFIX} and so ${DATETIME}. That value is excluded from task hashes but changes on every bitbake invocation, so the path is only correct whendo_create_image_sbom_spdxran in the same invocation.It does not when the class is newly enabled on an existing build tree: the image SBOM is already deployed and stamped from an earlier build,
do_sbom_cve_checkhas never run, so bitbake executes only the latter and it looks for a file whose timestamp belongs to the current invocation. The same happens on any forced re-run of just this task:$ bitbake -f -c sbom_cve_check core-image-minimal ERROR: core-image-minimal-1.0-r0 do_sbom_cve_check: sbom-cve-check failed: [...] sbom-cve-check: error: [Errno 2] No such file or directory: '.../core-image-minimal-qemux86-64.rootfs-20260804101106.spdx.json'$ ls tmp/deploy/images/qemux86-64/*.spdx.json core-image-minimal-qemux86-64.rootfs-20260804095834.spdx.json core-image-minimal-qemux86-64.rootfs.spdx.json -> ...-20260804095834.spdx.json
Quoted 6 lines
The file is there under ${IMAGE_LINK_NAME}, the symlink
do_create_image_sbom_spdxmaintains. Keep preferring the timestamped name, so behaviour is unchanged whenever it exists, and fall back to the symlink rather than failing. Guarded onlink_namebeing set, sinceIMAGE_LINK_NAMEcan be empty.Signed-off-by Thomas Roos <[email protected]>
Hi Thomas,
This code has already changed recently in commit 2a80840a4fe0 ("sbom-cve-check: Fix breakage with empty IMAGE_LINK_NAME"). Perhaps we should have just added a fallback to IMAGE_NAME if IMAGE_LINK_NAME is unset.
A quick scan of the code shows that there are other places where it is assumed that IMAGE_LINK_NAME is valid, such as vex.bbclass.
Best regards,
Signature · 1 line
Paul Barker
v2 cover Handle an empty IMAGE_LINK_NAME consistently
v1 fixed the sbom-cve-check input path. Paul noted that 2a80840a4fe0 ("sbom-cve-check: Fix breakage with empty IMAGE_LINK_NAME") had already touched this class, and that other classes make the same assumption. That commit guarded the export symlinks; the input path is separate and still built from IMAGE_NAME. Patch 1 now uses the shape Paul suggested, and patches 2-4 fix the other sites found by auditing meta/classes*, meta/lib/oe and meta/lib/oeqa.
Read and write sites need opposite handling of an empty value: read sites fall back to IMAGE_NAME, write sites skip the link. A central default (pin IMAGE_LINK_NAME to IMAGE_NAME when empty) does not work, as create_symlinks and multiubi_mkfs have no link != target check and IMAGE_NAME is itself derived from IMAGE_LINK_NAME.
Tested on qemux86-64, each fix confirmed in both directions. Patch 5 covers patches 2-4 in one build; patch 1 was checked by hand, as a selftest would need the sbom-cve-check databases (~8.7G of git).
AI-Generated: Uses Claude Opus 5
Thomas Roos (5):
sbom-cve-check: read the image SBOM through the stable symlink
vex: skip the VEX symlink when IMAGE_LINK_NAME is empty
testexport: fall back to IMAGE_NAME when IMAGE_LINK_NAME is empty
image_types: skip multiubi symlinks when IMAGE_LINK_NAME is empty oeqa/selftest/imagefeatures: test an empty IMAGE_LINK_NAME
meta/classes-recipe/image_types.bbclass | 2 +- meta/classes-recipe/sbom-cve-check.bbclass | 3 +- meta/classes-recipe/testexport.bbclass | 2 +- meta/classes/vex.bbclass | 3 +- meta/lib/oeqa/selftest/cases/imagefeatures.py | 42 +++++++++++++++++++ 5 files changed, 48 insertions(+), 4 deletions(-)
Signature · 1 line
2.55.0
PATCH v2 1/5 sbom-cve-check: read the image SBOM through the stable symlink
The input path was built from IMAGE_NAME, which carries DATETIME and so only resolves within the invocation that wrote the SBOM: enabling the class on an existing build tree, or "bitbake -f -c sbom_cve_check", failed with ENOENT. Read IMAGE_LINK_NAME instead, falling back to IMAGE_NAME when it is unset.
AI-Generated: Uses Claude Opus 5
--- meta/classes-recipe/sbom-cve-check.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes-recipe/sbom-cve-check.bbclass +2 -1
@@ -14,9 +14,10 @@ python do_sbom_cve_check() { """ Task: Run sbom-cve-check analysis on SBOM. """ - sbom_path = d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.spdx.json") image_name = d.getVar("IMAGE_NAME") link_name = d.getVar("IMAGE_LINK_NAME") + sbom_path = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), + "%s.spdx.json" % (link_name or image_name)) run_sbom_cve_check(d, sbom_path, image_name, link_name) }
Signature · 1 line
2.55.0
PATCH v2 2/5 vex: skip the VEX symlink when IMAGE_LINK_NAME is empty
In reply to Thomas RoosAn empty IMAGE_LINK_NAME left a bare ".vex.json" symlink in the deploy directory. Skip the link, as image.bbclass and rootfs-postcommands do.
AI-Generated: Uses Claude Opus 5
--- meta/classes/vex.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/vex.bbclass +2 -1
@@ -204,7 +204,8 @@ python vex_write_rootfs_manifest () { with open(manifest_name, "w") as f: json.dump(json_data, f, indent=2) - update_symlinks(manifest_name, link_path) + if link_name: + update_symlinks(manifest_name, link_path) bb.plain("Image VEX JSON report stored in: %s" % manifest_name) }
Signature · 1 line
2.55.0
Re: [PATCH v2 2/5] vex: skip the VEX symlink when IMAGE_LINK_NAME is empty
Quoted 14 lines · Thomas Roos
An empty
IMAGE_LINK_NAMEleft a bare ".vex.json" symlink in the deploy directory. Skip the link, as image.bbclass and rootfs-postcommands do.AI-Generated: Uses Claude Opus 5
Signed-off-by Thomas Roos <[email protected]>--- meta/classes/vex.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)meta/classes/vex.bbclass +0
-0
meta/classes/vex.bbclass python vex_write_rootfs_manifest () { · line 208
Quoted 6 lines
meta/classes/vex.bbclass +2
-1@@ -204,7 +204,8 @@ python vex_write_rootfs_manifest () { with open(manifest_name, "w") as f: json.dump(json_data, f, indent=2) - update_symlinks(manifest_name, link_path) + if link_name: + update_symlinks(manifest_name, link_path)
Using link_name in the conditional and link_path in the function argument is confusing. Perhaps we should move the link_path assignment inside this conditional? It's not used anywhere else.
if link_name:
link_path = os.path.join(deploy_dir, "%s.vex.json" % link_name) update_symlinks(manifest_name, link_path)
Best regards,
Signature · 1 line
Paul Barker
Re: [PATCH v2 2/5] vex: skip the VEX symlink when IMAGE_LINK_NAME is empty
Quoted 26 lines · Paul Barker
Quoted 14 lines · Thomas Roos
An empty
IMAGE_LINK_NAMEleft a bare ".vex.json" symlink in the deploy directory. Skip the link, as image.bbclass and rootfs-postcommands do.AI-Generated: Uses Claude Opus 5
Signed-off-by Thomas Roos <[email protected]>--- meta/classes/vex.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)meta/classes/vex.bbclass +0
-0meta/classes/vex.bbclass python vex_write_rootfs_manifest () { · line 208
Quoted 6 lines
meta/classes/vex.bbclass +2
-1@@ -204,7 +204,8 @@ python vex_write_rootfs_manifest () { with open(manifest_name, "w") as f: json.dump(json_data, f, indent=2) - update_symlinks(manifest_name, link_path) + if link_name: + update_symlinks(manifest_name, link_path)Using
link_namein the conditional andlink_pathin the function argument is confusing. Perhaps we should move thelink_pathassignment inside this conditional? It's not used anywhere else.
Quoted 3 lines
if
link_name:
link_path=os.path.join(deploy_dir, "%s.vex.json" % link_name)update_symlinks(manifest_name, link_path)
Actually, ignore this, I'm going in the wrong direction here.... I'll reply to the cover letter about the whole series.
Sorry for the noise!
Signature · 1 line
Paul Barker
PATCH v2 3/5 testexport: fall back to IMAGE_NAME when IMAGE_LINK_NAME is empty
In reply to Thomas Rooscopy_needed_files() built the manifest and testdata paths from IMAGE_LINK_NAME alone, so an empty value made it copy ".manifest" and fail. testexport_main() in the same file already falls back to IMAGE_NAME.
AI-Generated: Uses Claude Opus 5
--- meta/classes-recipe/testexport.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-recipe/testexport.bbclass +1 -1
@@ -134,7 +134,7 @@ def copy_needed_files(d, tc): # Copy test data image_name = ("%s/%s" % (d.getVar('DEPLOY_DIR_IMAGE'), - d.getVar('IMAGE_LINK_NAME'))) + d.getVar('IMAGE_LINK_NAME') or d.getVar('IMAGE_NAME'))) image_manifest = "%s.manifest" % image_name tdname = "%s.testdata.json" % image_name test_data_path = os.path.join(export_path, 'data')
Signature · 1 line
2.55.0
PATCH v2 4/5 image_types: skip multiubi symlinks when IMAGE_LINK_NAME is empty
In reply to Thomas RoosAn empty IMAGE_LINK_NAME made multiubi_mkfs link the named volumes from the suffix alone, e.g. "_volume.ubifs". Guard the block.
AI-Generated: Uses Claude Opus 5
--- meta/classes-recipe/image_types.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-recipe/image_types.bbclass +1 -1
@@ -217,7 +217,7 @@ multiubi_mkfs() { mv ubinize${vname}-${IMAGE_NAME}.cfg ${IMGDEPLOYDIR}/ # Create own symlinks for 'named' volumes - if [ -n "$vname" ]; then + if [ -n "$vname" ] && [ -n "${IMAGE_LINK_NAME}" ]; then cd ${IMGDEPLOYDIR} if [ -e ${IMAGE_NAME}${vname}.ubifs ]; then ln -sf ${IMAGE_NAME}${vname}.ubifs \
Signature · 1 line
2.55.0
PATCH v2 5/5 oeqa/selftest/imagefeatures: test an empty IMAGE_LINK_NAME
In reply to Thomas RoosNothing covered this configuration, which is why the vex, multiubi and testexport sites went unnoticed. One core-image-minimal build with IMAGE_LINK_NAME cleared covers all three; the test fails without them.
AI-Generated: Uses Claude Opus 5
--- meta/lib/oeqa/selftest/cases/imagefeatures.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+)
meta/lib/oeqa/selftest/cases/imagefeatures.py +42 -0
@@ -332,3 +332,45 @@ CORE_IMAGE_EXTRA_INSTALL = "man-pages" status, output = qemu.run_serial("man --pager=cat intro") self.assertEqual(status, 1, 'Failed to run man: %s' % (output)) self.assertIn("introduction to user commands", output) + + def test_empty_image_link_name(self): + """ + Test that an empty IMAGE_LINK_NAME suppresses the artifact symlinks + and that the classes reading an artifact back still locate it. + """ + image = 'core-image-minimal' + vname = 'mtd_4_256' + config = """ +INHERIT += "vex" +IMAGE_CLASSES += "testexport" +IMAGE_LINK_NAME = "" +IMAGE_NAME = "${IMAGE_BASENAME}${IMAGE_MACHINE_SUFFIX}${IMAGE_NAME_SUFFIX}" +IMAGE_FSTYPES += "multiubi" +MULTIUBI_BUILD = "%s" +MKUBIFS_ARGS_%s ?= "-m 4096 -e 253952 -c 4096" +UBINIZE_ARGS_%s ?= "-m 4096 -p 256KiB" +TEST_TARGET_IP = "192.168.7.2" +TEST_SERVER_IP = "192.168.7.1" +""" % (vname, vname, vname) + self.write_config(config) + + bitbake(image) + bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_NAME', 'TEST_EXPORT_DIR'], image) + deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] + + # Artifacts are still named after IMAGE_NAME + for name in ("%s.vex.json" % bb_vars['IMAGE_NAME'], + "%s_%s.ubifs" % (bb_vars['IMAGE_NAME'], vname)): + self.assertTrue(os.path.exists(os.path.join(deploy_dir, name)), + "%s is missing from %s" % (name, deploy_dir)) + + # ...and nothing is linked from the suffix alone + for name in (".vex.json", "_%s.ubifs" % vname, "_%s.ubi" % vname): + self.assertFalse(os.path.lexists(os.path.join(deploy_dir, name)), + "%s was created from an empty IMAGE_LINK_NAME" % name) + + # testexport copies these back out of DEPLOY_DIR_IMAGE + bitbake("-c testexport %s" % image) + for name in ('manifest', 'testdata.json'): + path = os.path.join(bb_vars['TEST_EXPORT_DIR'], 'data', name) + self.assertTrue(os.path.exists(path), "%s was not exported" % path)
Signature · 1 line
2.55.0
Re: [PATCH v2 0/5] Handle an empty IMAGE_LINK_NAME consistently
In reply to Thomas RoosQuoted 14 lines · Thomas Roos
v1 fixed the sbom-cve-check input path. Paul noted that
2a80840a4fe0("sbom-cve-check: Fix breakage with emptyIMAGE_LINK_NAME") had already touched this class, and that other classes make the same assumption. That commit guarded the export symlinks; the input path is separate and still built fromIMAGE_NAME. Patch 1 now uses the shape Paul suggested, and patches 2-4 fix the other sites found by auditing meta/classes*, meta/lib/oe and meta/lib/oeqa.Read and write sites need opposite handling of an empty value: read sites fall back to
IMAGE_NAME, write sites skip the link. A central default (pinIMAGE_LINK_NAMEtoIMAGE_NAMEwhen empty) does not work, ascreate_symlinksandmultiubi_mkfshave no link != target check andIMAGE_NAMEis itself derived fromIMAGE_LINK_NAME.
Quoted 5 lines
Tested on qemux86-64, each fix confirmed in both directions. Patch 5 covers patches 2-4 in one build; patch 1 was checked by hand, as a selftest would need the sbom-cve-check databases (~8.7G of git).
AI-Generated: Uses Claude Opus 5
Hi Thomas,
I discussed this with Richard, we want to avoid increasing the complexity of the code unnecessarily.
IMAGE_LINK_NAME is intended to always be valid, we need the link because IMAGE_NAME is dependent on the date and time that an image was built. Do we really need to support the case where IMAGE_LINK_NAME is unset?
If we don't need to support IMAGE_LINK_NAME being unset then perhaps we should just print a better error message in that case and give up.
Best regards,
Signature · 1 line
Paul Barker
Re: [PATCH v2 0/5] Handle an empty IMAGE_LINK_NAME consistently
Hi Paul,
Retested the original do_sbom_cve_check bug.
If you enable the sbom_cve_check class after a successful build it fails as do_create_image_sbom_spdx stays cached from the earlier build and its output keeps the old build's DATETIME. Result:
sbom-cve-check: error: [Errno 2] No such file or directory:
'.../core-image-minimal-qemux86-64.rootfs-20260902135131.spdx.json'
Before: path built as ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.spdx.json as IMAGE_NAME carries DATETIME, so it only matches the SBOM written in the same bitbake run.
After: build path from IMAGE_LINK_NAME instead (link_name or image_name, falls back when link name empty). IMAGE_LINK_NAME is the stable, non-timestamped symlink do_create_image_sbom_spdx maintains pointing at the current SBOM. create-spdx-image-3.0.bbclass keeps it updated to the latest build's file. Reading through it means do_sbom_cve_check finds the SBOM regardless of which invocation wrote it, since the symlink always points at the current one, not just this run's timestamp.
bitbake core-image-minimal # build once, class
not yet enabled
bitbake-config-build --set-fragment sbom-cve-check # or add fragment
manually
git checkout 1a32e30~1 -- meta/classes-recipe/sbom-cve-check.bbclass #
pre-fix code
bitbake core-image-minimal # ENOENT ondo_sbom_cve_check
git checkout HEAD -- meta/classes-recipe/sbom-cve-check.bbclass #
restore fix
bitbake -c sbom_cve_check core-image-minimal -f #
succeeds
The pattern is pre-existing, not part of this series, it was already established:
- meta/classes-recipe/testexport.bbclass:52 (testexport_main()) —d.getVar('IMAGE_LINK_NAME') or d.getVar('IMAGE_NAME')
- meta/classes-recipe/testimage.bbclass:228 — same IMAGE_LINK_NAME orIMAGE_NAME fallback, reading testdata.json back
Plus the empty-guard pattern (skip symlink creation rather than fail):
- meta/classes-recipe/image.bbclass:610 (create_symlinks) — if notlink_name: return
- meta/classes-recipe/rootfs-postcommands.bbclass:402,479
(write_image_manifest) — if ... and link_name
- meta/classes-recipe/qemuboot.bbclass:147 — ifd.getVar('IMAGE_LINK_NAME'): before writing the symlink
- meta/classes-recipe/kernel.bbclass:804 — if [ -n
"${KERNEL_IMAGE_LINK_NAME}" ] before the kernel symlink
- meta/classes-recipe/license_image.bbclass:300 — same link_name guard
pattern
- meta/classes-recipe/baremetal-image.bbclass:73 — same
I'm not dying if these series are not merged, I just think this fix is useful and there are already places using the same pattern! Please correct me if I'm wrong, also agree on not adding more code complexity. May a central place is better, but I do not know one!
Cheers, Thomas
Am Do., 27. Aug. 2026 um 17:37 Uhr schrieb Paul Barker <[email protected]>:
Quoted 43 lines · Thomas Roos
Quoted 10 lines
v1 fixed the sbom-cve-check input path. Paul noted that
2a80840a4fe0("sbom-cve-check: Fix breakage with emptyIMAGE_LINK_NAME") had already touched this class, and that other classes make the same assumption. That commit guarded the export symlinks; the input path is separate and still built fromIMAGE_NAME. Patch 1 now uses the shape Paul suggested, and patches 2-4 fix the other sites found by auditing meta/classes*, meta/lib/oe and meta/lib/oeqa.Read and write sites need opposite handling of an empty value: read sites fall back to
IMAGE_NAME, write sites skip the link. A central default(pin
Quoted 1 line
IMAGE_LINK_NAMEtoIMAGE_NAMEwhen empty) does not work, as
create_symlinksQuoted 4 lines
and
multiubi_mkfshave no link != target check andIMAGE_NAMEis itself derived fromIMAGE_LINK_NAME.Tested on qemux86-64, each fix confirmed in both directions. Patch 5
covers
Quoted 1 line
patches 2-4 in one build; patch 1 was checked by hand, as a selftest
would
Quoted 3 lines
need the sbom-cve-check databases (~8.7G of git).
AI-Generated: Uses Claude Opus 5
Hi Thomas,
I discussed this with Richard, we want to avoid increasing the complexity of the code unnecessarily.
IMAGE_LINK_NAMEis intended to always be valid, we need the link becauseIMAGE_NAMEis dependent on the date and time that an image was built. Do we really need to support the case whereIMAGE_LINK_NAMEis unset?If we don't need to support
IMAGE_LINK_NAMEbeing unset then perhaps we should just print a better error message in that case and give up.Best regards,
--
Paul Barker
Hi Paul,
updated patch and added also a fix for the other places. Together with a test case. Let me know if such patches are not welcome, acc. to the discussion of yesterdays engineering sync. I do not want to loose my reputation and end up in hell ;)
I just want to contribute a bit back to the greatest project in the world!
So please tell me!
Cheers, Thomas