wic: Add include-dir option
PATCH 1/1 wic: Add include-dir option
This option allows for the inclusion of a single directory for a partition.
--- 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(-)
scripts/lib/wic/help.py +3 -0
@@ -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
scripts/lib/wic/ksparser.py +1 -0
@@ -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',
scripts/lib/wic/partition.py +1 -0
@@ -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
scripts/lib/wic/plugins/source/rootfs.py +8 -2
@@ -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)
Signature · 1 line
2.17.1
Hi Armin,
Quoted 2 lines · Armin Kuster
This option allows for the inclusion of a single directory for a partition.
I am unsure how this is used in a .wks file.
From the code it looks similar to the include-path option, but relative to the rootfs source dir instead of the wic working dir?
But the include-dir value is also used in the destination path?
Thanks,
Martin
Quoted 75 lines
Signed-off-by Armin Kuster <[email protected]>--- 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(-)scripts/lib/wic/help.py +3
-0@@ -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 goscripts/lib/wic/ksparser.py +1
-0@@ -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',scripts/lib/wic/partition.py +1
-0@@ -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.labelscripts/lib/wic/plugins/source/rootfs.py +8
-2@@ -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)
Quoted 7 lines · Martin Hundebøll
Hi Armin,
Quoted 2 lines · Armin Kuster
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
Quoted 3 lines
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.
Quoted 2 lines
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
Quoted 83 lines
Thanks,
MartinQuoted 79 lines
Signed-off-by Armin Kuster <[email protected]>---
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(-)scripts/lib/wic/help.py +0
-0@@ -979,6 +979,9 @@ DESCRIPTIONcopies. 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 goscripts/lib/wic/ksparser.py +1
-0@@ -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',scripts/lib/wic/partition.py +0
-0@@ -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.labelscripts/lib/wic/plugins/source/rootfs.py +0
-0@@ -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))scripts/lib/wic/plugins/source/rootfs.py +0
-0@@ -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)
Quoted 34 lines · On Thu, 27 Feb 2020 at 19:43, akuster808 <[email protected]> wrote:
Quoted 7 lines · Martin Hundebøll
Hi Armin,
Quoted 2 lines · Armin Kuster
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=varQuoted 3 lines
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.
Quoted 1 line
Quoted 5 lines
Quoted 1 line
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.
IIRC,
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 --rootfs-dir=${IMAGE_ROOTFS}/var
For an example see scripts/lib/wic/canned-wks/efi-bootdisk.wks.in
Thanks,
Paul
Paul,
Quoted 35 lines · Paul Barker
Quoted 26 lines · On Thu, 27 Feb 2020 at 19:43, akuster808 <[email protected]> wrote:
Quoted 6 lines · Martin Hundebøll
Hi Armin,
Quoted 2 lines · Armin Kuster
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=varQuoted 2 lines
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 .
Quoted 8 lines
I used wic ls {path to partition}:{partition number} to view the contents of the partition.
Quoted 1 line
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.
Quoted 8 lines
IIRC,
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 --rootfs-dir=${IMAGE_ROOTFS}/varFor an example see
scripts/lib/wic/canned-wks/efi-bootdisk.wks.in
Yeah, I looked all the wks files an nothing jumped out at me. The "--rootfs-dir" is not intuitive for selecting a single dir but I see that it does address my issue.
thanks,
Armin
Quoted 3 lines
Thanks,
Paul