diff mbox series

[[meta-swupdate] PATCH 9/9] Create a class to generate SWU from image

Message ID 20210826113412.327976-10-sbabic@denx.de
State Accepted
Headers show
Series [[meta-swupdate] PATCH 9/9] Create a class to generate SWU from image | expand

Commit Message

Stefano Babic Aug. 26, 2021, 11:34 a.m. UTC
It is currently required a separate recipe to build the SWU from an
image. This is very flexible but it appears overkilling in use cases
where the only artifact is the rootfs. Create a separate class that can
be inherited replacing swupdate.bbclass and that build a SWU from an
image recipe.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 classes/swupdate-image.bbclass | 35 ++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 classes/swupdate-image.bbclass
diff mbox series

Patch

diff --git a/classes/swupdate-image.bbclass b/classes/swupdate-image.bbclass
new file mode 100644
index 0000000..54d121f
--- /dev/null
+++ b/classes/swupdate-image.bbclass
@@ -0,0 +1,35 @@ 
+# Copyright (C) 2015-2021 Stefano Babic <sbabic@denx.de>
+#
+# This class is thought to be used in an image recipe.
+# It generates a SWU file from the image itself
+# User *must* add a sw-descitpion file
+#
+# To use this class, add the inherit clause of the update image bb file.
+# The generated output file is an swu archive ready to be uploaded to a device running
+# swupdate.
+
+inherit swupdate-common.bbclass
+inherit image-artifact-names
+
+S = "${WORKDIR}/${PN}"
+
+SRC_URI += "file://sw-description"
+SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
+
+python do_swupdate_copy_swdescription() {
+
+    import shutil
+
+    workdir = d.getVar('S', True)
+    image = d.getVar('IMAGE_BASENAME', True)
+    filespath = d.getVar('FILESPATH')
+    sw_desc_path = bb.utils.which(filespath, "sw-description")
+    shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
+
+    if d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) is None:
+       bb.fatal("SWUPDATE_IMAGES_FSTYPES[%s] is not set !" % image)
+}
+
+do_swupdate_copy_swdescription[nostamp] = "1"
+addtask swupdate_copy_swdescription before do_image_complete after do_unpack
+addtask swuimage after do_swupdate_copy_swdescription do_image_complete before do_build