diff mbox series

[v2] classes: image-buildinfo: allow deploying the buildinfo file

Message ID 20260916062028.2282187-1-dwagenknecht@emlix.com
State New
Headers show
Series [v2] classes: image-buildinfo: allow deploying the buildinfo file | expand

Commit Message

Daniel Wagenknecht Sept. 16, 2026, 6:20 a.m. UTC
The `buildinfo` file generated by the `image-buildinfo` class
contains useful information to identify an image. Having it in the
rootfs of the image as well as deployed alongside the image artifact
can be useful. Allow to deploy it alongside the image by setting
'IMAGE_BUILDINFO_DEPLOY' to '1'.

I use this in an automated testing workflow with unreliable deploy step
to ensure the deployment succeeded. With
    IMAGE_BUILDINFO_VARS += "IMAGE_NAME"
    IMAGE_BUILDINFO_DEPLOY = "1"
the generated buidinfo file is unique and the deploy step can be
verified by comparing (the hash of) the file on the booted system and in
`IMAGE_DEPLOY_DIR`.

Signed-off-by: Daniel Wagenknecht <dwagenknecht@emlix.com>
---

@Paul Barker:
  I missed your reply, sorry! Adapted the patches according to your comments now.

v2:
  * rebased
  * copy generated file instead of regenerating it
  * add varflags only if needed


 meta/classes/image-buildinfo.bbclass | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Alexander Kanavin Sept. 16, 2026, 10:43 a.m. UTC | #1
On Wed, 16 Sept 2026 at 08:20, Daniel Wagenknecht via
lists.openembedded.org <dwagenknecht=emlix.com@lists.openembedded.org>
wrote:
> +# Deploy the file alongside the images.
> +IMAGE_BUILDINFO_DEPLOY ??= "0"

Do we need yet another variable and yet more conditional code paths
that are never tested? Why not just always deploy it?

Alex
diff mbox series

Patch

diff --git a/meta/classes/image-buildinfo.bbclass b/meta/classes/image-buildinfo.bbclass
index 01636dac65f..8fddcba3ee3 100644
--- a/meta/classes/image-buildinfo.bbclass
+++ b/meta/classes/image-buildinfo.bbclass
@@ -16,6 +16,9 @@  IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION"
 IMAGE_BUILDINFO_FILE ??= "${sysconfdir}/buildinfo"
 SDK_BUILDINFO_FILE ??= "/buildinfo"
 
+# Deploy the file alongside the images.
+IMAGE_BUILDINFO_DEPLOY ??= "0"
+
 # From buildhistory.bbclass
 def image_buildinfo_outputvars(vars, d):
     vars = vars.split()
@@ -70,6 +73,12 @@  python buildinfo_image () {
     bb.build.exec_func("buildinfo", d)
 }
 
+python buildinfo_deploy() {
+    src = d.expand("${IMAGE_ROOTFS}/${IMAGE_BUILDINFO_FILE}")
+    dst = d.expand("${IMGDEPLOYDIR}/${IMAGE_NAME}.buildinfo")
+    oe.path.copyhardlink(src, dst)
+}
+
 python buildinfo_sdk () {
     d.setVar("BUILDINFODEST", "${SDK_OUTPUT}/${SDKPATH}")
     d.setVar("IMAGE_BUILDINFO_FILE", d.getVar("SDK_BUILDINFO_FILE"))
@@ -79,3 +88,10 @@  python buildinfo_sdk () {
 IMAGE_PREPROCESS_COMMAND += "buildinfo_image"
 POPULATE_SDK_PRE_TARGET_COMMAND += "buildinfo_sdk"
 
+python () {
+   if oe.utils.vartrue('IMAGE_BUILDINFO_DEPLOY', True, False, d):
+     d.appendVar("IMAGE_PREPROCESS_COMMAND", " buildinfo_deploy")
+     d.appendVarFlag("do_image", "postfuncs", " create_symlinks")
+     d.appendVarFlag("do_image", "subimages", " buildinfo")
+}
+