From f7059362053c87f96ce68d1ab850962defb76540 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Mon, 29 Jun 2015 11:19:38 +0300 Subject: wic: Remove __write_partition method Moved code of __write_partition to 'assemble' method. This way it should be more readable. Signed-off-by: Ed Bartosh --- scripts/lib/wic/utils/partitionedfs.py | 36 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py index d61087a24d..ca4b1f06c0 100644 --- a/scripts/lib/wic/utils/partitionedfs.py +++ b/scripts/lib/wic/utils/partitionedfs.py @@ -334,30 +334,24 @@ class Image(object): except: pass - def __write_partition(self, num, source_file, start, size, image_file): - """ - Install source_file contents into a partition. - """ - if not source_file: # nothing to write - return - - # Start is included in the size so need to substract one from the end. - end = start + size - 1 - msger.debug("Installed %s in partition %d, sectors %d-%d, " - "size %d sectors" % (source_file, num, start, end, size)) - - dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \ - (source_file, image_file, self.sector_size, start, size) - exec_cmd(dd_cmd) - - def assemble(self, image_file): msger.debug("Installing partitions") - for p in self.partitions: - self.__write_partition(p['num'], p['source_file'], - p['start'], p['size'], image_file) - os.rename(p['source_file'], image_file + '.p%d' % p['num']) + for part in self.partitions: + source = part['source_file'] + if source: + # install source_file contents into a partition + cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \ + (source, image_file, self.sector_size, + part['start'], part['size']) + exec_cmd(cmd) + + msger.debug("Installed %s in partition %d, sectors %d-%d, " + "size %d sectors" % \ + (source, part['num'], part['start'], + part['start'] + part['size'] - 1, part['size'])) + + os.rename(source, image_file + '.p%d' % part['num']) def create(self): for dev in self.disks.keys(): -- cgit 1.2.3-korg