diff options
| author | Maciej Borzecki <maciej.borzecki@open-rnd.pl> | 2014-07-24 14:11:50 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-07-25 16:54:43 +0100 |
| commit | 73ce04eb6d538d1a924c6a0867b39cbe44e2f215 (patch) | |
| tree | e08f1c6caacba5d58946d5a1adb67ae254add9b8 /scripts/lib | |
| parent | 5e7de54d3d444e4a1b7f7c2a4d20ae7d5ab2fbba (diff) | |
| download | poky-73ce04eb6d538d1a924c6a0867b39cbe44e2f215.tar.gz | |
wic: squashfs partition support
It is possible to instruct wic to create a squashfs partition by setting
--fstype=squashfs in *.wks. For now this is only useable for rootfs
partitions (note that you must have squashfs support in the kernel). An
attempt to create an empty partition will produce a warning.
(From OE-Core rev: 30266a0be946bd0ce76d6920e7afe840c6c3bf80)
Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/mic/kickstart/custom_commands/partition.py | 61 |
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 | ||
| 27 | import shutil | 27 | import shutil |
| 28 | import os | ||
| 29 | import tempfile | ||
| 28 | 30 | ||
| 29 | from pykickstart.commands.partition import * | 31 | from pykickstart.commands.partition import * |
| 30 | from mic.utils.oe.misc import * | 32 | from 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. |
