summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-06-27 13:37:27 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-02 23:01:38 +0100
commitbda03019624ab10ae2ebbd85538d32f47f32c9af (patch)
tree8d00ab5e498b191fa91e124ace923cdb5fcee134
parent7dc4e007aa9f02162b3f24705e9d9dba7a1cf7ef (diff)
downloadopenembedded-core-bda03019624ab10ae2ebbd85538d32f47f32c9af.tar.gz
openembedded-core-bda03019624ab10ae2ebbd85538d32f47f32c9af.tar.bz2
openembedded-core-bda03019624ab10ae2ebbd85538d32f47f32c9af.zip
wic: Remove duplicated code
Moved duplicated code of geting rootfs size out of prepare_rootfs* methods.
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/partition.py48
1 files 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):
"""