diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-05 09:13:09 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-11 23:59:11 +0100 |
commit | 0e364973a43b1e117367c7187d9d1cd6caaa0f70 (patch) | |
tree | bb11be66224b0d83086c5f371efd2ee859bc9821 /scripts/lib/wic/utils/partitionedfs.py | |
parent | 4f9fe5b6165f9e8c02af199887404ad1d33e2c74 (diff) | |
download | poky-0e364973a43b1e117367c7187d9d1cd6caaa0f70.tar.gz |
wic: pylinted partitionedfs.py
Fixed some pylint findings in partitionedfs.py
(From OE-Core rev: fcb891a391a34fad15d99edfea6b0f022fc0d1c9)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/utils/partitionedfs.py')
-rw-r--r-- | scripts/lib/wic/utils/partitionedfs.py | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py index dcb63e584a..902548fbf8 100644 --- a/scripts/lib/wic/utils/partitionedfs.py +++ b/scripts/lib/wic/utils/partitionedfs.py | |||
@@ -31,7 +31,7 @@ GPT_OVERHEAD = 34 | |||
31 | # Size of a sector in bytes | 31 | # Size of a sector in bytes |
32 | SECTOR_SIZE = 512 | 32 | SECTOR_SIZE = 512 |
33 | 33 | ||
34 | class Image: | 34 | class Image(object): |
35 | """ | 35 | """ |
36 | Generic base object for an image. | 36 | Generic base object for an image. |
37 | 37 | ||
@@ -58,14 +58,14 @@ class Image: | |||
58 | assert not self._partitions_layed_out | 58 | assert not self._partitions_layed_out |
59 | 59 | ||
60 | self.disks[disk_name] = \ | 60 | self.disks[disk_name] = \ |
61 | { 'disk': None, # Disk object | 61 | {'disk': None, # Disk object |
62 | 'numpart': 0, # Number of allocate partitions | 62 | 'numpart': 0, # Number of allocate partitions |
63 | 'realpart': 0, # Number of partitions in the partition table | 63 | 'realpart': 0, # Number of partitions in the partition table |
64 | 'partitions': [], # Indexes to self.partitions | 64 | 'partitions': [], # Indexes to self.partitions |
65 | 'offset': 0, # Offset of next partition (in sectors) | 65 | 'offset': 0, # Offset of next partition (in sectors) |
66 | # Minimum required disk size to fit all partitions (in bytes) | 66 | # Minimum required disk size to fit all partitions (in bytes) |
67 | 'min_size': 0, | 67 | 'min_size': 0, |
68 | 'ptable_format': "msdos" } # Partition table format | 68 | 'ptable_format': "msdos"} # Partition table format |
69 | 69 | ||
70 | def add_disk(self, disk_name, disk_obj): | 70 | def add_disk(self, disk_name, disk_obj): |
71 | """ Add a disk object which have to be partitioned. More than one disk | 71 | """ Add a disk object which have to be partitioned. More than one disk |
@@ -97,20 +97,20 @@ class Image: | |||
97 | 97 | ||
98 | # We still need partition for "/" or non-subvolume | 98 | # We still need partition for "/" or non-subvolume |
99 | if mountpoint == "/" or not fsopts: | 99 | if mountpoint == "/" or not fsopts: |
100 | part = { 'ks_pnum' : ks_pnum, # Partition number in the KS file | 100 | part = {'ks_pnum': ks_pnum, # Partition number in the KS file |
101 | 'size': size, # In sectors | 101 | 'size': size, # In sectors |
102 | 'mountpoint': mountpoint, # Mount relative to chroot | 102 | 'mountpoint': mountpoint, # Mount relative to chroot |
103 | 'source_file': source_file, # partition contents | 103 | 'source_file': source_file, # partition contents |
104 | 'fstype': fstype, # Filesystem type | 104 | 'fstype': fstype, # Filesystem type |
105 | 'fsopts': fsopts, # Filesystem mount options | 105 | 'fsopts': fsopts, # Filesystem mount options |
106 | 'label': label, # Partition label | 106 | 'label': label, # Partition label |
107 | 'disk_name': disk_name, # physical disk name holding partition | 107 | 'disk_name': disk_name, # physical disk name holding partition |
108 | 'device': None, # kpartx device node for partition | 108 | 'device': None, # kpartx device node for partition |
109 | 'num': None, # Partition number | 109 | 'num': None, # Partition number |
110 | 'boot': boot, # Bootable flag | 110 | 'boot': boot, # Bootable flag |
111 | 'align': align, # Partition alignment | 111 | 'align': align, # Partition alignment |
112 | 'no_table' : no_table, # Partition does not appear in partition table | 112 | 'no_table' : no_table, # Partition does not appear in partition table |
113 | 'part_type' : part_type } # Partition type | 113 | 'part_type' : part_type} # Partition type |
114 | 114 | ||
115 | self.__add_partition(part) | 115 | self.__add_partition(part) |
116 | 116 | ||
@@ -213,7 +213,7 @@ class Image: | |||
213 | 213 | ||
214 | # Once all the partitions have been layed out, we can calculate the | 214 | # Once all the partitions have been layed out, we can calculate the |
215 | # minumim disk sizes. | 215 | # minumim disk sizes. |
216 | for disk_name, d in self.disks.items(): | 216 | for d in self.disks.values(): |
217 | d['min_size'] = d['offset'] | 217 | d['min_size'] = d['offset'] |
218 | if d['ptable_format'] == "gpt": | 218 | if d['ptable_format'] == "gpt": |
219 | d['min_size'] += GPT_OVERHEAD | 219 | d['min_size'] += GPT_OVERHEAD |
@@ -314,14 +314,14 @@ class Image: | |||
314 | 314 | ||
315 | def cleanup(self): | 315 | def cleanup(self): |
316 | if self.disks: | 316 | if self.disks: |
317 | for dev in self.disks.keys(): | 317 | for dev in self.disks: |
318 | d = self.disks[dev] | 318 | d = self.disks[dev] |
319 | try: | 319 | try: |
320 | d['disk'].cleanup() | 320 | d['disk'].cleanup() |
321 | except: | 321 | except: |
322 | pass | 322 | pass |
323 | 323 | ||
324 | def __write_partition(self, num, source_file, start, size): | 324 | def __write_partition(self, num, source_file, start, size, image_file): |
325 | """ | 325 | """ |
326 | Install source_file contents into a partition. | 326 | Install source_file contents into a partition. |
327 | """ | 327 | """ |
@@ -330,23 +330,20 @@ class Image: | |||
330 | 330 | ||
331 | # Start is included in the size so need to substract one from the end. | 331 | # Start is included in the size so need to substract one from the end. |
332 | end = start + size - 1 | 332 | end = start + size - 1 |
333 | msger.debug("Installed %s in partition %d, sectors %d-%d, size %d sectors" % (source_file, num, start, end, size)) | 333 | msger.debug("Installed %s in partition %d, sectors %d-%d, " |
334 | "size %d sectors" % (source_file, num, start, end, size)) | ||
334 | 335 | ||
335 | dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \ | 336 | dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \ |
336 | (source_file, self.image_file, self.sector_size, start, size) | 337 | (source_file, image_file, self.sector_size, start, size) |
337 | exec_cmd(dd_cmd) | 338 | exec_cmd(dd_cmd) |
338 | 339 | ||
339 | 340 | ||
340 | def assemble(self, image_file): | 341 | def assemble(self, image_file): |
341 | msger.debug("Installing partitions") | 342 | msger.debug("Installing partitions") |
342 | 343 | ||
343 | self.image_file = image_file | ||
344 | |||
345 | for p in self.partitions: | 344 | for p in self.partitions: |
346 | d = self.disks[p['disk_name']] | ||
347 | |||
348 | self.__write_partition(p['num'], p['source_file'], | 345 | self.__write_partition(p['num'], p['source_file'], |
349 | p['start'], p['size']) | 346 | p['start'], p['size'], image_file) |
350 | 347 | ||
351 | def create(self): | 348 | def create(self): |
352 | for dev in self.disks.keys(): | 349 | for dev in self.disks.keys(): |