summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/imager/direct.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/imager/direct.py')
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py58
1 files changed, 35 insertions, 23 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index a1d152659b..6e1f1c8cba 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -203,6 +203,8 @@ class DirectPlugin(ImagerPlugin):
203 source_plugin = self.ks.bootloader.source 203 source_plugin = self.ks.bootloader.source
204 disk_name = self.parts[0].disk 204 disk_name = self.parts[0].disk
205 if source_plugin: 205 if source_plugin:
206 # Don't support '-' in plugin names
207 source_plugin = source_plugin.replace("-", "_")
206 plugin = PluginMgr.get_plugins('source')[source_plugin] 208 plugin = PluginMgr.get_plugins('source')[source_plugin]
207 plugin.do_install_disk(self._image, disk_name, self, self.workdir, 209 plugin.do_install_disk(self._image, disk_name, self, self.workdir,
208 self.oe_builddir, self.bootimg_dir, 210 self.oe_builddir, self.bootimg_dir,
@@ -321,7 +323,15 @@ class PartitionedImage():
321 self.partitions = partitions 323 self.partitions = partitions
322 self.partimages = [] 324 self.partimages = []
323 # Size of a sector used in calculations 325 # Size of a sector used in calculations
324 self.sector_size = SECTOR_SIZE 326 sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE')
327 if sector_size_str is not None:
328 try:
329 self.sector_size = int(sector_size_str)
330 except ValueError:
331 self.sector_size = SECTOR_SIZE
332 else:
333 self.sector_size = SECTOR_SIZE
334
325 self.native_sysroot = native_sysroot 335 self.native_sysroot = native_sysroot
326 num_real_partitions = len([p for p in self.partitions if not p.no_table]) 336 num_real_partitions = len([p for p in self.partitions if not p.no_table])
327 self.extra_space = extra_space 337 self.extra_space = extra_space
@@ -508,7 +518,8 @@ class PartitionedImage():
508 logger.debug("Added '%s' partition, sectors %d-%d, size %d sectors", 518 logger.debug("Added '%s' partition, sectors %d-%d, size %d sectors",
509 parttype, start, end, size) 519 parttype, start, end, size)
510 520
511 cmd = "parted -s %s unit s mkpart %s" % (device, parttype) 521 cmd = "export PARTED_SECTOR_SIZE=%d; parted -s %s unit s mkpart %s" % \
522 (self.sector_size, device, parttype)
512 if fstype: 523 if fstype:
513 cmd += " %s" % fstype 524 cmd += " %s" % fstype
514 cmd += " %d %d" % (start, end) 525 cmd += " %d %d" % (start, end)
@@ -527,8 +538,8 @@ class PartitionedImage():
527 os.ftruncate(sparse.fileno(), min_size) 538 os.ftruncate(sparse.fileno(), min_size)
528 539
529 logger.debug("Initializing partition table for %s", device) 540 logger.debug("Initializing partition table for %s", device)
530 exec_native_cmd("parted -s %s mklabel %s" % (device, ptable_format), 541 exec_native_cmd("export PARTED_SECTOR_SIZE=%d; parted -s %s mklabel %s" %
531 self.native_sysroot) 542 (self.sector_size, device, ptable_format), self.native_sysroot)
532 543
533 def _write_disk_guid(self): 544 def _write_disk_guid(self):
534 if self.ptable_format in ('gpt', 'gpt-hybrid'): 545 if self.ptable_format in ('gpt', 'gpt-hybrid'):
@@ -538,7 +549,8 @@ class PartitionedImage():
538 self.disk_guid = uuid.uuid4() 549 self.disk_guid = uuid.uuid4()
539 550
540 logger.debug("Set disk guid %s", self.disk_guid) 551 logger.debug("Set disk guid %s", self.disk_guid)
541 sfdisk_cmd = "sfdisk --disk-id %s %s" % (self.path, self.disk_guid) 552 sfdisk_cmd = "sfdisk --sector-size %s --disk-id %s %s" % \
553 (self.sector_size, self.path, self.disk_guid)
542 exec_native_cmd(sfdisk_cmd, self.native_sysroot) 554 exec_native_cmd(sfdisk_cmd, self.native_sysroot)
543 555
544 def create(self): 556 def create(self):
@@ -613,45 +625,44 @@ class PartitionedImage():
613 partition_label = part.part_name if part.part_name else part.label 625 partition_label = part.part_name if part.part_name else part.label
614 logger.debug("partition %d: set name to %s", 626 logger.debug("partition %d: set name to %s",
615 part.num, partition_label) 627 part.num, partition_label)
616 exec_native_cmd("sgdisk --change-name=%d:%s %s" % \ 628 exec_native_cmd("sfdisk --sector-size %s --part-label %s %d %s" % \
617 (part.num, partition_label, 629 (self.sector_size, self.path, part.num,
618 self.path), self.native_sysroot) 630 partition_label), self.native_sysroot)
619
620 if part.part_type: 631 if part.part_type:
621 logger.debug("partition %d: set type UID to %s", 632 logger.debug("partition %d: set type UID to %s",
622 part.num, part.part_type) 633 part.num, part.part_type)
623 exec_native_cmd("sgdisk --typecode=%d:%s %s" % \ 634 exec_native_cmd("sfdisk --sector-size %s --part-type %s %d %s" % \
624 (part.num, part.part_type, 635 (self.sector_size, self.path, part.num,
625 self.path), self.native_sysroot) 636 part.part_type), self.native_sysroot)
626 637
627 if part.uuid and self.ptable_format in ("gpt", "gpt-hybrid"): 638 if part.uuid and self.ptable_format in ("gpt", "gpt-hybrid"):
628 logger.debug("partition %d: set UUID to %s", 639 logger.debug("partition %d: set UUID to %s",
629 part.num, part.uuid) 640 part.num, part.uuid)
630 exec_native_cmd("sgdisk --partition-guid=%d:%s %s" % \ 641 exec_native_cmd("sfdisk --sector-size %s --part-uuid %s %d %s" % \
631 (part.num, part.uuid, self.path), 642 (self.sector_size, self.path, part.num, part.uuid),
632 self.native_sysroot) 643 self.native_sysroot)
633 644
634 if part.active: 645 if part.active:
635 flag_name = "legacy_boot" if self.ptable_format in ('gpt', 'gpt-hybrid') else "boot" 646 flag_name = "legacy_boot" if self.ptable_format in ('gpt', 'gpt-hybrid') else "boot"
636 logger.debug("Set '%s' flag for partition '%s' on disk '%s'", 647 logger.debug("Set '%s' flag for partition '%s' on disk '%s'",
637 flag_name, part.num, self.path) 648 flag_name, part.num, self.path)
638 exec_native_cmd("parted -s %s set %d %s on" % \ 649 exec_native_cmd("export PARTED_SECTOR_SIZE=%d; parted -s %s set %d %s on" % \
639 (self.path, part.num, flag_name), 650 (self.sector_size, self.path, part.num, flag_name),
640 self.native_sysroot) 651 self.native_sysroot)
641 if self.ptable_format == 'gpt-hybrid' and part.mbr: 652 if self.ptable_format == 'gpt-hybrid' and part.mbr:
642 exec_native_cmd("parted -s %s set %d %s on" % \ 653 exec_native_cmd("export PARTED_SECTOR_SIZE=%d; parted -s %s set %d %s on" % \
643 (mbr_path, hybrid_mbr_part_num, "boot"), 654 (self.sector_size, mbr_path, hybrid_mbr_part_num, "boot"),
644 self.native_sysroot) 655 self.native_sysroot)
645 if part.system_id: 656 if part.system_id:
646 exec_native_cmd("sfdisk --part-type %s %s %s" % \ 657 exec_native_cmd("sfdisk --sector-size %s --part-type %s %s %s" % \
647 (self.path, part.num, part.system_id), 658 (self.sector_size, self.path, part.num, part.system_id),
648 self.native_sysroot) 659 self.native_sysroot)
649 660
650 if part.hidden and self.ptable_format == "gpt": 661 if part.hidden and self.ptable_format == "gpt":
651 logger.debug("Set hidden attribute for partition '%s' on disk '%s'", 662 logger.debug("Set hidden attribute for partition '%s' on disk '%s'",
652 part.num, self.path) 663 part.num, self.path)
653 exec_native_cmd("sfdisk --part-attrs %s %s RequiredPartition" % \ 664 exec_native_cmd("sfdisk --sector-size %s --part-attrs %s %s RequiredPartition" % \
654 (self.path, part.num), 665 (self.sector_size, self.path, part.num),
655 self.native_sysroot) 666 self.native_sysroot)
656 667
657 if self.ptable_format == "gpt-hybrid": 668 if self.ptable_format == "gpt-hybrid":
@@ -664,7 +675,8 @@ class PartitionedImage():
664 # create with an arbitrary type, then change it to the correct type 675 # create with an arbitrary type, then change it to the correct type
665 # with sfdisk 676 # with sfdisk
666 self._create_partition(mbr_path, "primary", "fat32", 1, GPT_OVERHEAD) 677 self._create_partition(mbr_path, "primary", "fat32", 1, GPT_OVERHEAD)
667 exec_native_cmd("sfdisk --part-type %s %d 0xee" % (mbr_path, hybrid_mbr_part_num), 678 exec_native_cmd("sfdisk --sector-size %s --part-type %s %d 0xee" % \
679 (self.sector_size, mbr_path, hybrid_mbr_part_num),
668 self.native_sysroot) 680 self.native_sysroot)
669 681
670 # Copy hybrid MBR 682 # Copy hybrid MBR