public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v5 1/6] wic: extra-partition: Small code cleanup
@ 2026-01-16  9:32 Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 2/6] wic: extra-partition: Move extra file parsing to a dedicated method Adam Duskett
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Adam Duskett @ 2026-01-16  9:32 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adam Duskett

- Remove redundant charachter escaped in the src_entry regex call.
- Remove an uneeded semicolon for cls.install_task.
- we copies -> we copy

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 scripts/lib/wic/plugins/source/extra_partition.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index d370b0107e..a1d9aa9a7b 100644
--- a/scripts/lib/wic/plugins/source/extra_partition.py
+++ b/scripts/lib/wic/plugins/source/extra_partition.py
@@ -69,7 +69,7 @@ class ExtraPartitionPlugin(SourcePlugin):
 
         # list of tuples (src_name, dst_name)
         deploy_files = []
-        for src_entry in re.findall(r'[\w;\-\./\*]+', extra_files):
+        for src_entry in re.findall(r'[\w;\-./*]+', extra_files):
             if ';' in src_entry:
                 dst_entry = tuple(src_entry.split(';'))
                 if not dst_entry[0] or not dst_entry[1]:
@@ -80,7 +80,7 @@ class ExtraPartitionPlugin(SourcePlugin):
             logger.debug('Destination entry: %r', dst_entry)
             deploy_files.append(dst_entry)
 
-        cls.install_task = [];
+        cls.install_task = []
         for deploy_entry in deploy_files:
             src, dst = deploy_entry
             if '*' in src:
@@ -111,7 +111,7 @@ class ExtraPartitionPlugin(SourcePlugin):
         """
         Called to do the actual content population for a partition i.e. it
         'prepares' the partition to be incorporated into the image.
-        In this case, we copies all files listed in IMAGE_EXTRA_PARTITION_FILES variable.
+        In this case, we copy all files listed in IMAGE_EXTRA_PARTITION_FILES variable.
         """
         extradir = "%s/extra.%d" % (cr_workdir, part.lineno)
 
-- 
2.52.0



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

* [PATCH v5 2/6] wic: extra-partition: Move extra file parsing to a dedicated method
  2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
@ 2026-01-16  9:32 ` Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 3/6] wic: extra-partition: Move extra var handling " Adam Duskett
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2026-01-16  9:32 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adam Duskett

For organizational purposes, and to make the following patches
easier to follow, move the extra file parsing to a dedicated
method.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 .../lib/wic/plugins/source/extra_partition.py | 35 +++++++++++--------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index a1d9aa9a7b..aa4fb931c2 100644
--- a/scripts/lib/wic/plugins/source/extra_partition.py
+++ b/scripts/lib/wic/plugins/source/extra_partition.py
@@ -37,20 +37,11 @@ class ExtraPartitionPlugin(SourcePlugin):
     image_extra_partition_files_var_name = 'IMAGE_EXTRA_PARTITION_FILES'
 
     @classmethod
-    def do_configure_partition(cls, part, source_params, cr, cr_workdir,
-                             oe_builddir, bootimg_dir, kernel_dir,
-                             native_sysroot):
+    def _parse_extra_files(cls, part, kernel_dir):
         """
-        Called before do_prepare_partition(), list the files to copy
+        Parse the files of which to copy.
         """
-        extradir = "%s/extra.%d" % (cr_workdir, part.lineno)
-        install_cmd = "install -d %s" % extradir
-        exec_cmd(install_cmd)
-
-        if not kernel_dir:
-            kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
-            if not kernel_dir:
-                raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
+        deploy_files = []
 
         extra_files = None
         for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), ("_part-name-%s", part.part_name), (None, None)):
@@ -66,9 +57,6 @@ class ExtraPartitionPlugin(SourcePlugin):
             raise WicError('No extra files defined, %s unset for entry #%d' % (cls.image_extra_partition_files_var_name, part.lineno))
 
         logger.info('Extra files: %s', extra_files)
-
-        # list of tuples (src_name, dst_name)
-        deploy_files = []
         for src_entry in re.findall(r'[\w;\-./*]+', extra_files):
             if ';' in src_entry:
                 dst_entry = tuple(src_entry.split(';'))
@@ -103,6 +91,23 @@ class ExtraPartitionPlugin(SourcePlugin):
             else:
                 cls.install_task.append((src, dst))
 
+    @classmethod
+    def do_configure_partition(cls, part, source_params, cr, cr_workdir,
+                             oe_builddir, bootimg_dir, kernel_dir,
+                             native_sysroot):
+        """
+        Called before do_prepare_partition(), list the files to copy
+        """
+        extradir = "%s/extra.%d" % (cr_workdir, part.lineno)
+        install_cmd = "install -d %s" % extradir
+        exec_cmd(install_cmd)
+
+        if not kernel_dir:
+            kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
+            if not kernel_dir:
+                raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
+
+        cls._parse_extra_files(part, kernel_dir)
 
     @classmethod
     def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
-- 
2.52.0



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

* [PATCH v5 3/6] wic: extra-partition: Move extra var handling to a dedicated method
  2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 2/6] wic: extra-partition: Move extra file parsing to a dedicated method Adam Duskett
@ 2026-01-16  9:32 ` Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 4/6] wic: extra-partition: Rename install_task to extra_files_task Adam Duskett
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2026-01-16  9:32 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adam Duskett

