Hi Adam,
Thanks for this v4 patch series.
- 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_dirs_var_name))
> + % (part.lineno,
> cls.image_extra_partition_dirs_var_name,
> + cls.image_extra_partition_dirs_var_name))
There is a typo, one of the printed variables should be
image_extra_partition_files_var_name.
+ if cls.extra_dirs_task:
> + for task in cls.extra_dirs_task:
> + mkdir_cmd = "mkdir -p %s/%s" % (extradir, task)
> + logger.debug(mkdir_cmd)
> + exec_cmd(mkdir_cmd)
> +
To maintain consistency with the extra files log, instead of printing the
mkdir command, you could print something like:
logger.debug("Create directory %s" % task)
@@ -13,20 +13,29 @@ 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.
> + BitBake variable or directories listed in the
> IMAGE_EXTRA_PARTITION_DIRECTORIES Bitbake variable.
> +
> + Directories are created automatically.
> + Files should be deployed to the DEPLOY_DIR_IMAGE directory.
>
I think the description should be reworded to avoid the confusion that the
plugin copies directories from DEPLOY_DIR_IMAGE like the files. Here is my
suggestion:
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.
What do you think ?
And just two minor points:
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 \
>
I would add an extra line in the plugin description before the WICVARS,
just as you did to separate the directories and files variables.
@@ -50,6 +60,23 @@ class ExtraPartitionPlugin(SourcePlugin):
> break
> return extra_vars
>
> +
> + @classmethod
> + def _parse_extra_directories(cls, part):
> + """
> + Parse the directories of which to copy.
> + """
>
There is an extra line between the functions.
Thanks for your compromise, I appreciate it.
Pierre-Loup,
On Thu, Jan 15, 2026 at 11:15 AM Adam Duskett via lists.openembedded.org
<[email protected]> 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 <[email protected]>
> ---
> 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.
>
> meta/lib/oeqa/selftest/cases/wic.py | 11 +++++
> .../lib/wic/plugins/source/extra_partition.py | 43 +++++++++++++++++--
> 2 files changed, 50 insertions(+), 4 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 62a7b4b1d3..185fcab585 100644
> --- a/scripts/lib/wic/plugins/source/extra_partition.py
> +++ b/scripts/lib/wic/plugins/source/extra_partition.py
> @@ -13,20 +13,29 @@ 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.
> + BitBake variable or directories listed in the
> IMAGE_EXTRA_PARTITION_DIRECTORIES Bitbake variable.
> +
> + Directories are created automatically.
> + Files should be deployed to the DEPLOY_DIR_IMAGE directory.
>
> 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 +43,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 +60,23 @@ 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.warning('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,17 +154,24 @@ 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_dirs_var_name))
> + % (part.lineno,
> cls.image_extra_partition_dirs_var_name,
> + cls.image_extra_partition_dirs_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")
>
> + if cls.extra_dirs_task:
> + for task in cls.extra_dirs_task:
> + mkdir_cmd = "mkdir -p %s/%s" % (extradir, task)
> + logger.debug(mkdir_cmd)
> + exec_cmd(mkdir_cmd)
> +
> if cls.extra_files_task:
> for task in cls.extra_files_task:
> src_path, dst_path = task
> --
> 2.52.0
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#229416):
https://lists.openembedded.org/g/openembedded-core/message/229416
Mute This Topic: https://lists.openembedded.org/mt/117276849/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-