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-05-24 07:19:19 +0100 |
| commit | 74c7efb2af5d94d66c3a510896bb4b79b1222735 (patch) | |
| tree | 91bc642148dde65c4c6c2eaacb339caa2d03d6d5 /scripts/lib | |
| parent | 1b2332d3382e0776382b65eeb4c0fcba0528da4e (diff) | |
| download | poky-74c7efb2af5d94d66c3a510896bb4b79b1222735.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)
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')
| -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 e864076c99..d9f77d9a28 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py | |||
| @@ -230,7 +230,7 @@ class Wic_PartData(Mic_PartData): | |||
| 230 | image_rootfs = rootfs_dir | 230 | image_rootfs = rootfs_dir |
| 231 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) | 231 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) |
| 232 | 232 | ||
| 233 | os.remove(rootfs) | 233 | os.path.isfile(rootfs) and os.remove(rootfs) |
| 234 | du_cmd = "du -ks %s" % image_rootfs | 234 | du_cmd = "du -ks %s" % image_rootfs |
| 235 | out = exec_cmd(du_cmd) | 235 | out = exec_cmd(du_cmd) |
| 236 | actual_rootfs_size = int(out.split()[0]) | 236 | actual_rootfs_size = int(out.split()[0]) |
| @@ -282,7 +282,7 @@ class Wic_PartData(Mic_PartData): | |||
| 282 | image_rootfs = rootfs_dir | 282 | image_rootfs = rootfs_dir |
| 283 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) | 283 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 284 | 284 | ||
| 285 | os.remove(rootfs) | 285 | os.path.isfile(rootfs) and os.remove(rootfs) |
| 286 | du_cmd = "du -ks %s" % image_rootfs | 286 | du_cmd = "du -ks %s" % image_rootfs |
| 287 | out = exec_cmd(du_cmd) | 287 | out = exec_cmd(du_cmd) |
| 288 | actual_rootfs_size = int(out.split()[0]) | 288 | actual_rootfs_size = int(out.split()[0]) |
| @@ -327,7 +327,7 @@ class Wic_PartData(Mic_PartData): | |||
| 327 | image_rootfs = rootfs_dir | 327 | image_rootfs = rootfs_dir |
| 328 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) | 328 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 329 | 329 | ||
| 330 | os.remove(rootfs) | 330 | os.path.isfile(rootfs) and os.remove(rootfs) |
| 331 | du_cmd = "du -bks %s" % image_rootfs | 331 | du_cmd = "du -bks %s" % image_rootfs |
| 332 | out = exec_cmd(du_cmd) | 332 | out = exec_cmd(du_cmd) |
| 333 | blocks = int(out.split()[0]) | 333 | blocks = int(out.split()[0]) |
| @@ -380,7 +380,7 @@ class Wic_PartData(Mic_PartData): | |||
| 380 | image_rootfs = rootfs_dir | 380 | image_rootfs = rootfs_dir |
| 381 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) | 381 | rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) |
| 382 | 382 | ||
| 383 | os.remove(rootfs) | 383 | os.path.isfile(rootfs) and os.remove(rootfs) |
| 384 | squashfs_cmd = "mksquashfs %s %s -noappend" % \ | 384 | squashfs_cmd = "mksquashfs %s %s -noappend" % \ |
| 385 | (image_rootfs, rootfs) | 385 | (image_rootfs, rootfs) |
| 386 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) | 386 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) |
| @@ -419,7 +419,7 @@ class Wic_PartData(Mic_PartData): | |||
| 419 | """ | 419 | """ |
| 420 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 420 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 421 | 421 | ||
| 422 | os.remove(fs) | 422 | os.path.isfile(fs) and os.remove(fs) |
| 423 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ | 423 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
| 424 | (fs, self.size) | 424 | (fs, self.size) |
| 425 | exec_cmd(dd_cmd) | 425 | exec_cmd(dd_cmd) |
| @@ -447,7 +447,7 @@ class Wic_PartData(Mic_PartData): | |||
| 447 | """ | 447 | """ |
| 448 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 448 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 449 | 449 | ||
| 450 | os.remove(fs) | 450 | os.path.isfile(fs) and os.remove(fs) |
| 451 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ | 451 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
| 452 | (fs, self.size) | 452 | (fs, self.size) |
| 453 | exec_cmd(dd_cmd) | 453 | exec_cmd(dd_cmd) |
| @@ -472,7 +472,7 @@ class Wic_PartData(Mic_PartData): | |||
| 472 | Prepare an empty vfat partition. | 472 | Prepare an empty vfat partition. |
| 473 | """ | 473 | """ |
| 474 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 474 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 475 | os.remove(fs) | 475 | os.path.isfile(fs) and os.remove(fs) |
| 476 | 476 | ||
| 477 | blocks = self.size | 477 | blocks = self.size |
| 478 | 478 | ||
| @@ -499,7 +499,7 @@ class Wic_PartData(Mic_PartData): | |||
| 499 | "Proceeding as requested." % self.mountpoint) | 499 | "Proceeding as requested." % self.mountpoint) |
| 500 | 500 | ||
| 501 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 501 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 502 | os.remove(fs) | 502 | os.path.isfile(fs) and os.remove(fs) |
| 503 | 503 | ||
| 504 | # it is not possible to create a squashfs without source data, | 504 | # it is not possible to create a squashfs without source data, |
| 505 | # thus prepare an empty temp dir that is used as source | 505 | # thus prepare an empty temp dir that is used as source |
