diff mbox series

[5/6] wic: extra-partitions: Make extra-files optional

Message ID 20260113144314.3563680-5-adam.duskett@amarulasolutions.com
State New
Headers show
Series [1/6] wic: extra-partition: Small code cleanup | expand

Commit Message

Adam Duskett Jan. 13, 2026, 2:43 p.m. UTC
There are many use cases where a user may need a blank partition of a given
size and format with no extra files added. Such as an empty data partition.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 meta/lib/oeqa/selftest/cases/wic.py           | 10 ++++++++++
 .../lib/wic/plugins/source/extra_partition.py | 20 ++++++++++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

Comments

Pierre-loup GOSSE Jan. 13, 2026, 3:13 p.m. UTC | #1
Hi Adam,

Thanks for your contribution to the plugin.

> 
> There are many use cases where a user may need a blank partition of a
> given
> size and format with no extra files added. Such as an empty data
> partition.
> 

A blank partition can already be created without the extra-partition plugin.

Personally, I use the following example line in my WKS file:

part --fstype=ext4 --label data --fixed-size 500M

This command creates a blank 500MB partition with an ext4 filesystem.

In my opinion, the extra plugin should always requires files, similar to the bootimg partition plugin (on which the extra partition plugin is based).

Pierre-Loup,
Adam Duskett Jan. 14, 2026, 9:26 a.m. UTC | #2
Hi Pierre! Thanks for the review!

On Tue, Jan 13, 2026 at 4:13 PM Pierre-loup GOSSE via lists.openembedded.org
<pierre-loup.gosse=smile.fr@lists.openembedded.org> wrote:

> Hi Adam,
>
> Thanks for your contribution to the plugin.
>
>
> There are many use cases where a user may need a blank partition of a given
> size and format with no extra files added. Such as an empty data partition.
>
>
> A blank partition can already be created without the extra-partition
> plugin.
>
> Personally, I use the following example line in my WKS file:
>
>   part --fstype=ext4 --label data --fixed-size 500M
>
> This command creates a blank 500MB partition with an ext4 filesystem.
>
> In my opinion, the extra plugin should always requires files, similar to
> the bootimg partition plugin (on which the extra partition plugin is based).
>
>
I'm not seeing the problem with making this optional. A bootimg partition
requires certain files to be present for a system to boot.
An extra partition doesn't.

Adam

> Pierre-Loup,
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#229273):
> https://lists.openembedded.org/g/openembedded-core/message/229273
> Mute This Topic: https://lists.openembedded.org/mt/117243676/10152556
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> adam.duskett@amarulasolutions.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Pierre-loup GOSSE Jan. 14, 2026, 10:25 a.m. UTC | #3
Hi Adam,

I'm not seeing the problem with making this optional. A bootimg partition
> requires certain files to be present for a system to boot.
> An extra partition doesn't.
>

My point is, why use the extra-partition plugin without files if omitting
--source already achieves the same result ?

    part --source extra-partition --fstype=ext4 --label data --fixed-size
500M

Is equivalent to:

    part --fstype=ext4 --label data --fixed-size 500M

If your empty extra partition does not requires files, then there is not
need to use the extra-partition plugin.
This is why I designed the plugin to requires files, or creating
directories as in your patch 6/6. If both are optional, I don't see the
added value of using the extra-partition plugin for this use case.

That said, I'm open to making the plugin more flexible. It could allow no
files or directories, but it should raise a warning or a notice.

Pierre-Loup,


On Wed, Jan 14, 2026 at 10:26 AM Adam Duskett <
adam.duskett@amarulasolutions.com> wrote:

> Hi Pierre! Thanks for the review!
>
> On Tue, Jan 13, 2026 at 4:13 PM Pierre-loup GOSSE via
> lists.openembedded.org <pierre-loup.gosse=smile.fr@lists.openembedded.org>
> wrote:
>
>> Hi Adam,
>>
>> Thanks for your contribution to the plugin.
>>
>>
>> There are many use cases where a user may need a blank partition of a
>> given
>> size and format with no extra files added. Such as an empty data
>> partition.
>>
>>
>> A blank partition can already be created without the extra-partition
>> plugin.
>>
>> Personally, I use the following example line in my WKS file:
>>
>>   part --fstype=ext4 --label data --fixed-size 500M
>>
>> This command creates a blank 500MB partition with an ext4 filesystem.
>>
>> In my opinion, the extra plugin should always requires files, similar to
>> the bootimg partition plugin (on which the extra partition plugin is based).
>>
>>
> I'm not seeing the problem with making this optional. A bootimg partition
> requires certain files to be present for a system to boot.
> An extra partition doesn't.
>
> Adam
>
>> Pierre-Loup,
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#229273):
>> https://lists.openembedded.org/g/openembedded-core/message/229273
>> Mute This Topic: https://lists.openembedded.org/mt/117243676/10152556
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
>> adam.duskett@amarulasolutions.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>>
Adam Duskett Jan. 14, 2026, 10:56 a.m. UTC | #4
Hey Pierre-loup;



On Wed, Jan 14, 2026 at 11:25 AM Pierre-loup GOSSE <
pierre-loup.gosse@smile.fr> wrote:

> Hi Adam,
>
> I'm not seeing the problem with making this optional. A bootimg partition
>> requires certain files to be present for a system to boot.
>> An extra partition doesn't.
>>
>
> My point is, why use the extra-partition plugin without files if omitting
> --source already achieves the same result ?
>
>     part --source extra-partition --fstype=ext4 --label data --fixed-size
> 500M
>
> Is equivalent to:
>
>     part --fstype=ext4 --label data --fixed-size 500M
>
> If your empty extra partition does not requires files, then there is not
> need to use the extra-partition plugin.
>
That's understood. but does it really matter? Is it hurting anyone or
anything if they use --source extra-partition?


> This is why I designed the plugin to requires files, or creating
> directories as in your patch 6/6. If both are optional, I don't see the
> added value of using the extra-partition plugin for this use case.
>
People see the "extra partition" plugin and assume they can make extra
partitions from it. The plugin isn't named "extra partition with mandatory
files"

>
> That said, I'm open to making the plugin more flexible. It could allow no
> files or directories, but it should raise a warning or a notice.
>
With this patch series, It does throw a notice. For both empty directories
and empty files.

>
> Pierre-Loup,
>
>
> On Wed, Jan 14, 2026 at 10:26 AM Adam Duskett <
> adam.duskett@amarulasolutions.com> wrote:
>
>> Hi Pierre! Thanks for the review!
>>
>> On Tue, Jan 13, 2026 at 4:13 PM Pierre-loup GOSSE via
>> lists.openembedded.org <pierre-loup.gosse=smile.fr@lists.openembedded.org>
>> wrote:
>>
>>> Hi Adam,
>>>
>>> Thanks for your contribution to the plugin.
>>>
>>>
>>> There are many use cases where a user may need a blank partition of a
>>> given
>>> size and format with no extra files added. Such as an empty data
>>> partition.
>>>
>>>
>>> A blank partition can already be created without the extra-partition
>>> plugin.
>>>
>>> Personally, I use the following example line in my WKS file:
>>>
>>>   part --fstype=ext4 --label data --fixed-size 500M
>>>
>>> This command creates a blank 500MB partition with an ext4 filesystem.
>>>
>>> In my opinion, the extra plugin should always requires files, similar to
>>> the bootimg partition plugin (on which the extra partition plugin is based).
>>>
>>>
>> I'm not seeing the problem with making this optional. A bootimg partition
>> requires certain files to be present for a system to boot.
>> An extra partition doesn't.
>>
>> Adam
>>
>>> Pierre-Loup,
>>>
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#229273):
>>> https://lists.openembedded.org/g/openembedded-core/message/229273
>>> Mute This Topic: https://lists.openembedded.org/mt/117243676/10152556
>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
>>> adam.duskett@amarulasolutions.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>
>>>
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index d7a9b14658..33a6460677 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1698,6 +1698,16 @@  INITRAMFS_IMAGE = "core-image-initramfs-boot"
 
             self.remove_config(config)
 
+            # Test with a blank formatted partition of 5M with no extra files
+            with NamedTemporaryFile("w", suffix=".wks") as wks:
+                wks.writelines(['part / --source extra_partition --ondisk sda --fstype=ext4 --label foo --align 4 --size 5M\n'])
+                wks.flush()
+                _, wicimg = self._get_wic(wks.name)
+
+                cmd = "wic ls %s | wc -l" % wicimg
+                result = runCmd(cmd)
+                self.assertEqual('2', result.output, msg="Expect 1 partition, not %s" % result.output)
+
         finally:
             os.environ['PATH'] = oldpath
 
diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py
index efe15a4d15..3abd2bfd4c 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.debug('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)
@@ -74,7 +76,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:
@@ -131,13 +132,14 @@  class ExtraPartitionPlugin(SourcePlugin):
             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_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,