summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2020-04-19 08:35:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-26 14:00:50 +0100
commitd19004da2fd40109322990061bb4fe48d91a6150 (patch)
treeb5ae0ad163dc20507aa68e4cc91d38ab9d5dea98 /scripts/lib/wic/plugins
parentc58711f0ea2a4d3b54e9f5f442abe3192f4697d0 (diff)
downloadpoky-d19004da2fd40109322990061bb4fe48d91a6150.tar.gz
wic: Add --change-directory argument
This option allows to specify which part of a rootfs is going to be included, the same way the -C argument on tar. Thanks to this option we can make sure the permissions and usernames on the target partition are respected, and also simplify the creation of splitted partitons, not neeting to invoke external vars or using .wks.in files. Eg: part / --source rootfs --ondisk sda --fstype=ext4 --exclude-path=etc/    part /etc --source rootfs --fstype=ext4 --change-directory=etc Cc: Paul Barker <pbarker@konsulko.com> (From OE-Core rev: 2265d089a58e1f78f26d623ee667c420cb1c3bd4) Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins')
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 8b2a067385..85c634f8a1 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -86,14 +86,29 @@ class RootfsPlugin(SourcePlugin):
86 new_rootfs = None 86 new_rootfs = None
87 new_pseudo = None 87 new_pseudo = None
88 # Handle excluded paths. 88 # Handle excluded paths.
89 if part.exclude_path or part.include_path: 89 if part.exclude_path or part.include_path or part.change_directory:
90 # We need a new rootfs directory we can delete files from. Copy to 90 # We need a new rootfs directory we can delete files from. Copy to
91 # workdir. 91 # workdir.
92 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) 92 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno))
93 93
94 if os.path.lexists(new_rootfs): 94 if os.path.lexists(new_rootfs):
95 shutil.rmtree(os.path.join(new_rootfs)) 95 shutil.rmtree(os.path.join(new_rootfs))
96 copyhardlinktree(part.rootfs_dir, new_rootfs) 96
97 if part.change_directory:
98 cd = part.change_directory
99 if cd[-1] == '/':
100 cd = cd[:-1]
101 if os.path.isabs(cd):
102 logger.error("Must be relative: --change-directory=%s" % cd)
103 sys.exit(1)
104 orig_dir = os.path.realpath(os.path.join(part.rootfs_dir, cd))
105 if not orig_dir.startswith(part.rootfs_dir):
106 logger.error("'%s' points to a path outside the rootfs" % orig_dir)
107 sys.exit(1)
108
109 else:
110 orig_dir = part.rootfs_dir
111 copyhardlinktree(orig_dir, new_rootfs)
97 112
98 # Convert the pseudo directory to its new location 113 # Convert the pseudo directory to its new location
99 if (pseudo_dir): 114 if (pseudo_dir):
@@ -108,7 +123,7 @@ class RootfsPlugin(SourcePlugin):
108 pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot, 123 pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot,
109 new_rootfs, 124 new_rootfs,
110 new_pseudo), 125 new_pseudo),
111 part.rootfs_dir, new_rootfs) 126 orig_dir, new_rootfs)
112 exec_native_cmd(pseudo_cmd, native_sysroot) 127 exec_native_cmd(pseudo_cmd, native_sysroot)
113 128
114 for path in part.include_path or []: 129 for path in part.include_path or []: