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:36:57 -0700 |
commit | 41f08393643ceb2607cad44d2c485b3dc9da7ec9 (patch) | |
tree | 7ad2991798666a4e22ff239ba9f1b7366aff3827 | |
parent | 8bea23a89968db3d44b9fae2ceb242dfd89a4880 (diff) | |
download | openembedded-core-41f08393643ceb2607cad44d2c485b3dc9da7ec9.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>
-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): image_rootfs = rootfs_dir rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) - os.remove(rootfs) + os.path.isfile(rootfs) and os.remove(rootfs) du_cmd = "du -ks %s" % image_rootfs out = exec_cmd(du_cmd) actual_rootfs_size = int(out.split()[0]) @@ -283,7 +283,7 @@ class Wic_PartData(Mic_PartData): image_rootfs = rootfs_dir rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.remove(rootfs) + os.path.isfile(rootfs) and os.remove(rootfs) du_cmd = "du -ks %s" % image_rootfs out = exec_cmd(du_cmd) actual_rootfs_size = int(out.split()[0]) @@ -328,7 +328,7 @@ class Wic_PartData(Mic_PartData): image_rootfs = rootfs_dir rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.remove(rootfs) + os.path.isfile(rootfs) and os.remove(rootfs) du_cmd = "du -bks %s" % image_rootfs out = exec_cmd(du_cmd) blocks = int(out.split()[0]) @@ -381,7 +381,7 @@ class Wic_PartData(Mic_PartData): image_rootfs = rootfs_dir rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype) - os.remove(rootfs) + os.path.isfile(rootfs) and os.remove(rootfs) squashfs_cmd = "mksquashfs %s %s -noappend" % \ (image_rootfs, rootfs) exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) @@ -420,7 +420,7 @@ class Wic_PartData(Mic_PartData): """ fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.remove(fs) + os.path.isfile(fs) and os.remove(fs) dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ (fs, self.size) exec_cmd(dd_cmd) @@ -448,7 +448,7 @@ class Wic_PartData(Mic_PartData): """ fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.remove(fs) + os.path.isfile(fs) and os.remove(fs) dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ (fs, self.size) exec_cmd(dd_cmd) @@ -473,7 +473,7 @@ class Wic_PartData(Mic_PartData): Prepare an empty vfat partition. """ fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.remove(fs) + os.path.isfile(fs) and os.remove(fs) blocks = self.size @@ -500,7 +500,7 @@ class Wic_PartData(Mic_PartData): "Proceeding as requested." % self.mountpoint) fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.remove(fs) + os.path.isfile(fs) and os.remove(fs) # it is not possible to create a squashfs without source data, # thus prepare an empty temp dir that is used as source |