For organizational purposes, and to make the following patches
easier to follow, move the extra file parsing to a dedicated
method.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 .../lib/wic/plugins/source/extra_partition.py | 25 +++++++++++--------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index aa4fb931c2..05b0ace361 100644
--- a/scripts/lib/wic/plugins/source/extra_partition.py
+++ b/scripts/lib/wic/plugins/source/extra_partition.py
@@ -36,6 +36,20 @@ class ExtraPartitionPlugin(SourcePlugin):
     name = 'extra_partition'
     image_extra_partition_files_var_name = 'IMAGE_EXTRA_PARTITION_FILES'
 
+    @classmethod
+    def _get_extra_vars(cls, part, var_name):
+        """Get extra partition directory or file variables"""
+        extra_vars = None
+        for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), ("_part-name-%s", part.part_name), (None, None)):
+            var = ""
+            if fmt:
+                var = fmt % id
+            thing = var_name + var
+            extra_vars = get_bitbake_var(thing)
+            if extra_vars is not None:
+                break
+        return extra_vars
+
     @classmethod
     def _parse_extra_files(cls, part, kernel_dir):
         """
@@ -43,16 +57,7 @@ class ExtraPartitionPlugin(SourcePlugin):
         """
         deploy_files = []
 
-        extra_files = None
-        for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), ("_part-name-%s", part.part_name), (None, None)):
-            if fmt:
-                var = fmt % id
-            else:
-                var = ""
-            extra_files = get_bitbake_var(cls.image_extra_partition_files_var_name + var)
-            if extra_files is not None:
-                break
-
+        extra_files = cls._get_extra_vars(part, cls.image_extra_partition_files_var_name)
         if extra_files is None:
             raise WicError('No extra files defined, %s unset for entry #%d' % (cls.image_extra_partition_files_var_name, part.lineno))
 
-- 
2.52.0



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

* [PATCH v5 4/6] wic: extra-partition: Rename install_task to extra_files_task
  2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 2/6] wic: extra-partition: Move extra file parsing to a dedicated method Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 3/6] wic: extra-partition: Move extra var handling " Adam Duskett
