summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2014-07-10 14:29:27 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-07-16 10:06:24 +0100
commitd9efc110fd73822629b2a3326761f2256b9f23b0 (patch)
treeba1085f9872cda95a8d9d86cdd3a517db6eb32d9 /scripts
parentb1c68e5446080f0743f7f8a530f3b00f90c8717d (diff)
downloadopenembedded-core-d9efc110fd73822629b2a3326761f2256b9f23b0.tar.gz
openembedded-core-d9efc110fd73822629b2a3326761f2256b9f23b0.tar.bz2
openembedded-core-d9efc110fd73822629b2a3326761f2256b9f23b0.zip
wic: Add vfat support
Add vfat as a supported rootfs type (in addition to the current ext2/3/4 and btrfs support). vfat partitions can now be created using --source rootfs along with --fstype=vfat, or without --source but specifying a --size. Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/mic/kickstart/custom_commands/partition.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
index 75ad6ad103..4662bdd75c 100644
--- a/scripts/lib/mic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
@@ -186,6 +186,11 @@ class Wic_PartData(Mic_PartData):
rootfs_dir, native_sysroot,
pseudo)
+ elif self.fstype.startswith("vfat"):
+ return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
+ rootfs_dir, native_sysroot,
+ pseudo)
+
def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
@@ -270,6 +275,53 @@ class Wic_PartData(Mic_PartData):
self.size = rootfs_size
self.source_file = rootfs
+ def prepare_rootfs_vfat(self, cr_workdir, 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)
+
+ du_cmd = "du -bks %s" % image_rootfs
+ rc, out = exec_cmd(du_cmd)
+ blocks = int(out.split()[0])
+
+ extra_blocks = self.get_extra_block_count(blocks)
+
+ if extra_blocks < BOOTDD_EXTRA_SPACE:
+ extra_blocks = BOOTDD_EXTRA_SPACE
+
+ blocks += extra_blocks
+
+ msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
+ (extra_blocks, self.mountpoint, blocks))
+
+ # Ensure total sectors is an integral number of sectors per
+ # track or mcopy will complain. Sectors are 512 bytes, and we
+ # generate images with 32 sectors per track. This calculation is
+ # done in blocks, thus the mod by 16 instead of 32.
+ blocks += (16 - (blocks % 16))
+
+ dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (rootfs, blocks)
+ exec_native_cmd(dosfs_cmd, native_sysroot)
+
+ mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, image_rootfs)
+ rc, out = exec_native_cmd(mcopy_cmd, native_sysroot)
+ if rc:
+ msger.error("ERROR: mcopy returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % rc)
+
+ chmod_cmd = "chmod 644 %s" % rootfs
+ exec_cmd(chmod_cmd)
+
+ # get the rootfs size in the right units for kickstart (Mb)
+ du_cmd = "du -Lbms %s" % rootfs
+ rc, out = exec_cmd(du_cmd)
+ rootfs_size = out.split()[0]
+
+ self.set_size(rootfs_size)
+ self.set_source_file(rootfs)
+
def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
"""
Prepare an empty partition.
@@ -280,6 +332,9 @@ class Wic_PartData(Mic_PartData):
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)
def prepare_empty_partition_ext(self, cr_workdir, oe_builddir,
native_sysroot):
@@ -322,6 +377,25 @@ class Wic_PartData(Mic_PartData):
return 0
+ def prepare_empty_partition_vfat(self, cr_workdir, oe_builddir,
+ native_sysroot):
+ """
+ Prepare an empty vfat partition.
+ """
+ fs = "%s/fs.%s" % (cr_workdir, self.fstype)
+
+ blocks = self.size * 1024
+
+ dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (fs, blocks)
+ exec_native_cmd(dosfs_cmd, native_sysroot)
+
+ chmod_cmd = "chmod 644 %s" % fs
+ exec_cmd(chmod_cmd)
+
+ self.source_file = fs
+
+ return 0
+
def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
"""
Prepare a swap partition.