summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/utils/partitionedfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/utils/partitionedfs.py')
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py36
1 files 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):
334 except: 334 except:
335 pass 335 pass
336 336
337 def __write_partition(self, num, source_file, start, size, image_file):
338 """
339 Install source_file contents into a partition.
340 """
341 if not source_file: # nothing to write
342 return
343
344 # Start is included in the size so need to substract one from the end.
345 end = start + size - 1
346 msger.debug("Installed %s in partition %d, sectors %d-%d, "
347 "size %d sectors" % (source_file, num, start, end, size))
348
349 dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \
350 (source_file, image_file, self.sector_size, start, size)
351 exec_cmd(dd_cmd)
352
353
354 def assemble(self, image_file): 337 def assemble(self, image_file):
355 msger.debug("Installing partitions") 338 msger.debug("Installing partitions")
356 339
357 for p in self.partitions: 340 for part in self.partitions:
358 self.__write_partition(p['num'], p['source_file'], 341 source = part['source_file']
359 p['start'], p['size'], image_file) 342 if source:
360 os.rename(p['source_file'], image_file + '.p%d' % p['num']) 343 # install source_file contents into a partition
344 cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \
345 (source, image_file, self.sector_size,
346 part['start'], part['size'])
347 exec_cmd(cmd)
348
349 msger.debug("Installed %s in partition %d, sectors %d-%d, "
350 "size %d sectors" % \
351 (source, part['num'], part['start'],
352 part['start'] + part['size'] - 1, part['size']))
353
354 os.rename(source, image_file + '.p%d' % part['num'])
361 355
362 def create(self): 356 def create(self):
363 for dev in self.disks.keys(): 357 for dev in self.disks.keys():