@ 2026-01-16  9:32 ` Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 5/6] wic: extra-partitions: move extra-files WicError to do_prepare_partition Adam Duskett
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2026-01-16  9:32 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adam Duskett

Rename install_task to extra_files_task for clarity

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
v1 -> v2: If the list is blank, print a warning instead of an info.
v2 -> v4: Raise an error in do_prepare_partition instead of making
          extra files optional. Extend error message.

 scripts/lib/wic/plugins/source/extra_partition.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index 05b0ace361..25aab06c52 100644
--- a/scripts/lib/wic/plugins/source/extra_partition.py
+++ b/scripts/lib/wic/plugins/source/extra_partition.py
@@ -73,7 +73,7 @@ class ExtraPartitionPlugin(SourcePlugin):
             logger.debug('Destination entry: %r', dst_entry)
             deploy_files.append(dst_entry)
 
-        cls.install_task = []
+        cls.extra_files_task = []
         for deploy_entry in deploy_files:
             src, dst = deploy_entry
             if '*' in src:
@@ -92,9 +92,9 @@ class ExtraPartitionPlugin(SourcePlugin):
                 for entry in srcs:
                     src = os.path.relpath(entry, kernel_dir)
                     entry_dst_name = entry_name_fn(entry)
-                    cls.install_task.append((src, entry_dst_name))
+                    cls.extra_files_task.append((src, entry_dst_name))
             else:
-                cls.install_task.append((src, dst))
+                cls.extra_files_task.append((src, dst))
 
     @classmethod
     def do_configure_partition(cls, part, source_params, cr, cr_workdir,
@@ -130,7 +130,7 @@ class ExtraPartitionPlugin(SourcePlugin):
             if not kernel_dir:
                 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
 
-        for task in cls.install_task:
+        for task in cls.extra_files_task:
             src_path, dst_path = task
             logger.debug('Install %s as %s', src_path, dst_path)
             install_cmd = "install -m 0644 -D %s %s" \
-- 
2.52.0



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

* [PATCH v5 5/6] wic: extra-partitions: move extra-files WicError to do_prepare_partition
  2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
                   ` (2 preceding siblings ...)
  2026-01-16  9:32 ` [PATCH v5 4/6] wic: extra-partition: Rename install_task to extra_files_task Adam Duskett
@ 2026-01-16  9:32 ` Adam Duskett
  2026-01-16  9:32 ` [PATCH v5 6/6] wic: extra-partitions: extend to support extra directories Adam Duskett
  2026-01-19  8:55 ` [OE-core] [PATCH v5 1/6] wic: extra-partition: Small code cleanup Antonin Godard
  5 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2026-01-16  9:32 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adam Duskett

For organizational purposes, move the raised WicError if extra files isn't
provided by a user to the do_prepare_partition method and rewrite the message
to be more clear if a user wishes to create an empty partition.

The original error is changed to a warning in the event a user has a typo
in the variable. For example:

IMAGE_EXTRA_PARTITION_FILES_label-fooo = "bar.conf"
part --source extra-partition --fstype=ext4 --label foo

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
v1 -> v2: If the list is blank, print a warning instead of an info.

v2 -> v4: Raise an error in do_prepare_partition instead of making
          extra files optional. Extend error message.

v4 -> v5: Chagne logger.warning to logger.info

 scripts/lib/wic/plugins/source/extra_partition.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index 25aab06c52..327bc2b8c3 100644
--- a/scripts/lib/wic/plugins/source/extra_partition.py
+++ b/scripts/lib/wic/plugins/source/extra_partition.py
@@ -55,11 +55,13 @@ class ExtraPartitionPlugin(SourcePlugin):
         """
         Parse the files of which to copy.
         """
+        cls.extra_files_task = []
         deploy_files = []
 
         extra_files = cls._get_extra_vars(part, cls.image_extra_partition_files_var_name)
         if extra_files is None:
-            raise WicError('No extra files defined, %s unset for entry #%d' % (cls.image_extra_partition_files_var_name, part.lineno))
+            logger.info('No extra files defined, %s unset for entry #%d' % (cls.image_extra_partition_files_var_name, part.lineno))
+            return
 
         logger.info('Extra files: %s', extra_files)
         for src_entry in re.findall(r'[\w;\-./*]+', extra_files):
@@ -73,7 +75,6 @@ class ExtraPartitionPlugin(SourcePlugin):
             logger.debug('Destination entry: %r', dst_entry)
             deploy_files.append(dst_entry)
 
-        cls.extra_files_task = []
         for deploy_entry in deploy_files:
             src, dst = deploy_entry
             if '*' in src:
