summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/utils
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-09-02 13:58:16 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-03 12:43:31 +0100
commit791a3912d98014105bdb2a8585e4a1b7ae8120b1 (patch)
treebcfb06b795482f6113cfa6b5c967a0bbb9b4bc1c /scripts/lib/wic/utils
parent14b47e22f9b2566320ab6ef103da1501bca129de (diff)
downloadpoky-791a3912d98014105bdb2a8585e4a1b7ae8120b1.tar.gz
wic: fix short variable names
Made short variable names longer and more readable. Fixed pylint warnings "Invalid variable name" and "Invalid argument name". (From OE-Core rev: 872cb0d5d79b26f34e6b35d7be8870d245021be4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/utils')
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py154
-rw-r--r--scripts/lib/wic/utils/runner.py16
2 files changed, 85 insertions, 85 deletions
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 2f884a3cb8..5a103bbc7e 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -129,14 +129,14 @@ class Image(object):
129 self._partitions_layed_out = True 129 self._partitions_layed_out = True
130 130
131 # Go through partitions in the order they are added in .ks file 131 # Go through partitions in the order they are added in .ks file
132 for n in range(len(self.partitions)): 132 for num in range(len(self.partitions)):
133 p = self.partitions[n] 133 part = self.partitions[num]
134 134
135 if not self.disks.has_key(p['disk_name']): 135 if not self.disks.has_key(part['disk_name']):
136 raise ImageError("No disk %s for partition %s" \ 136 raise ImageError("No disk %s for partition %s" \
137 % (p['disk_name'], p['mountpoint'])) 137 % (part['disk_name'], part['mountpoint']))
138 138
139 if ptable_format == 'msdos' and p['part_type']: 139 if ptable_format == 'msdos' and part['part_type']:
140 # The --part-type can also be implemented for MBR partitions, 140 # The --part-type can also be implemented for MBR partitions,
141 # in which case it would map to the 1-byte "partition type" 141 # in which case it would map to the 1-byte "partition type"
142 # filed at offset 3 of the partition entry. 142 # filed at offset 3 of the partition entry.
@@ -144,79 +144,79 @@ class Image(object):
144 "implemented for msdos partitions") 144 "implemented for msdos partitions")
145 145
146 # Get the disk where the partition is located 146 # Get the disk where the partition is located
147 d = self.disks[p['disk_name']] 147 disk = self.disks[part['disk_name']]
148 d['numpart'] += 1 148 disk['numpart'] += 1
149 if not p['no_table']: 149 if not part['no_table']:
150 d['realpart'] += 1 150 disk['realpart'] += 1
151 d['ptable_format'] = ptable_format 151 disk['ptable_format'] = ptable_format
152 152
153 if d['numpart'] == 1: 153 if disk['numpart'] == 1:
154 if ptable_format == "msdos": 154 if ptable_format == "msdos":
155 overhead = MBR_OVERHEAD 155 overhead = MBR_OVERHEAD
156 elif ptable_format == "gpt": 156 elif ptable_format == "gpt":
157 overhead = GPT_OVERHEAD 157 overhead = GPT_OVERHEAD
158 158
159 # Skip one sector required for the partitioning scheme overhead 159 # Skip one sector required for the partitioning scheme overhead
160 d['offset'] += overhead 160 disk['offset'] += overhead
161 161
162 if d['realpart'] > 3: 162 if disk['realpart'] > 3:
163 # Reserve a sector for EBR for every logical partition 163 # Reserve a sector for EBR for every logical partition
164 # before alignment is performed. 164 # before alignment is performed.
165 if ptable_format == "msdos": 165 if ptable_format == "msdos":
166 d['offset'] += 1 166 disk['offset'] += 1
167 167
168 168
169 if p['align']: 169 if part['align']:
170 # If not first partition and we do have alignment set we need 170 # If not first partition and we do have alignment set we need
171 # to align the partition. 171 # to align the partition.
172 # FIXME: This leaves a empty spaces to the disk. To fill the 172 # FIXME: This leaves a empty spaces to the disk. To fill the
173 # gaps we could enlargea the previous partition? 173 # gaps we could enlargea the previous partition?
174 174
175 # Calc how much the alignment is off. 175 # Calc how much the alignment is off.
176 align_sectors = d['offset'] % (p['align'] * 1024 / self.sector_size) 176 align_sectors = disk['offset'] % (part['align'] * 1024 / self.sector_size)
177 177
178 if align_sectors: 178 if align_sectors:
179 # If partition is not aligned as required, we need 179 # If partition is not aligned as required, we need
180 # to move forward to the next alignment point 180 # to move forward to the next alignment point
181 align_sectors = (p['align'] * 1024 / self.sector_size) - align_sectors 181 align_sectors = (part['align'] * 1024 / self.sector_size) - align_sectors
182 182
183 msger.debug("Realignment for %s%s with %s sectors, original" 183 msger.debug("Realignment for %s%s with %s sectors, original"
184 " offset %s, target alignment is %sK." % 184 " offset %s, target alignment is %sK." %
185 (p['disk_name'], d['numpart'], align_sectors, 185 (part['disk_name'], disk['numpart'], align_sectors,
186 d['offset'], p['align'])) 186 disk['offset'], part['align']))
187 187
188 # increase the offset so we actually start the partition on right alignment 188 # increase the offset so we actually start the partition on right alignment
189 d['offset'] += align_sectors 189 disk['offset'] += align_sectors
190 190
191 p['start'] = d['offset'] 191 part['start'] = disk['offset']
192 d['offset'] += p['size'] 192 disk['offset'] += part['size']
193 193
194 p['type'] = 'primary' 194 part['type'] = 'primary'
195 if not p['no_table']: 195 if not part['no_table']:
196 p['num'] = d['realpart'] 196 part['num'] = disk['realpart']
197 else: 197 else:
198 p['num'] = 0 198 part['num'] = 0
199 199
200 if d['ptable_format'] == "msdos": 200 if disk['ptable_format'] == "msdos":
201 if d['realpart'] > 3: 201 if disk['realpart'] > 3:
202 p['type'] = 'logical' 202 part['type'] = 'logical'
203 p['num'] = d['realpart'] + 1 203 part['num'] = disk['realpart'] + 1
204 204
205 d['partitions'].append(n) 205 disk['partitions'].append(num)
206 msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d " 206 msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d "
207 "sectors (%d bytes)." \ 207 "sectors (%d bytes)." \
208 % (p['mountpoint'], p['disk_name'], p['num'], 208 % (part['mountpoint'], part['disk_name'], part['num'],
209 p['start'], p['start'] + p['size'] - 1, 209 part['start'], part['start'] + part['size'] - 1,
210 p['size'], p['size'] * self.sector_size)) 210 part['size'], part['size'] * self.sector_size))
211 211
212 # Once all the partitions have been layed out, we can calculate the 212 # Once all the partitions have been layed out, we can calculate the
213 # minumim disk sizes. 213 # minumim disk sizes.
214 for d in self.disks.values(): 214 for disk in self.disks.values():
215 d['min_size'] = d['offset'] 215 disk['min_size'] = disk['offset']
216 if d['ptable_format'] == "gpt": 216 if disk['ptable_format'] == "gpt":
217 d['min_size'] += GPT_OVERHEAD 217 disk['min_size'] += GPT_OVERHEAD
218 218
219 d['min_size'] *= self.sector_size 219 disk['min_size'] *= self.sector_size
220 220
221 def __create_partition(self, device, parttype, fstype, start, size): 221 def __create_partition(self, device, parttype, fstype, start, size):
222 """ Create a partition on an image described by the 'device' object. """ 222 """ Create a partition on an image described by the 'device' object. """
@@ -237,21 +237,21 @@ class Image(object):
237 self.layout_partitions() 237 self.layout_partitions()
238 238
239 for dev in self.disks.keys(): 239 for dev in self.disks.keys():
240 d = self.disks[dev] 240 disk = self.disks[dev]
241 msger.debug("Initializing partition table for %s" % \ 241 msger.debug("Initializing partition table for %s" % \
242 (d['disk'].device)) 242 (disk['disk'].device))
243 exec_native_cmd("parted -s %s mklabel %s" % \ 243 exec_native_cmd("parted -s %s mklabel %s" % \
244 (d['disk'].device, d['ptable_format']), 244 (disk['disk'].device, disk['ptable_format']),
245 self.native_sysroot) 245 self.native_sysroot)
246 246
247 msger.debug("Creating partitions") 247 msger.debug("Creating partitions")
248 248
249 for p in self.partitions: 249 for part in self.partitions:
250 if p['num'] == 0: 250 if part['num'] == 0:
251 continue 251 continue
252 252
253 d = self.disks[p['disk_name']] 253 disk = self.disks[part['disk_name']]
254 if d['ptable_format'] == "msdos" and p['num'] == 5: 254 if disk['ptable_format'] == "msdos" and part['num'] == 5:
255 # Create an extended partition (note: extended 255 # Create an extended partition (note: extended
256 # partition is described in MBR and contains all 256 # partition is described in MBR and contains all
257 # logical partitions). The logical partitions save a 257 # logical partitions). The logical partitions save a
@@ -263,17 +263,17 @@ class Image(object):
263 # starts a sector before the first logical partition, 263 # starts a sector before the first logical partition,
264 # add a sector at the back, so that there is enough 264 # add a sector at the back, so that there is enough
265 # room for all logical partitions. 265 # room for all logical partitions.
266 self.__create_partition(d['disk'].device, "extended", 266 self.__create_partition(disk['disk'].device, "extended",
267 None, p['start'] - 1, 267 None, part['start'] - 1,
268 d['offset'] - p['start'] + 1) 268 disk['offset'] - part['start'] + 1)
269 269
270 if p['fstype'] == "swap": 270 if part['fstype'] == "swap":
271 parted_fs_type = "linux-swap" 271 parted_fs_type = "linux-swap"
272 elif p['fstype'] == "vfat": 272 elif part['fstype'] == "vfat":
273 parted_fs_type = "fat32" 273 parted_fs_type = "fat32"
274 elif p['fstype'] == "msdos": 274 elif part['fstype'] == "msdos":
275 parted_fs_type = "fat16" 275 parted_fs_type = "fat16"
276 elif p['fstype'] == "ontrackdm6aux3": 276 elif part['fstype'] == "ontrackdm6aux3":
277 parted_fs_type = "ontrackdm6aux3" 277 parted_fs_type = "ontrackdm6aux3"
278 else: 278 else:
279 # Type for ext2/ext3/ext4/btrfs 279 # Type for ext2/ext3/ext4/btrfs
@@ -281,55 +281,55 @@ class Image(object):
281 281
282 # Boot ROM of OMAP boards require vfat boot partition to have an 282 # Boot ROM of OMAP boards require vfat boot partition to have an
283 # even number of sectors. 283 # even number of sectors.
284 if p['mountpoint'] == "/boot" and p['fstype'] in ["vfat", "msdos"] \ 284 if part['mountpoint'] == "/boot" and part['fstype'] in ["vfat", "msdos"] \
285 and p['size'] % 2: 285 and part['size'] % 2:
286 msger.debug("Substracting one sector from '%s' partition to " \ 286 msger.debug("Substracting one sector from '%s' partition to " \
287 "get even number of sectors for the partition" % \ 287 "get even number of sectors for the partition" % \
288 p['mountpoint']) 288 part['mountpoint'])
289 p['size'] -= 1 289 part['size'] -= 1
290 290
291 self.__create_partition(d['disk'].device, p['type'], 291 self.__create_partition(disk['disk'].device, part['type'],
292 parted_fs_type, p['start'], p['size']) 292 parted_fs_type, part['start'], part['size'])
293 293
294 if p['part_type']: 294 if part['part_type']:
295 msger.debug("partition %d: set type UID to %s" % \ 295 msger.debug("partition %d: set type UID to %s" % \
296 (p['num'], p['part_type'])) 296 (part['num'], part['part_type']))
297 exec_native_cmd("sgdisk --typecode=%d:%s %s" % \ 297 exec_native_cmd("sgdisk --typecode=%d:%s %s" % \
298 (p['num'], p['part_type'], 298 (part['num'], part['part_type'],
299 d['disk'].device), self.native_sysroot) 299 disk['disk'].device), self.native_sysroot)
300 300
301 if p['uuid']: 301 if part['uuid']:
302 msger.debug("partition %d: set UUID to %s" % \ 302 msger.debug("partition %d: set UUID to %s" % \
303 (p['num'], p['uuid'])) 303 (part['num'], part['uuid']))
304 exec_native_cmd("sgdisk --partition-guid=%d:%s %s" % \ 304 exec_native_cmd("sgdisk --partition-guid=%d:%s %s" % \
305 (p['num'], p['uuid'], d['disk'].device), 305 (part['num'], part['uuid'], disk['disk'].device),
306 self.native_sysroot) 306 self.native_sysroot)
307 307
308 if p['boot']: 308 if part['boot']:
309 flag_name = "legacy_boot" if d['ptable_format'] == 'gpt' else "boot" 309 flag_name = "legacy_boot" if disk['ptable_format'] == 'gpt' else "boot"
310 msger.debug("Set '%s' flag for partition '%s' on disk '%s'" % \ 310 msger.debug("Set '%s' flag for partition '%s' on disk '%s'" % \
311 (flag_name, p['num'], d['disk'].device)) 311 (flag_name, part['num'], disk['disk'].device))
312 exec_native_cmd("parted -s %s set %d %s on" % \ 312 exec_native_cmd("parted -s %s set %d %s on" % \
313 (d['disk'].device, p['num'], flag_name), 313 (disk['disk'].device, part['num'], flag_name),
314 self.native_sysroot) 314 self.native_sysroot)
315 315
316 # Parted defaults to enabling the lba flag for fat16 partitions, 316 # Parted defaults to enabling the lba flag for fat16 partitions,
317 # which causes compatibility issues with some firmware (and really 317 # which causes compatibility issues with some firmware (and really
318 # isn't necessary). 318 # isn't necessary).
319 if parted_fs_type == "fat16": 319 if parted_fs_type == "fat16":
320 if d['ptable_format'] == 'msdos': 320 if disk['ptable_format'] == 'msdos':
321 msger.debug("Disable 'lba' flag for partition '%s' on disk '%s'" % \ 321 msger.debug("Disable 'lba' flag for partition '%s' on disk '%s'" % \
322 (p['num'], d['disk'].device)) 322 (part['num'], disk['disk'].device))
323 exec_native_cmd("parted -s %s set %d lba off" % \ 323 exec_native_cmd("parted -s %s set %d lba off" % \
324 (d['disk'].device, p['num']), 324 (disk['disk'].device, part['num']),
325 self.native_sysroot) 325 self.native_sysroot)
326 326
327 def cleanup(self): 327 def cleanup(self):
328 if self.disks: 328 if self.disks:
329 for dev in self.disks: 329 for dev in self.disks:
330 d = self.disks[dev] 330 disk = self.disks[dev]
331 try: 331 try:
332 d['disk'].cleanup() 332 disk['disk'].cleanup()
333 except: 333 except:
334 pass 334 pass
335 335
@@ -354,8 +354,8 @@ class Image(object):
354 354
355 def create(self): 355 def create(self):
356 for dev in self.disks.keys(): 356 for dev in self.disks.keys():
357 d = self.disks[dev] 357 disk = self.disks[dev]
358 d['disk'].create() 358 disk['disk'].create()
359 359
360 self.__format_disks() 360 self.__format_disks()
361 361
diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py
index f6a1d0828c..7431917ff0 100644
--- a/scripts/lib/wic/utils/runner.py
+++ b/scripts/lib/wic/utils/runner.py
@@ -62,13 +62,13 @@ def runtool(cmdln_or_args, catch=1):
62 serr = subprocess.STDOUT 62 serr = subprocess.STDOUT
63 63
64 try: 64 try:
65 p = subprocess.Popen(cmdln_or_args, stdout=sout, 65 process = subprocess.Popen(cmdln_or_args, stdout=sout,
66 stderr=serr, shell=shell) 66 stderr=serr, shell=shell)
67 (sout, serr) = p.communicate() 67 (sout, serr) = process.communicate()
68 # combine stdout and stderr, filter None out 68 # combine stdout and stderr, filter None out
69 out = ''.join(filter(None, [sout, serr])) 69 out = ''.join(filter(None, [sout, serr]))
70 except OSError, e: 70 except OSError, err:
71 if e.errno == 2: 71 if err.errno == 2:
72 # [Errno 2] No such file or directory 72 # [Errno 2] No such file or directory
73 msger.error('Cannot run command: %s, lost dependency?' % cmd) 73 msger.error('Cannot run command: %s, lost dependency?' % cmd)
74 else: 74 else:
@@ -77,12 +77,12 @@ def runtool(cmdln_or_args, catch=1):
77 if catch != 3: 77 if catch != 3:
78 os.close(dev_null) 78 os.close(dev_null)
79 79
80 return (p.returncode, out) 80 return (process.returncode, out)
81 81
82def show(cmdln_or_args): 82def show(cmdln_or_args):
83 # show all the message using msger.verbose 83 # show all the message using msger.verbose
84 84
85 rc, out = runtool(cmdln_or_args, catch=3) 85 rcode, out = runtool(cmdln_or_args, catch=3)
86 86
87 if isinstance(cmdln_or_args, list): 87 if isinstance(cmdln_or_args, list):
88 cmd = ' '.join(cmdln_or_args) 88 cmd = ' '.join(cmdln_or_args)
@@ -100,7 +100,7 @@ def show(cmdln_or_args):
100 msg += '\n +----------------' 100 msg += '\n +----------------'
101 101
102 msger.verbose(msg) 102 msger.verbose(msg)
103 return rc 103 return rcode
104 104
105def outs(cmdln_or_args, catch=1): 105def outs(cmdln_or_args, catch=1):
106 # get the outputs of tools 106 # get the outputs of tools