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-02-03 14:13:54 +0000
commit7723cbe607bb988a85be6edea3e92420c421e03a (patch)
tree519a2bd3ad97ff7a3b2ef1570cdceecc2df5ab17 /scripts/lib/wic/plugins/source/rootfs.py
parent14dcd18f6cf77d119fc9436f5afdf33437a6c01c (diff)
downloadpoky-7723cbe607bb988a85be6edea3e92420c421e03a.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: 1988d07b65ad38bdf8fac8615f11fb6536a75806) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 5fb8ae0e9159597d7eaa9307a3a8543800bf9405) Signed-off-by: Steve Sakoman <steve@sakoman.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 f19ec3312b..c8c1c0f58f 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -77,6 +77,7 @@ class RootfsPlugin(SourcePlugin):
77 "it is not a valid path, exiting" % part.rootfs_dir) 77 "it is not a valid path, exiting" % part.rootfs_dir)
78 78
79 part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) 79 part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
80 part.has_fstab = os.path.exists(os.path.join(part.rootfs_dir, "etc/fstab"))
80 pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo") 81 pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo")
81 if not os.path.lexists(pseudo_dir): 82 if not os.path.lexists(pseudo_dir):
82 logger.warn("%s folder does not exist. " 83 logger.warn("%s folder does not exist. "
@@ -86,7 +87,7 @@ class RootfsPlugin(SourcePlugin):
86 new_rootfs = None 87 new_rootfs = None
87 new_pseudo = None 88 new_pseudo = None
88 # Handle excluded paths. 89 # Handle excluded paths.
89 if part.exclude_path or part.include_path or part.change_directory or part.updated_fstab_path: 90 if part.exclude_path or part.include_path or part.change_directory or part.update_fstab_in_rootfs:
90 # We need a new rootfs directory we can safely modify without 91 # We need a new rootfs directory we can safely modify without
91 # interfering with other tasks. Copy to workdir. 92 # interfering with other tasks. Copy to workdir.
92 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) 93 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno))
@@ -159,8 +160,10 @@ class RootfsPlugin(SourcePlugin):
159 rm_cmd = "rm -rf %s" % (full_path) 160 rm_cmd = "rm -rf %s" % (full_path)
160 exec_native_cmd(rm_cmd, native_sysroot, pseudo) 161 exec_native_cmd(rm_cmd, native_sysroot, pseudo)
161 162
162 has_fstab = os.path.exists(os.path.join(new_rootfs, "etc/fstab")) 163 # Update part.has_fstab here as fstab may have been added or
163 if part.updated_fstab_path and has_fstab: 164 # removed by the above modifications.
165 part.has_fstab = os.path.exists(os.path.join(new_rootfs, "etc/fstab"))
166 if part.update_fstab_in_rootfs and part.has_fstab:
164 fstab_path = os.path.join(new_rootfs, "etc/fstab") 167 fstab_path = os.path.join(new_rootfs, "etc/fstab")
165 # Assume that fstab should always be owned by root with fixed permissions 168 # Assume that fstab should always be owned by root with fixed permissions
166 install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path) 169 install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path)