@@ -125,6 +126,12 @@ class ExtraPartitionPlugin(SourcePlugin):
         """
         extradir = "%s/extra.%d" % (cr_workdir, part.lineno)
 
+        if not cls.extra_files_task:
+            raise WicError("Entry #%d does not have a corresponding %s variable set!"
+                           "If you wish to create an empty partition, remove "
+                           "--source extra-partition from the wks file"
+                           % (part.lineno, cls.image_extra_partition_files_var_name))
+
         if not kernel_dir:
             kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
             if not kernel_dir:
-- 
2.52.0



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

* [PATCH v5 6/6] wic: extra-partitions: extend to support extra directories
  2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
                   ` (3 preceding siblings ...)
  2026-01-16  9:32 ` [PATCH v5 5/6] wic: extra-partitions: move extra-files WicError to do_prepare_partition Adam Duskett
@ 2026-01-16  9:32 ` Adam Duskett
  2026-01-16 10:39   ` [OE-core] " Pierre-loup GOSSE
  2026-01-19  8:55 ` [OE-core] [PATCH v5 1/6] wic: extra-partition: Small code cleanup Antonin Godard
  5 siblings, 1 reply; 8+ messages in thread
From: Adam Duskett @ 2026-01-16  9:32 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adam Duskett

  - Add the ability to define a space-delminated list of directories
    to create on the extra partition.

  - Extend the fail condition to fail if both extra directories and
    extra files is not defined.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
v1 -> v2: Make the list space deliminated instead of semicolon deliminated.
          If the list is blank, print a warning instead of an info.

v2 -> v3: Remove uneeded logic in _parse_extra_directories

v3 -> v4: Rework to error if extra directories and files are not set.

v4 -> v5: Fix double image_extra_partition_dirs_var_name typo 
          Change logger.debug print for consistency
          Reword plugin description for clarity
          Add an extra line in the plugin description before the WICVARS
          Remove extra space between _get_extra_vars and _parse_extra_directories

 meta/lib/oeqa/selftest/cases/wic.py           | 11 ++++
 .../lib/wic/plugins/source/extra_partition.py | 60 +++++++++++++++----
 2 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index d7a9b14658..83072deaae 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1657,10 +1657,14 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
     def test_extra_partition_plugin(self):
         """Test extra partition plugin"""
         config = dedent("""\
+        IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo = "/test1 /test2/test3"
+        IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "/test1 /test2/test3"
         IMAGE_EXTRA_PARTITION_FILES_label-foo = "bar.conf;foo.conf"
         IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "bar.conf;foobar.conf"
         IMAGE_EXTRA_PARTITION_FILES = "foo/*"
         WICVARS:append = "\
+            IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo \
+            IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
             IMAGE_EXTRA_PARTITION_FILES_label-foo \
             IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
         "
@@ -1692,6 +1696,13 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
                 result = runCmd("wic ls %s | wc -l" % wicimg)
                 self.assertEqual('4', result.output, msg="Expect 3 partitions, not %s" % result.output)
 
+                for part, extra_dir in enumerate(["test1", "test2"]):
+                    result = runCmd("wic ls %s:%d | grep -q \"%s\"" % (wicimg, part + 1, extra_dir))
+                    self.assertEqual(0, result.status, msg="Directory '%s' not found in the partition #%d" % (extra_dir, part))
+
+                    result = runCmd("wic ls %s:%d/test2 | grep -q \"test3\"" % (wicimg, part + 1))
+                    self.assertEqual(0, result.status, msg="Directory test2/test3 not found in the partition #%d" % part)
+
                 for part, file in enumerate(["foo.conf", "foobar.conf", "bar.conf"]):
                     result = runCmd("wic ls %s:%d | grep -q \"%s\"" % (wicimg, part + 1, file))
                     self.assertEqual(0, result.status, msg="File '%s' not found in the partition #%d" % (file, part))
diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index 327bc2b8c3..3be7aed374 100644
--- a/scripts/lib/wic/plugins/source/extra_partition.py
+++ b/scripts/lib/wic/plugins/source/extra_partition.py
@@ -12,21 +12,31 @@ logger = logging.getLogger('wic')
 
 class ExtraPartitionPlugin(SourcePlugin):
     """
-    Populates an extra partition with files listed in the IMAGE_EXTRA_PARTITION_FILES
-    BitBake variable. Files should be deployed to the DEPLOY_DIR_IMAGE directory.
+    Populates an extra partition with:
+    - Files listed in the IMAGE_EXTRA_PARTITION_FILES BitBake variable. Files should be deployed to
+      the DEPLOY_DIR_IMAGE directory.
+    - Empty directories listed in the IMAGE_EXTRA_PARTITION_DIRECTORIES Bitbake variable.
+      Directories are created automatically.
 
     The plugin supports:
     - Glob pattern matching for file selection.
     - File renaming.
     - Suffixes to specify the target partition (by label, UUID, or partname),
       enabling multiple extra partitions to coexist.
+    - Extra directories.
 
     For example:
 
+        IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo = "/foo /bar/baz"
+        IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "/foo /bar/baz"
+
         IMAGE_EXTRA_PARTITION_FILES_label-foo = "bar.conf;foo.conf"
         IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "bar.conf;foobar.conf"
         IMAGE_EXTRA_PARTITION_FILES = "foo/*"
+
         WICVARS:append = "\
+            IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo \
+            IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
             IMAGE_EXTRA_PARTITION_FILES_label-foo \
             IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
         "
@@ -34,6 +44,7 @@ class ExtraPartitionPlugin(SourcePlugin):
     """
 
     name = 'extra_partition'
+    image_extra_partition_dirs_var_name = 'IMAGE_EXTRA_PARTITION_DIRECTORIES'
     image_extra_partition_files_var_name = 'IMAGE_EXTRA_PARTITION_FILES'
 
     @classmethod
@@ -50,6 +61,22 @@ class ExtraPartitionPlugin(SourcePlugin):
                 break
         return extra_vars
 
+    @classmethod
+    def _parse_extra_directories(cls, part):
+        """
+        Parse the directories of which to copy.
+        """
+        cls.extra_dirs_task = []
+
+        extra_dirs = cls._get_extra_vars(part, cls.image_extra_partition_dirs_var_name)
+        if extra_dirs is None:
+            logger.info('No extra directories defined, %s unset for entry #%d' % (cls.image_extra_partition_dirs_var_name, part.lineno))
+            return
+
+        logger.info('Extra dirs: %s', extra_dirs)
+        for src_entry in extra_dirs.strip().split(' '):
+            cls.extra_dirs_task.append(src_entry)
+
     @classmethod
     def _parse_extra_files(cls, part, kernel_dir):
         """
@@ -113,6 +140,7 @@ class ExtraPartitionPlugin(SourcePlugin):
             if not kernel_dir:
                 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
 
+        cls._parse_extra_directories(part)
         cls._parse_extra_files(part, kernel_dir)
 
     @classmethod
@@ -126,24 +154,32 @@ class ExtraPartitionPlugin(SourcePlugin):
         """
         extradir = "%s/extra.%d" % (cr_workdir, part.lineno)
 
-        if not cls.extra_files_task:
-            raise WicError("Entry #%d does not have a corresponding %s variable set!"
+        if not cls.extra_dirs_task and not cls.extra_files_task:
+            raise WicError("Entry #%d does not have a corresponding %s or %s variable set!"
                            "If you wish to create an empty partition, remove "
                            "--source extra-partition from the wks file"
-                           % (part.lineno, cls.image_extra_partition_files_var_name))
+                           % (part.lineno, cls.image_extra_partition_dirs_var_name,
+                              cls.image_extra_partition_files_var_name))
 
         if not kernel_dir:
             kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
             if not kernel_dir:
                 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
 
-        for task in cls.extra_files_task:
-            src_path, dst_path = task
-            logger.debug('Install %s as %s', src_path, dst_path)
-            install_cmd = "install -m 0644 -D %s %s" \
-                          % (os.path.join(kernel_dir, src_path),
-                             os.path.join(extradir, dst_path))
-            exec_cmd(install_cmd)
+        if cls.extra_dirs_task:
+            for task in cls.extra_dirs_task:
+                logger.debug("Create directory %s" % task)
+                mkdir_cmd = "mkdir -p %s/%s" % (extradir, task)
+                exec_cmd(mkdir_cmd)
+
+        if cls.extra_files_task:
+            for task in cls.extra_files_task:
+                src_path, dst_path = task
+                logger.debug('Install %s as %s', src_path, dst_path)
+                install_cmd = "install -m 0644 -D %s %s" \
+                              % (os.path.join(kernel_dir, src_path),
+                                 os.path.join(extradir, dst_path))
+                exec_cmd(install_cmd)
 
         logger.debug('Prepare extra partition using rootfs in %s', extradir)
         part.prepare_rootfs(cr_workdir, oe_builddir, extradir,
-- 
2.52.0



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

* Re: [OE-core] [PATCH v5 6/6] wic: extra-partitions: extend to support extra directories
  2026-01-16  9:32 ` [PATCH v5 6/6] wic: extra-partitions: extend to support extra directories Adam Duskett
@ 2026-01-16 10:39   ` Pierre-loup GOSSE
  0 siblings, 0 replies; 8+ messages in thread
From: Pierre-loup GOSSE @ 2026-01-16 10:39 UTC (permalink / raw)
  To: adam.duskett; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 9977 bytes --]

