[OE-core] [PATCH 2/3] Add possibility to install overlays to image through a class

Geoffrey Levillain geoffrey.levillain at smile.fr
Wed Feb 15 16:18:48 UTC 2017


There is often a need to add configuration files specific to an image,
to simplify this process we can use a task.

Fetching is set as noexec for images, but there is a need to fetch files
here. This class permit to use do_fetch, do_unpack and do_patch in order
to get your image-specific overlays to install.

Signed-off-by: Geoffrey Levillain <geoffrey.levillain at smile.fr>
---
 meta/classes/image_overlay.bbclass | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 meta/classes/image_overlay.bbclass

diff --git a/meta/classes/image_overlay.bbclass b/meta/classes/image_overlay.bbclass
new file mode 100644
index 0000000000..93c1ea6f9f
--- /dev/null
+++ b/meta/classes/image_overlay.bbclass
@@ -0,0 +1,24 @@
+# Enable SRC_URI for images and use it to install overlays
+
+# Let these task be executed to fetch overlay
+unset do_fetch[noexec]
+unset do_unpack[noexec]
+unset do_patch[noexec]
+
+# Add a task to install the overlay
+# (content of folders listed in OVERLAY_ROOT_DIRS is copied in rootfs)
+addtask install_overlay after do_unpack do_patch do_rootfs before do_image
+fakeroot do_install_overlay() {
+    for dir in ${OVERLAY_ROOT_DIRS}; do
+        if [ ! -d "${WORKDIR}/${dir}" ] ; then
+            bbfatal "${dir} not found, please check your OVERLAY_ROOT_DIRS and SRC_URI variables."
+        fi
+        cp -dr --no-preserve=ownership "${WORKDIR}/${dir}"/* "${IMAGE_ROOTFS}"
+    done
+}
+do_install_overlay[depends] += "virtual/fakeroot-native:do_populate_sysroot"
+do_install_overlay[dirs] = "${IMAGE_ROOTFS}"
+do_install_overlay[umask] = "022"
+do_install_overlay[vardeps] += "OVERLAY_ROOT_DIRS"
+
+SSTATETASKS += "do_install_overlay"
-- 
2.11.0




More information about the Openembedded-core mailing list