diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-05-21 10:29:52 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-09 16:37:44 -0700 |
commit | 6dd71217a85cbd7173dfcc4dc9e416c0c451bc9c (patch) | |
tree | bd8b2fc879e41f11640a7c32c8b1b929ed086f6e /scripts | |
parent | 417c86b42bcadb16e6db4296dadcb324b13725fd (diff) | |
download | poky-6dd71217a85cbd7173dfcc4dc9e416c0c451bc9c.tar.gz |
wic: Make sure file exists before removing it
Bunch of os.remove calls were added to the partition.py lately.
They're causing wic to fail with OSError: [Errno 2] No such file or directory
if file doesn't exist.
Added check for file existence to all recently added calls of
os.remove. That should fix this regression.
(From OE-Core rev: 75162b05b5ad9aac307f7911caecb2b8a017acbf)
(From OE-Core rev: 41f08393643ceb2607cad44d2c485b3dc9da7ec9)
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')
-rw-r--r-- | scripts/lib/wic/kickstart/custom_commands/partition.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py index 654c38023b..7cfeec4dd2 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py | |||
@@ -231,7 +231,7 @@ class Wic_PartData(Mic_PartData): | |||
231 | image_rootfs = rootfs_dir | 231 | image_rootfs = rootfs_dir |
232 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) | 232 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) |
233 | 233 | ||
234 | os.remove(rootfs) | 234 | os.path.isfile(rootfs) and os.remove(rootfs) |
235 | du_cmd = "du -ks %s" % image_rootfs | 235 | du_cmd = "du -ks %s" % image_rootfs |
236 | out = exec_cmd(du_cmd) | 236 | out = exec_cmd(du_cmd) |
237 | actual_rootfs_size = int(out.split()[0]) | 237 | actual_rootfs_size = int(out.split()[0]) |
@@ -283,7 +283,7 @@ class Wic_PartData(Mic_PartData): | |||
283 | image_rootfs = rootfs_dir | 283 | image_rootfs = rootfs_dir |
284 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) | 284 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) |
285 | 285 | ||
286 | os.remove(rootfs) | 286 | os.path.isfile(rootfs) and os.remove(rootfs) |
287 | du_cmd = "du -ks %s" % image_rootfs | 287 | du_cmd = "du -ks %s" % image_rootfs |
288 | out = exec_cmd(du_cmd) | 288 | out = exec_cmd(du_cmd) |
289 | actual_rootfs_size = int(out.split()[0]) | 289 | actual_rootfs_size = int(out.split()[0]) |
@@ -328,7 +328,7 @@ class Wic_PartData(Mic_PartData): | |||
328 | image_rootfs = rootfs_dir | 328 | image_rootfs = rootfs_dir |
329 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) | 329 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) |
330 | 330 | ||
331 | os.remove(rootfs) | 331 | os.path.isfile(rootfs) and os.remove(rootfs) |
332 | du_cmd = "du -bks %s" % image_rootfs | 332 | du_cmd = "du -bks %s" % image_rootfs |
333 | out = exec_cmd(du_cmd) | 333 | out = exec_cmd(du_cmd) |
334 | blocks = int(out.split()[0]) | 334 | blocks = int(out.split()[0]) |
@@ -381,7 +381,7 @@ class Wic_PartData(Mic_PartData): | |||
381 | image_rootfs = rootfs_dir | 381 | image_rootfs = rootfs_dir |
382 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) | 382 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) |
383 | 383 | ||
384 | os.remove(rootfs) | 384 | os.path.isfile(rootfs) and os.remove(rootfs) |
385 | squashfs_cmd = "mksquashfs %s %s -noappend" % \ | 385 | squashfs_cmd = "mksquashfs %s %s -noappend" % \ |
386 | (image_rootfs, rootfs) | 386 | (image_rootfs, rootfs) |
387 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) | 387 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) |
@@ -420,7 +420,7 @@ class Wic_PartData(Mic_PartData): | |||
420 | """ | 420 | """ |
421 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 421 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
422 | 422 | ||
423 | os.remove(fs) | 423 | os.path.isfile(fs) and os.remove(fs) |
424 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ | 424 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
425 | (fs, self.size) | 425 | (fs, self.size) |
426 | exec_cmd(dd_cmd) | 426 | exec_cmd(dd_cmd) |
@@ -448,7 +448,7 @@ class Wic_PartData(Mic_PartData): | |||
448 | """ | 448 | """ |
449 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 449 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
450 | 450 | ||
451 | os.remove(fs) | 451 | os.path.isfile(fs) and os.remove(fs) |
452 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ | 452 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
453 | (fs, self.size) | 453 | (fs, self.size) |
454 | exec_cmd(dd_cmd) | 454 | exec_cmd(dd_cmd) |
@@ -473,7 +473,7 @@ class Wic_PartData(Mic_PartData): | |||
473 | Prepare an empty vfat partition. | 473 | Prepare an empty vfat partition. |
474 | """ | 474 | """ |
475 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 475 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
476 | os.remove(fs) | 476 | os.path.isfile(fs) and os.remove(fs) |
477 | 477 | ||
478 | blocks = self.size | 478 | blocks = self.size |
479 | 479 | ||
@@ -500,7 +500,7 @@ class Wic_PartData(Mic_PartData): | |||
500 | "Proceeding as requested." % self.mountpoint) | 500 | "Proceeding as requested." % self.mountpoint) |
501 | 501 | ||
502 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 502 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
503 | os.remove(fs) | 503 | os.path.isfile(fs) and os.remove(fs) |
504 | 504 | ||
505 | # it is not possible to create a squashfs without source data, | 505 | # it is not possible to create a squashfs without source data, |
506 | # thus prepare an empty temp dir that is used as source | 506 | # thus prepare an empty temp dir that is used as source |