From bda03019624ab10ae2ebbd85538d32f47f32c9af Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Sat, 27 Jun 2015 13:37:27 +0300 Subject: wic: Remove duplicated code Moved duplicated code of geting rootfs size out of prepare_rootfs* methods. --- .../lib/wic/kickstart/custom_commands/partition.py | 48 +++++----------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py index 4e8a6a89b0..72f617a1b6 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py @@ -234,8 +234,16 @@ class Wic_PartData(Mic_PartData): for prefix in ("ext", "btrfs", "vfat", "squashfs"): if self.fstype.startswith(prefix): method = getattr(self, "prepare_rootfs_" + prefix) - return method(rootfs, oe_builddir, rootfs_dir, - native_sysroot, pseudo) + method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo) + + self.source_file = rootfs + + # get the rootfs size in the right units for kickstart (kB) + du_cmd = "du -Lbks %s" % rootfs + out = exec_cmd(du_cmd) + self.size = out.split()[0] + + break def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo): @@ -270,16 +278,6 @@ class Wic_PartData(Mic_PartData): (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir) exec_native_cmd(pseudo + mkfs_cmd, native_sysroot) - # get the rootfs size in the right units for kickstart (kB) - du_cmd = "du -Lbks %s" % rootfs - out = exec_cmd(du_cmd) - rootfs_size = out.split()[0] - - self.size = rootfs_size - self.source_file = rootfs - - return 0 - def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo): """ @@ -313,14 +311,6 @@ class Wic_PartData(Mic_PartData): (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs) exec_native_cmd(pseudo + mkfs_cmd, native_sysroot) - # get the rootfs size in the right units for kickstart (kB) - du_cmd = "du -Lbks %s" % rootfs - out = exec_cmd(du_cmd) - rootfs_size = out.split()[0] - - self.size = rootfs_size - self.source_file = rootfs - def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo): """ @@ -360,14 +350,6 @@ class Wic_PartData(Mic_PartData): chmod_cmd = "chmod 644 %s" % rootfs exec_cmd(chmod_cmd) - # get the rootfs size in the right units for kickstart (kB) - du_cmd = "du -Lbks %s" % rootfs - out = exec_cmd(du_cmd) - rootfs_size = out.split()[0] - - self.set_size(rootfs_size) - self.set_source_file(rootfs) - def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo): """ @@ -377,16 +359,6 @@ class Wic_PartData(Mic_PartData): (rootfs_dir, rootfs) exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) - # get the rootfs size in the right units for kickstart (kB) - du_cmd = "du -Lbks %s" % rootfs - out = exec_cmd(du_cmd) - rootfs_size = out.split()[0] - - self.size = rootfs_size - self.source_file = rootfs - - return 0 - def prepare_empty_partition_ext(self, rootfs, oe_builddir, native_sysroot): """ -- cgit 1.2.3-korg