From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [wic][PATCH v2 08/20] wic: Refactor prepare_rootfs API
Date: Tue, 30 Jun 2015 11:51:40 +0300 [thread overview]
Message-ID: <1435654312-18177-9-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1435654312-18177-1-git-send-email-ed.bartosh@linux.intel.com>
Moved code out of prepare_roots* methods to avoid code duplication.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py
index 324ea69..489ebe3 100644
--- a/scripts/lib/wic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/wic/kickstart/custom_commands/partition.py
@@ -219,34 +219,36 @@ class Wic_PartData(Mic_PartData):
pseudo += "export PSEUDO_NOSYMLINKEXP=%s;" % p_nosymlinkexp
pseudo += "%s/usr/bin/pseudo " % native_sysroot
+ rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
+ if os.path.isfile(rootfs):
+ os.remove(rootfs)
+
if self.fstype.startswith("ext"):
- return self.prepare_rootfs_ext(cr_workdir, oe_builddir,
+ return self.prepare_rootfs_ext(rootfs, oe_builddir,
rootfs_dir, native_sysroot,
pseudo)
elif self.fstype.startswith("btrfs"):
- return self.prepare_rootfs_btrfs(cr_workdir, oe_builddir,
+ return self.prepare_rootfs_btrfs(rootfs, oe_builddir,
rootfs_dir, native_sysroot,
pseudo)
elif self.fstype.startswith("vfat"):
- return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
+ return self.prepare_rootfs_vfat(rootfs, oe_builddir,
rootfs_dir, native_sysroot,
pseudo)
elif self.fstype.startswith("squashfs"):
- return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir,
+ return self.prepare_rootfs_squashfs(rootfs, oe_builddir,
rootfs_dir, native_sysroot,
pseudo)
- def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
+ def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for an ext2/3/4 rootfs partition.
"""
image_rootfs = rootfs_dir
- rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
- os.path.isfile(rootfs) and os.remove(rootfs)
du_cmd = "du -ks %s" % image_rootfs
out = exec_cmd(du_cmd)
actual_rootfs_size = int(out.split()[0])
@@ -285,7 +287,7 @@ class Wic_PartData(Mic_PartData):
return 0
- def prepare_rootfs_btrfs(self, cr_workdir, oe_builddir, rootfs_dir,
+ def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for a btrfs rootfs partition.
@@ -293,9 +295,7 @@ class Wic_PartData(Mic_PartData):
Currently handles ext2/3/4 and btrfs.
"""
image_rootfs = rootfs_dir
- rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
- os.path.isfile(rootfs) and os.remove(rootfs)
du_cmd = "du -ks %s" % image_rootfs
out = exec_cmd(du_cmd)
actual_rootfs_size = int(out.split()[0])
@@ -330,15 +330,13 @@ class Wic_PartData(Mic_PartData):
self.size = rootfs_size
self.source_file = rootfs
- def prepare_rootfs_vfat(self, cr_workdir, oe_builddir, rootfs_dir,
+ def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for a vfat rootfs partition.
"""
image_rootfs = rootfs_dir
- rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
- os.path.isfile(rootfs) and os.remove(rootfs)
du_cmd = "du -bks %s" % image_rootfs
out = exec_cmd(du_cmd)
blocks = int(out.split()[0])
@@ -381,15 +379,13 @@ class Wic_PartData(Mic_PartData):
self.set_size(rootfs_size)
self.set_source_file(rootfs)
- def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir,
+ def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for a squashfs rootfs partition.
"""
image_rootfs = rootfs_dir
- rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
- os.path.isfile(rootfs) and os.remove(rootfs)
squashfs_cmd = "mksquashfs %s %s -noappend" % \
(image_rootfs, rootfs)
exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
--
2.1.4
next prev parent reply other threads:[~2015-06-30 8:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 8:51 [wic][PATCH v2 00/20] miscellaneous fixes. poky-conrib:ed/wic/misc Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 01/20] wic: Fix misleading message Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 02/20] wic: Test rootfs plugin using image recipes Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 03/20] wic: Test rootfs plugin using rootfs paths Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 04/20] wic: Refactor getting bitbake variables Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 05/20] wic: Include mount point into image report Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 06/20] wic: Remove annoing debug message Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 07/20] wic: Turn off debug output for 'bitbake -e' Ed Bartosh
2015-06-30 8:51 ` Ed Bartosh [this message]
2015-06-30 8:51 ` [wic][PATCH v2 09/20] wic: Rename partition images Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 10/20] wic: Get rid of useless variable 'image_rootfs' Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 11/20] wic: Call methods better way Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 12/20] wic: Refactor prepare_empty_partition API Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 13/20] wic: Remove duplicated code Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 14/20] wic: Fix naming conflict Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 15/20] wic: Add --uuid partition option Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 16/20] wic: Refactor fstab update code Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 17/20] wic: Remove __write_partition method Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 18/20] wic: Fix confusing error message Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 19/20] wic: Code cleanup: long lines, identation and whitespaces Ed Bartosh
2015-06-30 8:51 ` [wic][PATCH v2 20/20] wic: Code cleanup: unused imports Ed Bartosh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435654312-18177-9-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox