]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: Remove __write_partition method
authorEd Bartosh <ed.bartosh@linux.intel.com>
Mon, 29 Jun 2015 08:19:38 +0000 (11:19 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 Jul 2015 22:01:44 +0000 (23:01 +0100)
Moved code of __write_partition to 'assemble' method.
This way it should be more readable.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
scripts/lib/wic/utils/partitionedfs.py

index d61087a24d34d58f0a79b53507bfd9473b9aef9e..ca4b1f06c0421ea4702732c18b6534fa1b9e8885 100644 (file)
@@ -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():