diff options
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs.py')
-rw-r--r-- | scripts/lib/wic/plugins/source/rootfs.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py index f1db83f8a1..96d940a91d 100644 --- a/scripts/lib/wic/plugins/source/rootfs.py +++ b/scripts/lib/wic/plugins/source/rootfs.py | |||
@@ -94,6 +94,7 @@ class RootfsPlugin(SourcePlugin): | |||
94 | "it is not a valid path, exiting" % part.rootfs_dir) | 94 | "it is not a valid path, exiting" % part.rootfs_dir) |
95 | 95 | ||
96 | part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) | 96 | part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) |
97 | part.has_fstab = os.path.exists(os.path.join(part.rootfs_dir, "etc/fstab")) | ||
97 | pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo") | 98 | pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo") |
98 | if not os.path.lexists(pseudo_dir): | 99 | if not os.path.lexists(pseudo_dir): |
99 | logger.warn("%s folder does not exist. " | 100 | logger.warn("%s folder does not exist. " |
@@ -103,9 +104,9 @@ class RootfsPlugin(SourcePlugin): | |||
103 | new_rootfs = None | 104 | new_rootfs = None |
104 | new_pseudo = None | 105 | new_pseudo = None |
105 | # Handle excluded paths. | 106 | # Handle excluded paths. |
106 | if part.exclude_path or part.include_path or part.change_directory: | 107 | if part.exclude_path or part.include_path or part.change_directory or part.update_fstab_in_rootfs: |
107 | # We need a new rootfs directory we can delete files from. Copy to | 108 | # We need a new rootfs directory we can safely modify without |
108 | # workdir. | 109 | # interfering with other tasks. Copy to workdir. |
109 | new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) | 110 | new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) |
110 | 111 | ||
111 | if os.path.lexists(new_rootfs): | 112 | if os.path.lexists(new_rootfs): |
@@ -199,17 +200,33 @@ class RootfsPlugin(SourcePlugin): | |||
199 | if not os.path.lexists(full_path): | 200 | if not os.path.lexists(full_path): |
200 | continue | 201 | continue |
201 | 202 | ||
203 | if new_pseudo: | ||
204 | pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo) | ||
205 | else: | ||
206 | pseudo = None | ||
202 | if path.endswith(os.sep): | 207 | if path.endswith(os.sep): |
203 | # Delete content only. | 208 | # Delete content only. |
204 | for entry in os.listdir(full_path): | 209 | for entry in os.listdir(full_path): |
205 | full_entry = os.path.join(full_path, entry) | 210 | full_entry = os.path.join(full_path, entry) |
206 | if os.path.isdir(full_entry) and not os.path.islink(full_entry): | 211 | rm_cmd = "rm -rf %s" % (full_entry) |
207 | shutil.rmtree(full_entry) | 212 | exec_native_cmd(rm_cmd, native_sysroot, pseudo) |
208 | else: | ||
209 | os.remove(full_entry) | ||
210 | else: | 213 | else: |
211 | # Delete whole directory. | 214 | # Delete whole directory. |
212 | shutil.rmtree(full_path) | 215 | rm_cmd = "rm -rf %s" % (full_path) |
216 | exec_native_cmd(rm_cmd, native_sysroot, pseudo) | ||
217 | |||
218 | # Update part.has_fstab here as fstab may have been added or | ||
219 | # removed by the above modifications. | ||
220 | part.has_fstab = os.path.exists(os.path.join(new_rootfs, "etc/fstab")) | ||
221 | if part.update_fstab_in_rootfs and part.has_fstab: | ||
222 | fstab_path = os.path.join(new_rootfs, "etc/fstab") | ||
223 | # Assume that fstab should always be owned by root with fixed permissions | ||
224 | install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path) | ||
225 | if new_pseudo: | ||
226 | pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo) | ||
227 | else: | ||
228 | pseudo = None | ||
229 | exec_native_cmd(install_cmd, native_sysroot, pseudo) | ||
213 | 230 | ||
214 | part.prepare_rootfs(cr_workdir, oe_builddir, | 231 | part.prepare_rootfs(cr_workdir, oe_builddir, |
215 | new_rootfs or part.rootfs_dir, native_sysroot, | 232 | new_rootfs or part.rootfs_dir, native_sysroot, |