]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
classes: image-buildinfo: allow deploying the buildinfo file
authorDaniel Wagenknecht <dwagenknecht@emlix.com>
Mon, 20 Apr 2026 17:43:47 +0000 (19:43 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 5 Jun 2026 14:50:15 +0000 (15:50 +0100)
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>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/image-buildinfo.bbclass

index b83ce650ad45c6a0ea49180994ee6572374fb08d..1dce50b376ea51f97fdfd5dd78993057e2d4162d 100644 (file)
@@ -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,12 +73,20 @@ python buildinfo_image () {
     bb.build.exec_func("buildinfo", d)
 }
 
+python buildinfo_deploy() {
+    d.setVar("BUILDINFODEST", "${IMGDEPLOYDIR}/")
+    d.setVar("IMAGE_BUILDINFO_FILE", "${IMAGE_NAME}.buildinfo")
+    bb.build.exec_func("buildinfo", d)
+}
+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 ${@oe.utils.vartrue('IMAGE_BUILDINFO_DEPLOY', 'buildinfo_deploy', '', d)}"
 POPULATE_SDK_PRE_TARGET_COMMAND += "buildinfo_sdk"