All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/1] Permit to install files from an overlay in images recipes
@ 2017-03-14 16:58 Geoffrey Levillain
  2017-03-14 16:58 ` [PATCH v3 1/1] image_overlay.bbclass: Add possibility to install overlays to image Geoffrey Levillain
  0 siblings, 1 reply; 2+ messages in thread
From: Geoffrey Levillain @ 2017-03-14 16:58 UTC (permalink / raw)
  To: openembedded-core

Hi, 

This patch introduce a capability to install overlays into image
after fetching them. There is actually a need to add image-specific
configurations files into image recipes, and this patch is a way
to standardize this process as well as simplify it by fetching and
install overlays when image_overlay is inherited.

It copy every files in directories listed in OVERLAY_ROOT_DIRS into
IMAGE_ROOTFS directory after execution of do_rootfs. 

This implementation use ROOTFS_POSTPROCESS_COMMAND instead of using
a task like the previous version.

Geoffrey Levillain (1):
  image_overlay.bbclass: Add possibility to install overlays to image

 meta/classes/image_overlay.bbclass | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 meta/classes/image_overlay.bbclass

Regards,
Geoffrey Levillain



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v3 1/1] image_overlay.bbclass: Add possibility to install overlays to image
  2017-03-14 16:58 [PATCH v3 0/1] Permit to install files from an overlay in images recipes Geoffrey Levillain
@ 2017-03-14 16:58 ` Geoffrey Levillain
  0 siblings, 0 replies; 2+ messages in thread
From: Geoffrey Levillain @ 2017-03-14 16:58 UTC (permalink / raw)
  To: openembedded-core

There is often a need to add configuration files specific to an image,
with this class it's possible to fetch and install files from the
image recipe.

Fetching is set as noexec for images, but there is a need to fetch files
here. This class permit to fetch and unpack without the use of these
tasks in order to get your image-specific overlays to install.

This class must be inherited beside an image class (such as core-image).

Small example of usage in image recipe as it help to understand :
----------------------------------------------------------
FILESEXTRAPATHS_prepend := "${THISDIR}:"

DESCRIPTION = "An overlayable image"

OVERLAY_SRC_URI = "file://overlay.tar.gz file://overlay2"

OVERLAY_ROOT_DIRS = "overlay1 overlay2"

inherit core-image image_overlay
----------------------------------------------------------
(Where file://overlay2 refer to a directory, and overlay.tar.gz
cointain a directory named overlay1)

Signed-off-by: Geoffrey Levillain <geoffrey.levillain@smile.fr>
---
 meta/classes/image_overlay.bbclass | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 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..ade2911410
--- /dev/null
+++ b/meta/classes/image_overlay.bbclass
@@ -0,0 +1,38 @@
+# When inherited by an image recipe, this class provide simple way to
+# put configuration files into rootfs.
+
+ROOTFS_POSTPROCESS_COMMAND_append = "install_overlay ; "
+
+python install_overlay() {
+    """Fetch and install overlays into rootfs
+    
+       Fetch overlays from OVERLAY_SRC_URI and copy the files
+       inside the folders listed in OVERLAY_ROOT_DIRS to rootfs.
+       
+       OVERLAY_ROOT_DIRS contains only names of folders, no path.
+       
+       OVERLAY_SRC_URI must be used to get dirs in OVERLAY_ROOT_DIRS
+       imported to the workdir, it's the same as SRC_URI, so it's 
+       possible to use distant repository, tarballs, etc.
+    """
+    workdir = d.getVar('WORKDIR', True)
+    rootfs = d.getVar('IMAGE_ROOTFS', True)
+    srcs = (d.getVar("OVERLAY_SRC_URI", True) or "").split()
+    overlay_root_dirs = (d.getVar('OVERLAY_ROOT_DIRS', True) or '').split()
+
+    fetcher = bb.fetch2.Fetch(srcs, d)
+    fetcher.download()
+    fetcher.unpack(workdir)
+
+    for i in range(len(overlay_root_dirs)):
+        fullpath = os.path.join(workdir, overlay_root_dirs[i])
+        
+        if not os.path.isdir(fullpath):
+            bb.fatal(fullpath +
+                     " : directory not found, please check your"\
+                     " OVERLAY_ROOT_DIRS and OVERLAY_SRC_URI variables.")
+            break
+        os.system("cp -dr " + os.path.join(fullpath, "*") + " " + rootfs)
+}
+
+do_rootfs[vardeps] += "OVERLAY_ROOT_DIRS OVERLAY_SRC_URI"
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-14 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14 16:58 [PATCH v3 0/1] Permit to install files from an overlay in images recipes Geoffrey Levillain
2017-03-14 16:58 ` [PATCH v3 1/1] image_overlay.bbclass: Add possibility to install overlays to image Geoffrey Levillain

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.