diff mbox series

[v3] classes: image-buildinfo: deploy the buildinfo file

Message ID 20260928081434.975338-1-dwagenknecht@emlix.com
State Under Review
Headers show
Series [v3] classes: image-buildinfo: deploy the buildinfo file | expand

Commit Message

Daniel Wagenknecht Sept. 28, 2026, 8:14 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.

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>
---
v2:
  * rebased
  * copy generated file instead of regenerating it
  * add varflags only if needed

v3:
  * rebased
  * deploy unconditionally as suggested by alex.kanavin@gmail.com

 meta/classes/image-buildinfo.bbclass | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes/image-buildinfo.bbclass b/meta/classes/image-buildinfo.bbclass
index 01636dac6..d44e15443 100644
--- a/meta/classes/image-buildinfo.bbclass
+++ b/meta/classes/image-buildinfo.bbclass
@@ -70,12 +70,21 @@  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)
+}
+do_image[postfuncs] += "create_symlinks"
+do_image[subimages] += "buildinfo"
+
+
 python buildinfo_sdk () {
     d.setVar("BUILDINFODEST", "${SDK_OUTPUT}/${SDKPATH}")
     d.setVar("IMAGE_BUILDINFO_FILE", d.getVar("SDK_BUILDINFO_FILE"))
     bb.build.exec_func("buildinfo", d)
 }
 
-IMAGE_PREPROCESS_COMMAND += "buildinfo_image"
+IMAGE_PREPROCESS_COMMAND += "buildinfo_image buildinfo_deploy"
 POPULATE_SDK_PRE_TARGET_COMMAND += "buildinfo_sdk"