<div dir="ltr"><div>Hello,</div><div></div><div><br></div><div>I added a feature to wic. It can create a partition from a subdirectory of an image and preserves permissions, the owner and the group of the files. Here&#39;s an exemple on how I use it in a wks file to create a different partition for the home directory.</div><div><br>part /home --source rootfs --rootfs-dir=core-image-base:/home --size 500 --ondisk mmcblk --fstype=ext4 --label APPS --align 4096<br></div><div><br></div><div>Here is the patch.</div><div><br></div><div>diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py<br>index 3da7e23..580abcb 100644<br>--- a/scripts/lib/wic/partition.py<br>+++ b/scripts/lib/wic/partition.py<br>@@ -202,7 +202,7 @@ class Partition():<br>                            (self.mountpoint, self.size, self.fixed_size))<br> <br>     def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir,<br>-                       native_sysroot, real_rootfs = True):<br>+                       native_sysroot, real_rootfs = True, folder = &quot;&quot;):<br>         &quot;&quot;&quot;<br>         Prepare content for a rootfs partition i.e. create a partition<br>         and fill it from a /rootfs dir.<br>@@ -241,7 +241,7 @@ class Partition():<br> <br>         prefix = &quot;ext&quot; if self.fstype.startswith(&quot;ext&quot;) else self.fstype<br>         method = getattr(self, &quot;prepare_rootfs_&quot; + prefix)<br>-        method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo)<br>+        method(rootfs, oe_builddir, rootfs_dir + folder, native_sysroot, pseudo)<br>         self.source_file = rootfs<br> <br>         # get the rootfs size in the right units for kickstart (kB)<br>diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py<br>index aec720f..8861156 100644<br>--- a/scripts/lib/wic/plugins/source/rootfs.py<br>+++ b/scripts/lib/wic/plugins/source/rootfs.py<br>@@ -81,6 +81,13 @@ class RootfsPlugin(SourcePlugin):<br>                 raise WicError(&quot;Couldn&#39;t find --rootfs-dir=%s connection or &quot;<br>                                &quot;it is not a valid path, exiting&quot; % part.rootfs_dir)<br> <br>+        # You can select the subfolder of an image by using &quot;:&quot; to separate the image name and the sub folder name.<br>+        # i.e. --rootfs-dir=core-image-base:/home<br>+        folder = &quot;&quot;<br>+        folder_index = rootfs_dir.find(&quot;:&quot;)<br>+        if folder_index &gt;= 0:<br>+            folder = rootfs_dir[folder_index + 1:]<br>+            rootfs_dir = rootfs_dir[:folder_index]<br>         part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)<br> <br>         new_rootfs = None<br>@@ -123,4 +130,4 @@ class RootfsPlugin(SourcePlugin):<br>                     shutil.rmtree(full_path)<br> <br>         part.prepare_rootfs(cr_workdir, oe_builddir,<br>-                            new_rootfs or part.rootfs_dir, native_sysroot)<br>+                            new_rootfs or part.rootfs_dir, native_sysroot, True, folder)<br></div><div><br></div><div>I hope you will consider adding it to wic.</div><div><br></div><div>Thank you.</div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Patrick Gauvin</div></div>