summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/mic/kickstart/custom_commands/partition.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
index 06f29a9885..3b652b399c 100644
--- a/scripts/lib/mic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
@@ -25,6 +25,8 @@
25# 25#
26 26
27import shutil 27import shutil
28import os
29import tempfile
28 30
29from pykickstart.commands.partition import * 31from pykickstart.commands.partition import *
30from mic.utils.oe.misc import * 32from mic.utils.oe.misc import *
@@ -192,6 +194,10 @@ class Wic_PartData(Mic_PartData):
192 return self.prepare_rootfs_vfat(cr_workdir, oe_builddir, 194 return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
193 rootfs_dir, native_sysroot, 195 rootfs_dir, native_sysroot,
194 pseudo) 196 pseudo)
197 elif self.fstype.startswith("squashfs"):
198 return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir,
199 rootfs_dir, native_sysroot,
200 pseudo)
195 201
196 def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir, 202 def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
197 native_sysroot, pseudo): 203 native_sysroot, pseudo):
@@ -324,6 +330,28 @@ class Wic_PartData(Mic_PartData):
324 self.set_size(rootfs_size) 330 self.set_size(rootfs_size)
325 self.set_source_file(rootfs) 331 self.set_source_file(rootfs)
326 332
333 def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir,
334 native_sysroot, pseudo):
335 """
336 Prepare content for a squashfs rootfs partition.
337 """
338 image_rootfs = rootfs_dir
339 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
340
341 squashfs_cmd = "mksquashfs %s %s -noappend" % \
342 (image_rootfs, rootfs)
343 rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
344
345 # get the rootfs size in the right units for kickstart (Mb)
346 du_cmd = "du -Lbms %s" % rootfs
347 rc, out = exec_cmd(du_cmd)
348 rootfs_size = out.split()[0]
349
350 self.size = rootfs_size
351 self.source_file = rootfs
352
353 return 0
354
327 def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot): 355 def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
328 """ 356 """
329 Prepare an empty partition. 357 Prepare an empty partition.
@@ -337,6 +365,9 @@ class Wic_PartData(Mic_PartData):
337 elif self.fstype.startswith("vfat"): 365 elif self.fstype.startswith("vfat"):
338 return self.prepare_empty_partition_vfat(cr_workdir, oe_builddir, 366 return self.prepare_empty_partition_vfat(cr_workdir, oe_builddir,
339 native_sysroot) 367 native_sysroot)
368 elif self.fstype.startswith("squashfs"):
369 return self.prepare_empty_partition_squashfs(cr_workdir, oe_builddir,
370 native_sysroot)
340 371
341 def prepare_empty_partition_ext(self, cr_workdir, oe_builddir, 372 def prepare_empty_partition_ext(self, cr_workdir, oe_builddir,
342 native_sysroot): 373 native_sysroot):
@@ -398,6 +429,36 @@ class Wic_PartData(Mic_PartData):
398 429
399 return 0 430 return 0
400 431
432 def prepare_empty_partition_squashfs(self, cr_workdir, oe_builddir,
433 native_sysroot):
434 """
435 Prepare an empty squashfs partition.
436 """
437 msger.warning("Creating of an empty squashfs %s partition was attempted. " \
438 "Proceeding as requested." % self.mountpoint)
439
440 fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
441
442 # it is not possible to create a squashfs without source data,
443 # thus prepare an empty temp dir that is used as source
444 tmpdir = tempfile.mkdtemp()
445
446 squashfs_cmd = "mksquashfs %s %s -noappend" % \
447 (tmpdir, fs)
448 rc, out = exec_native_cmd(squashfs_cmd, native_sysroot)
449
450 os.rmdir(tmpdir)
451
452 # get the rootfs size in the right units for kickstart (Mb)
453 du_cmd = "du -Lbms %s" % fs
454 rc, out = exec_cmd(du_cmd)
455 fs_size = out.split()[0]
456
457 self.size = fs_size
458 self.source_file = fs
459
460 return 0
461
401 def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot): 462 def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
402 """ 463 """
403 Prepare a swap partition. 464 Prepare a swap partition.