summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/rootfs.py
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-01-19 16:26:10 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-20 22:46:18 +0000
commitda846838fc5d2a1b421767be68561cdaa08bca42 (patch)
tree6402f67ec29c819a984ec6c2212d08dbd54b4e4e /scripts/lib/wic/plugins/source/rootfs.py
parent36575a949399953f98fc1cfda4a3dcb5a295b02c (diff)
downloadpoky-da846838fc5d2a1b421767be68561cdaa08bca42.tar.gz
wic: Optimise fstab modification for ext2/3/4 and msdos partitions
The fix for [Yocto #13994] required the rootfs directory to be copied (using hardlinks if possible) when modifying the fstab file under wic. We can optimise this copy away for filesystems where we have the tools to modify the contents of the partition image after it is created. For ext2/3/4 filesystems we have the debugfs tool and for msdos/vfat filesystems we have the mcopy tool. So for any of these filesystems we skip the modification of the fstab file in the rootfs directory (and skip the associated copy unless it is otherwise necessary) and update the contents of fstab directly in the partition image. (From OE-Core rev: 5fb8ae0e9159597d7eaa9307a3a8543800bf9405) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs.py')
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 6fd415af5b..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,7 +104,7 @@ 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 or part.updated_fstab_path: 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 safely modify without 108 # We need a new rootfs directory we can safely modify without
108 # interfering with other tasks. Copy to 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))
@@ -214,8 +215,10 @@ class RootfsPlugin(SourcePlugin):
214 rm_cmd = "rm -rf %s" % (full_path) 215 rm_cmd = "rm -rf %s" % (full_path)
215 exec_native_cmd(rm_cmd, native_sysroot, pseudo) 216 exec_native_cmd(rm_cmd, native_sysroot, pseudo)
216 217
217 has_fstab = os.path.exists(os.path.join(new_rootfs, "etc/fstab")) 218 # Update part.has_fstab here as fstab may have been added or
218 if part.updated_fstab_path and has_fstab: 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:
219 fstab_path = os.path.join(new_rootfs, "etc/fstab") 222 fstab_path = os.path.join(new_rootfs, "etc/fstab")
220 # Assume that fstab should always be owned by root with fixed permissions 223 # Assume that fstab should always be owned by root with fixed permissions
221 install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path) 224 install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path)