[OE-core] [PATCH] wic: Add include-dir option

akuster808 akuster808 at gmail.com
Thu Feb 27 19:43:19 UTC 2020



On 2/27/20 12:12 AM, Martin Hundebøll wrote:
> Hi Armin,
>
> On 27/02/2020 05.26, Armin Kuster wrote:
>> This option allows for the inclusion of a single directory
>> for a partition.
>
> I am unsure how this is used in a .wks file.
Yeah, the documentation does not cover this.

This is what I used to verified it works

part  / --source rootfs --ondisk mmcblk1 --fstype=ext4 --label rootfs
--align 4096 --exclude-path=var
part  /var --source rootfs --ondisk mmcblk1 --fstype=ext4 --label var
--align 4096 --include-dir=var


>
> From the code it looks similar to the include-path option, but
> relative to the rootfs source dir instead of the wic working dir?

the --include-path adds an entire rootfs  to the partition. I don't want
the another rootfs. The help file even says that.  I want on directory.
--exclude-dir allows me to "exclude" a dir .


I used wic ls {path to partition}:{partition number}  to view the
contents  of the partition.

>
> But the include-dir value is also used in the destination path?
Then please document it and I don't mean the "help" file which is unclear.

So how would you have "home" or "var" be in their own partitions? Please
show an example.


- armin

>
> Thanks,
> Martin
>
>> Signed-off-by: Armin Kuster <akuster808 at gmail.com>
>> ---
>>   scripts/lib/wic/help.py                  |  3 +++
>>   scripts/lib/wic/ksparser.py              |  1 +
>>   scripts/lib/wic/partition.py             |  1 +
>>   scripts/lib/wic/plugins/source/rootfs.py | 10 ++++++++--
>>   4 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
>> index 4d342fcf05..517f68e11e 100644
>> --- a/scripts/lib/wic/help.py
>> +++ b/scripts/lib/wic/help.py
>> @@ -979,6 +979,9 @@ DESCRIPTION
>>                            copies. This option only has an effect
>> with the rootfs
>>                            source plugin.
>>   +         --include-dir: This option is specific to wic. It adds
>> the contents
>> +                        of the given directory to the resulting
>> partition.
>> +
>>            --extra-space: This option is specific to wic. It adds extra
>>                           space after the space filled by the content
>>                           of the partition. The final size can go
>> diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
>> index 650b976223..b8abc33c87 100644
>> --- a/scripts/lib/wic/ksparser.py
>> +++ b/scripts/lib/wic/ksparser.py
>> @@ -138,6 +138,7 @@ class KickStart():
>>           part.add_argument('--align', type=int)
>>           part.add_argument('--exclude-path', nargs='+')
>>           part.add_argument('--include-path', nargs='+')
>> +        part.add_argument('--include-dir')
>>           part.add_argument("--extra-space", type=sizetype)
>>           part.add_argument('--fsoptions', dest='fsopts')
>>           part.add_argument('--fstype', default='vfat',
>> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
>> index 2d95f78439..0b735fffd9 100644
>> --- a/scripts/lib/wic/partition.py
>> +++ b/scripts/lib/wic/partition.py
>> @@ -31,6 +31,7 @@ class Partition():
>>           self.extra_space = args.extra_space
>>           self.exclude_path = args.exclude_path
>>           self.include_path = args.include_path
>> +        self.include_dir = args.include_dir
>>           self.fsopts = args.fsopts
>>           self.fstype = args.fstype
>>           self.label = args.label
>> diff --git a/scripts/lib/wic/plugins/source/rootfs.py
>> b/scripts/lib/wic/plugins/source/rootfs.py
>> index 705aeb5563..d1c59cab8a 100644
>> --- a/scripts/lib/wic/plugins/source/rootfs.py
>> +++ b/scripts/lib/wic/plugins/source/rootfs.py
>> @@ -71,7 +71,7 @@ class RootfsPlugin(SourcePlugin):
>>             new_rootfs = None
>>           # Handle excluded paths.
>> -        if part.exclude_path or part.include_path:
>> +        if part.exclude_path or part.include_path or part.include_dir:
>>               # We need a new rootfs directory we can delete files
>> from. Copy to
>>               # workdir.
>>               new_rootfs = os.path.realpath(os.path.join(cr_workdir,
>> "rootfs%d" % part.lineno))
>> @@ -79,7 +79,13 @@ class RootfsPlugin(SourcePlugin):
>>               if os.path.lexists(new_rootfs):
>>                   shutil.rmtree(os.path.join(new_rootfs))
>>   -            copyhardlinktree(part.rootfs_dir, new_rootfs)
>> +            if part.include_dir:
>> +                src = os.path.realpath(os.path.join(part.rootfs_dir,
>> part.include_dir))
>> +                dst = os.path.realpath(os.path.join(new_rootfs,
>> part.include_dir))
>> +                copyhardlinktree(src, dst)
>> +
>> +            else:
>> +                copyhardlinktree(part.rootfs_dir, new_rootfs)
>>                 for path in part.include_path or []:
>>                   copyhardlinktree(path, new_rootfs)
>>



More information about the Openembedded-core mailing list