Reviewed-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>

Thanks,

Pierre-Loup

On Fri, Jan 16, 2026 at 10:32 AM Adam Duskett via lists.openembedded.org
<adam.duskett=amarulasolutions.com@lists.openembedded.org> wrote:

>   - Add the ability to define a space-delminated list of directories
>     to create on the extra partition.
>
>   - Extend the fail condition to fail if both extra directories and
>     extra files is not defined.
>
> Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
> ---
> v1 -> v2: Make the list space deliminated instead of semicolon deliminated.
>           If the list is blank, print a warning instead of an info.
>
> v2 -> v3: Remove uneeded logic in _parse_extra_directories
>
> v3 -> v4: Rework to error if extra directories and files are not set.
>
> v4 -> v5: Fix double image_extra_partition_dirs_var_name typo
>           Change logger.debug print for consistency
>           Reword plugin description for clarity
>           Add an extra line in the plugin description before the WICVARS
>           Remove extra space between _get_extra_vars and
> _parse_extra_directories
>
>  meta/lib/oeqa/selftest/cases/wic.py           | 11 ++++
>  .../lib/wic/plugins/source/extra_partition.py | 60 +++++++++++++++----
>  2 files changed, 59 insertions(+), 12 deletions(-)
>
> diff --git a/meta/lib/oeqa/selftest/cases/wic.py
> b/meta/lib/oeqa/selftest/cases/wic.py
> index d7a9b14658..83072deaae 100644
> --- a/meta/lib/oeqa/selftest/cases/wic.py
> +++ b/meta/lib/oeqa/selftest/cases/wic.py
> @@ -1657,10 +1657,14 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
>      def test_extra_partition_plugin(self):
>          """Test extra partition plugin"""
>          config = dedent("""\
> +        IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo = "/test1
> /test2/test3"
> +
> IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d
> = "/test1 /test2/test3"
>          IMAGE_EXTRA_PARTITION_FILES_label-foo = "bar.conf;foo.conf"
>
>  IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d =
> "bar.conf;foobar.conf"
>          IMAGE_EXTRA_PARTITION_FILES = "foo/*"
>          WICVARS:append = "\
> +            IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo \
> +
> IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d
> \
>              IMAGE_EXTRA_PARTITION_FILES_label-foo \
>
>  IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
>          "
> @@ -1692,6 +1696,13 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
>                  result = runCmd("wic ls %s | wc -l" % wicimg)
>                  self.assertEqual('4', result.output, msg="Expect 3
> partitions, not %s" % result.output)
>
> +                for part, extra_dir in enumerate(["test1", "test2"]):
> +                    result = runCmd("wic ls %s:%d | grep -q \"%s\"" %
> (wicimg, part + 1, extra_dir))
> +                    self.assertEqual(0, result.status, msg="Directory
> '%s' not found in the partition #%d" % (extra_dir, part))
> +
> +                    result = runCmd("wic ls %s:%d/test2 | grep -q
> \"test3\"" % (wicimg, part + 1))
> +                    self.assertEqual(0, result.status, msg="Directory
> test2/test3 not found in the partition #%d" % part)
> +
>                  for part, file in enumerate(["foo.conf", "foobar.conf",
> "bar.conf"]):
>                      result = runCmd("wic ls %s:%d | grep -q \"%s\"" %
> (wicimg, part + 1, file))
>                      self.assertEqual(0, result.status, msg="File '%s' not
> found in the partition #%d" % (file, part))
> diff --git a/scripts/lib/wic/plugins/source/extra_partition.py
> b/scripts/lib/wic/plugins/source/extra_partition.py
> index 327bc2b8c3..3be7aed374 100644
> --- a/scripts/lib/wic/plugins/source/extra_partition.py
> +++ b/scripts/lib/wic/plugins/source/extra_partition.py
> @@ -12,21 +12,31 @@ logger = logging.getLogger('wic')
>
>  class ExtraPartitionPlugin(SourcePlugin):
>      """
> -    Populates an extra partition with files listed in the
> IMAGE_EXTRA_PARTITION_FILES
> -    BitBake variable. Files should be deployed to the DEPLOY_DIR_IMAGE
> directory.
> +    Populates an extra partition with:
> +    - Files listed in the IMAGE_EXTRA_PARTITION_FILES BitBake variable.
> Files should be deployed to
> +      the DEPLOY_DIR_IMAGE directory.
> +    - Empty directories listed in the IMAGE_EXTRA_PARTITION_DIRECTORIES
> Bitbake variable.
> +      Directories are created automatically.
>
>      The plugin supports:
>      - Glob pattern matching for file selection.
>      - File renaming.
>      - Suffixes to specify the target partition (by label, UUID, or
> partname),
>        enabling multiple extra partitions to coexist.
> +    - Extra directories.
>
>      For example:
>
> +        IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo = "/foo /bar/baz"
> +
> IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d
> = "/foo /bar/baz"
> +
>          IMAGE_EXTRA_PARTITION_FILES_label-foo = "bar.conf;foo.conf"
>
>  IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d =
> "bar.conf;foobar.conf"
>          IMAGE_EXTRA_PARTITION_FILES = "foo/*"
> +
>          WICVARS:append = "\
> +            IMAGE_EXTRA_PARTITION_DIRECTORIES_label-foo \
> +
> IMAGE_EXTRA_PARTITION_DIRECTORIES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d
> \
>              IMAGE_EXTRA_PARTITION_FILES_label-foo \
>
>  IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
>          "
> @@ -34,6 +44,7 @@ class ExtraPartitionPlugin(SourcePlugin):
>      """
>
>      name = 'extra_partition'
> +    image_extra_partition_dirs_var_name =
> 'IMAGE_EXTRA_PARTITION_DIRECTORIES'
>      image_extra_partition_files_var_name = 'IMAGE_EXTRA_PARTITION_FILES'
>
>      @classmethod
> @@ -50,6 +61,22 @@ class ExtraPartitionPlugin(SourcePlugin):
>                  break
>          return extra_vars
>
> +    @classmethod
> +    def _parse_extra_directories(cls, part):
> +        """
> +        Parse the directories of which to copy.
> +        """
> +        cls.extra_dirs_task = []
> +
> +        extra_dirs = cls._get_extra_vars(part,
> cls.image_extra_partition_dirs_var_name)
> +        if extra_dirs is None:
> +            logger.info('No extra directories defined, %s unset for
> entry #%d' % (cls.image_extra_partition_dirs_var_name, part.lineno))
> +            return
> +
> +        logger.info('Extra dirs: %s', extra_dirs)
> +        for src_entry in extra_dirs.strip().split(' '):
> +            cls.extra_dirs_task.append(src_entry)
> +
>      @classmethod
>      def _parse_extra_files(cls, part, kernel_dir):
>          """
> @@ -113,6 +140,7 @@ class ExtraPartitionPlugin(SourcePlugin):
>              if not kernel_dir:
>                  raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
>
> +        cls._parse_extra_directories(part)
>          cls._parse_extra_files(part, kernel_dir)
>
>      @classmethod
> @@ -126,24 +154,32 @@ class ExtraPartitionPlugin(SourcePlugin):
>          """
>          extradir = "%s/extra.%d" % (cr_workdir, part.lineno)
>
> -        if not cls.extra_files_task:
> -            raise WicError("Entry #%d does not have a corresponding %s
> variable set!"
> +        if not cls.extra_dirs_task and not cls.extra_files_task:
> +            raise WicError("Entry #%d does not have a corresponding %s or
> %s variable set!"
>                             "If you wish to create an empty partition,
> remove "
>                             "--source extra-partition from the wks file"
> -                           % (part.lineno,
> cls.image_extra_partition_files_var_name))
> +                           % (part.lineno,
> cls.image_extra_partition_dirs_var_name,
> +                              cls.image_extra_partition_files_var_name))
>
>          if not kernel_dir:
>              kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
>              if not kernel_dir:
>                  raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
>
> -        for task in cls.extra_files_task:
> -            src_path, dst_path = task
> -            logger.debug('Install %s as %s', src_path, dst_path)
> -            install_cmd = "install -m 0644 -D %s %s" \
> -                          % (os.path.join(kernel_dir, src_path),
> -                             os.path.join(extradir, dst_path))
> -            exec_cmd(install_cmd)
> +        if cls.extra_dirs_task:
> +            for task in cls.extra_dirs_task:
> +                logger.debug("Create directory %s" % task)
> +                mkdir_cmd = "mkdir -p %s/%s" % (extradir, task)
> +                exec_cmd(mkdir_cmd)
> +
> +        if cls.extra_files_task:
> +            for task in cls.extra_files_task:
> +                src_path, dst_path = task
> +                logger.debug('Install %s as %s', src_path, dst_path)
> +                install_cmd = "install -m 0644 -D %s %s" \
> +                              % (os.path.join(kernel_dir, src_path),
> +                                 os.path.join(extradir, dst_path))
> +                exec_cmd(install_cmd)
>
>          logger.debug('Prepare extra partition using rootfs in %s',
> extradir)
>          part.prepare_rootfs(cr_workdir, oe_builddir, extradir,
> --
> 2.52.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Liens: Vous recevez tous les messages envoyés à ce groupe.
> Voir/Répondre en ligne (#229536):
> https://lists.openembedded.org/g/openembedded-core/message/229536
> Sujets: https://lists.openembedded.org/mt/117295121/9955716
> Propriétaire du groupe: openembedded-core+owner@lists.openembedded.org
> Se désabonner: https://lists.openembedded.org/g/openembedded-core/unsub [
> pierre-loup.gosse@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

[-- Attachment #2: Type: text/html, Size: 12905 bytes --]

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

* Re: [OE-core] [PATCH v5 1/6] wic: extra-partition: Small code cleanup
  2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
                   ` (4 preceding siblings ...)
  2026-01-16  9:32 ` [PATCH v5 6/6] wic: extra-partitions: extend to support extra directories Adam Duskett
@ 2026-01-19  8:55 ` Antonin Godard
  5 siblings, 0 replies; 8+ messages in thread
From: Antonin Godard @ 2026-01-19  8:55 UTC (permalink / raw)
  To: adam.duskett, openembedded-core

Hi,

Sorry, this conflicts with another series from Louis right now which has passed
testing:
https://lore.kernel.org/r/20260112-extrafiles-v2-0-67f0f6c37c4e@non.se.com

I cannot apply your patches on top for now. As it's still undecided whether
these will make it to master, you can wait a while before rebasing your
series, or rebase now if you want me to run your patches in our test infra.

Regards,
Antonin

-- 
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



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

end of thread, other threads:[~2026-01-19  8:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-16  9:32 [PATCH v5 1/6] wic: extra-partition: Small code cleanup Adam Duskett
2026-01-16  9:32 ` [PATCH v5 2/6] wic: extra-partition: Move extra file parsing to a dedicated method Adam Duskett
2026-01-16  9:32 ` [PATCH v5 3/6] wic: extra-partition: Move extra var handling " Adam Duskett
2026-01-16  9:32 ` [PATCH v5 4/6] wic: extra-partition: Rename install_task to extra_files_task Adam Duskett
2026-01-16  9:32 ` [PATCH v5 5/6] wic: extra-partitions: move extra-files WicError to do_prepare_partition Adam Duskett
2026-01-16  9:32 ` [PATCH v5 6/6] wic: extra-partitions: extend to support extra directories Adam Duskett
2026-01-16 10:39   ` [OE-core] " Pierre-loup GOSSE
2026-01-19  8:55 ` [OE-core] [PATCH v5 1/6] wic: extra-partition: Small code cleanup Antonin Godard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox