mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 18:49:32 +02:00
wic: Call methods better way
Shortened code by using getattr to obtain a method to call for prepare_empty_partition_* and prepare_rootfs_* methods. (From OE-Core rev: 066f713f71828ff6f408448e5ea4fcd56faa423e) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
73d0d23014
commit
052c8198d7
@@ -160,8 +160,12 @@ class Wic_PartData(Mic_PartData):
|
|||||||
self.prepare_swap_partition(cr_workdir, oe_builddir,
|
self.prepare_swap_partition(cr_workdir, oe_builddir,
|
||||||
native_sysroot)
|
native_sysroot)
|
||||||
elif self.fstype:
|
elif self.fstype:
|
||||||
self.prepare_empty_partition(cr_workdir, oe_builddir,
|
for prefix in ("ext", "btrfs", "vfat", "squashfs"):
|
||||||
native_sysroot)
|
if self.fstype.startswith(prefix):
|
||||||
|
method = getattr(self,
|
||||||
|
"prepare_empty_partition_" + prefix)
|
||||||
|
method(cr_workdir, oe_builddir, native_sysroot)
|
||||||
|
break
|
||||||
return
|
return
|
||||||
|
|
||||||
plugins = pluginmgr.get_source_plugins()
|
plugins = pluginmgr.get_source_plugins()
|
||||||
@@ -223,23 +227,11 @@ class Wic_PartData(Mic_PartData):
|
|||||||
if os.path.isfile(rootfs):
|
if os.path.isfile(rootfs):
|
||||||
os.remove(rootfs)
|
os.remove(rootfs)
|
||||||
|
|
||||||
if self.fstype.startswith("ext"):
|
for prefix in ("ext", "btrfs", "vfat", "squashfs"):
|
||||||
return self.prepare_rootfs_ext(rootfs, oe_builddir,
|
if self.fstype.startswith(prefix):
|
||||||
rootfs_dir, native_sysroot,
|
method = getattr(self, "prepare_rootfs_" + prefix)
|
||||||
pseudo)
|
return method(rootfs, oe_builddir, rootfs_dir,
|
||||||
elif self.fstype.startswith("btrfs"):
|
native_sysroot, pseudo)
|
||||||
return self.prepare_rootfs_btrfs(rootfs, oe_builddir,
|
|
||||||
rootfs_dir, native_sysroot,
|
|
||||||
pseudo)
|
|
||||||
|
|
||||||
elif self.fstype.startswith("vfat"):
|
|
||||||
return self.prepare_rootfs_vfat(rootfs, oe_builddir,
|
|
||||||
rootfs_dir, native_sysroot,
|
|
||||||
pseudo)
|
|
||||||
elif self.fstype.startswith("squashfs"):
|
|
||||||
return self.prepare_rootfs_squashfs(rootfs, oe_builddir,
|
|
||||||
rootfs_dir, native_sysroot,
|
|
||||||
pseudo)
|
|
||||||
|
|
||||||
def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
|
def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
|
||||||
native_sysroot, pseudo):
|
native_sysroot, pseudo):
|
||||||
@@ -391,23 +383,6 @@ class Wic_PartData(Mic_PartData):
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
|
|
||||||
"""
|
|
||||||
Prepare an empty partition.
|
|
||||||
"""
|
|
||||||
if self.fstype.startswith("ext"):
|
|
||||||
return self.prepare_empty_partition_ext(cr_workdir, oe_builddir,
|
|
||||||
native_sysroot)
|
|
||||||
elif self.fstype.startswith("btrfs"):
|
|
||||||
return self.prepare_empty_partition_btrfs(cr_workdir, oe_builddir,
|
|
||||||
native_sysroot)
|
|
||||||
elif self.fstype.startswith("vfat"):
|
|
||||||
return self.prepare_empty_partition_vfat(cr_workdir, oe_builddir,
|
|
||||||
native_sysroot)
|
|
||||||
elif self.fstype.startswith("squashfs"):
|
|
||||||
return self.prepare_empty_partition_squashfs(cr_workdir, oe_builddir,
|
|
||||||
native_sysroot)
|
|
||||||
|
|
||||||
def prepare_empty_partition_ext(self, cr_workdir, oe_builddir,
|
def prepare_empty_partition_ext(self, cr_workdir, oe_builddir,
|
||||||
native_sysroot):
|
native_sysroot):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user