summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
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):
186 rootfs_dir, native_sysroot, 186 rootfs_dir, native_sysroot,
187 pseudo) 187 pseudo)
188 188
189 elif self.fstype.startswith("vfat"):
190 return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
191 rootfs_dir, native_sysroot,
192 pseudo)
193
189 def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir, 194 def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
190 native_sysroot, pseudo): 195 native_sysroot, pseudo):
191 """ 196 """
@@ -270,6 +275,53 @@ class Wic_PartData(Mic_PartData):
270 self.size = rootfs_size 275 self.size = rootfs_size
271 self.source_file = rootfs 276 self.source_file = rootfs
272 277
278 def prepare_rootfs_vfat(self, cr_workdir, oe_builddir, rootfs_dir,
279 native_sysroot, pseudo):
280 """
281 Prepare content for a vfat rootfs partition.
282 """
283 image_rootfs = rootfs_dir
284 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
285
286 du_cmd = "du -bks %s" % image_rootfs
287 rc, out = exec_cmd(du_cmd)
288 blocks = int(out.split()[0])
289
290 extra_blocks = self.get_extra_block_count(blocks)
291
292 if extra_blocks < BOOTDD_EXTRA_SPACE:
293 extra_blocks = BOOTDD_EXTRA_SPACE
294
295 blocks += extra_blocks
296
297 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
298 (extra_blocks, self.mountpoint, blocks))
299
300 # Ensure total sectors is an integral number of sectors per
301 # track or mcopy will complain. Sectors are 512 bytes, and we
302 # generate images with 32 sectors per track. This calculation is
303 # done in blocks, thus the mod by 16 instead of 32.
304 blocks += (16 - (blocks % 16))
305
306 dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (rootfs, blocks)
307 exec_native_cmd(dosfs_cmd, native_sysroot)
308
309 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, image_rootfs)
310 rc, out = exec_native_cmd(mcopy_cmd, native_sysroot)
311 if rc:
312 msger.error("ERROR: mcopy returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % rc)
313
314 chmod_cmd = "chmod 644 %s" % rootfs
315 exec_cmd(chmod_cmd)
316
317 # get the rootfs size in the right units for kickstart (Mb)
318 du_cmd = "du -Lbms %s" % rootfs
319 rc, out = exec_cmd(du_cmd)
320 rootfs_size = out.split()[0]
321
322 self.set_size(rootfs_size)
323 self.set_source_file(rootfs)
324
273 def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot): 325 def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
274 """ 326 """
275 Prepare an empty partition. 327 Prepare an empty partition.
@@ -280,6 +332,9 @@ class Wic_PartData(Mic_PartData):
280 elif self.fstype.startswith("btrfs"): 332 elif self.fstype.startswith("btrfs"):
281 return self.prepare_empty_partition_btrfs(cr_workdir, oe_builddir, 333 return self.prepare_empty_partition_btrfs(cr_workdir, oe_builddir,
282 native_sysroot) 334 native_sysroot)
335 elif self.fstype.startswith("vfat"):
336 return self.prepare_empty_partition_vfat(cr_workdir, oe_builddir,
337 native_sysroot)
283 338
284 def prepare_empty_partition_ext(self, cr_workdir, oe_builddir, 339 def prepare_empty_partition_ext(self, cr_workdir, oe_builddir,
285 native_sysroot): 340 native_sysroot):
@@ -322,6 +377,25 @@ class Wic_PartData(Mic_PartData):
322 377
323 return 0 378 return 0
324 379
380 def prepare_empty_partition_vfat(self, cr_workdir, oe_builddir,
381 native_sysroot):
382 """
383 Prepare an empty vfat partition.
384 """
385 fs = "%s/fs.%s" % (cr_workdir, self.fstype)
386
387 blocks = self.size * 1024
388
389 dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (fs, blocks)
390 exec_native_cmd(dosfs_cmd, native_sysroot)
391
392 chmod_cmd = "chmod 644 %s" % fs
393 exec_cmd(chmod_cmd)
394
395 self.source_file = fs
396
397 return 0
398
325 def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot): 399 def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
326 """ 400 """
327 Prepare a swap partition. 401 Prepare a swap partition.