All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quirin Gylstorff <Quirin.Gylstorff@siemens.com>
To: cip-dev@lists.cip-project.org, jan.kiszka@siemens.com,
	felix.moessbauer@siemens.com, christian.storm@siemens.com
Subject: [cip-dev][isar-cip-core][RFC 4/5] image_uuid: read target_image_uuid
Date: Thu, 10 Nov 2022 13:45:02 +0100	[thread overview]
Message-ID: <20221110124503.274124-5-Quirin.Gylstorff@siemens.com> (raw)
In-Reply-To: <20221110124503.274124-1-Quirin.Gylstorff@siemens.com>

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

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@siemens.com>
---
 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



  parent reply	other threads:[~2022-11-10 12:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 12:44 [cip-dev][isar-cip-core][RFC 0/5] SWUpdate abort on installing indentical image Quirin Gylstorff
2022-11-10 12:44 ` [cip-dev][isar-cip-core][RFC 1/5] core/images/swupdate.inc: Move image_uuid to swupdate.inc Quirin Gylstorff
2022-11-10 12:45 ` [cip-dev][isar-cip-core][RFC 2/5] swupdate-handler-roundrobin: Increase revision Quirin Gylstorff
2022-11-10 13:50   ` Jan Kiszka
2022-11-10 12:45 ` [cip-dev][isar-cip-core][RFC 3/5] swupdate-handler-roundrobin: add uuidcheck patch Quirin Gylstorff
2022-11-10 13:52   ` Jan Kiszka
2022-11-10 14:05     ` Gylstorff Quirin
2022-11-10 12:45 ` Quirin Gylstorff [this message]
2022-11-10 13:56   ` [cip-dev][isar-cip-core][RFC 4/5] image_uuid: read target_image_uuid Jan Kiszka
2022-11-10 14:09     ` Gylstorff Quirin
2022-11-10 12:45 ` [cip-dev][isar-cip-core][RFC 5/5] recipe-core/images: Integrate uuidcheck into sw-description Quirin Gylstorff
2022-11-10 13:58   ` Jan Kiszka
2022-11-10 14:10     ` Gylstorff Quirin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110124503.274124-5-Quirin.Gylstorff@siemens.com \
    --to=quirin.gylstorff@siemens.com \
    --cc=christian.storm@siemens.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=felix.moessbauer@siemens.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.