mirror of
https://git.yoctoproject.org/poky
synced 2026-07-16 15:57:04 +00:00
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: a56b9dbfeb410d235b5af2c5a846b3f1360d2d1d) 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: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
d2c89a6f15
commit
58e578f7b6
@@ -55,6 +55,8 @@ class Partition():
|
||||
self.fsuuid = args.fsuuid
|
||||
self.type = args.type
|
||||
self.updated_fstab_path = None
|
||||
self.has_fstab = False
|
||||
self.update_fstab_in_rootfs = False
|
||||
|
||||
self.lineno = lineno
|
||||
self.source_file = ""
|
||||
@@ -125,6 +127,8 @@ class Partition():
|
||||
partition command parameters.
|
||||
"""
|
||||
self.updated_fstab_path = updated_fstab_path
|
||||
if self.updated_fstab_path and not (self.fstype.startswith("ext") or self.fstype == "msdos"):
|
||||
self.update_fstab_in_rootfs = True
|
||||
|
||||
if not self.source:
|
||||
if not self.size and not self.fixed_size:
|
||||
@@ -250,7 +254,7 @@ class Partition():
|
||||
|
||||
prefix = "ext" if self.fstype.startswith("ext") else self.fstype
|
||||
method = getattr(self, "prepare_rootfs_" + prefix)
|
||||
method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo)
|
||||
method(rootfs, cr_workdir, oe_builddir, rootfs_dir, native_sysroot, pseudo)
|
||||
self.source_file = rootfs
|
||||
|
||||
# get the rootfs size in the right units for kickstart (kB)
|
||||
@@ -258,7 +262,7 @@ class Partition():
|
||||
out = exec_cmd(du_cmd)
|
||||
self.size = int(out.split()[0])
|
||||
|
||||
def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
|
||||
def prepare_rootfs_ext(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
|
||||
native_sysroot, pseudo):
|
||||
"""
|
||||
Prepare content for an ext2/3/4 rootfs partition.
|
||||
@@ -282,10 +286,19 @@ class Partition():
|
||||
(self.fstype, extraopts, rootfs, label_str, self.fsuuid, rootfs_dir)
|
||||
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
|
||||
|
||||
if self.updated_fstab_path and self.has_fstab:
|
||||
debugfs_script_path = os.path.join(cr_workdir, "debugfs_script")
|
||||
with open(debugfs_script_path, "w") as f:
|
||||
f.write("cd etc\n")
|
||||
f.write("rm fstab\n")
|
||||
f.write("write %s fstab\n" % (self.updated_fstab_path))
|
||||
debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs)
|
||||
exec_native_cmd(debugfs_cmd, native_sysroot)
|
||||
|
||||
mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
|
||||
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
|
||||
|
||||
def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
|
||||
def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
|
||||
native_sysroot, pseudo):
|
||||
"""
|
||||
Prepare content for a btrfs rootfs partition.
|
||||
@@ -308,7 +321,7 @@ class Partition():
|
||||
self.mkfs_extraopts, self.fsuuid, rootfs)
|
||||
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
|
||||
|
||||
def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir,
|
||||
def prepare_rootfs_msdos(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
|
||||
native_sysroot, pseudo):
|
||||
"""
|
||||
Prepare content for a msdos/vfat rootfs partition.
|
||||
@@ -337,12 +350,16 @@ class Partition():
|
||||
mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
|
||||
exec_native_cmd(mcopy_cmd, native_sysroot)
|
||||
|
||||
if self.updated_fstab_path and self.has_fstab:
|
||||
mcopy_cmd = "mcopy -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path)
|
||||
exec_native_cmd(mcopy_cmd, native_sysroot)
|
||||
|
||||
chmod_cmd = "chmod 644 %s" % rootfs
|
||||
exec_cmd(chmod_cmd)
|
||||
|
||||
prepare_rootfs_vfat = prepare_rootfs_msdos
|
||||
|
||||
def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir,
|
||||
def prepare_rootfs_squashfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
|
||||
native_sysroot, pseudo):
|
||||
"""
|
||||
Prepare content for a squashfs rootfs partition.
|
||||
|
||||
Reference in New Issue
Block a user