From: Quirin Gylstorff <quirin.gylstorff@...>
This writes the target_image_uuid to the Variable TARGET_IMAGE_UUID
which can be used to validate a update against the root file system.
Signed-off-by: Quirin Gylstorff <quirin.gylstorff@...>
---
classes/image_uuid.bbclass | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/classes/image_uuid.bbclass b/classes/image_uuid.bbclass
index 277941b..3e2e3de 100644
--- a/classes/image_uuid.bbclass
+++ b/classes/image_uuid.bbclass
@@ -13,6 +13,8 @@
inherit rootfs
inherit image
+# Generate the uuid from BB_TASKHASH to ensure a new
+# hash on each rebuild
def generate_image_uuid(d):
import uuid
@@ -23,6 +25,23 @@ def generate_image_uuid(d):
IMAGE_UUID ?= "${@generate_image_uuid(d)}"
+def read_target_image_uuid(d):
+ import os.path
+
+ deploy_dir = d.getVar("DEPLOY_DIR_IMAGE")
+ image_full_name = d.getVar("IMAGE_FULLNAME")
+ uuid_file = f"{deploy_dir}/{image_full_name}.uuid.env"
+ if not os.path.isfile(uuid_file):
+ return None
+
+ target_image_uuid = None
+ with open(uuid_file, "r") as f:
+ uuid_file_content = f.read()
+ target_image_uuid = uuid_file_content.split('=')[1].strip(' \t\n\r').strip('\"')
+ return target_image_uuid
+
+TARGET_IMAGE_UUID = "${@read_target_image_uuid(d)}"
+
do_generate_image_uuid[vardeps] += "IMAGE_UUID"
do_generate_image_uuid[depends] = "buildchroot-target:do_build"
do_generate_image_uuid[dirs] = "${DEPLOY_DIR_IMAGE}"
--
2.35.1