* [wic][PATCH] wic: Make sure file exists before removing it
@ 2015-05-21 7:29 Ed Bartosh
0 siblings, 0 replies; only message in thread
From: Ed Bartosh @ 2015-05-21 7:29 UTC (permalink / raw)
To: openembedded-core
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.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/kickstart/custom_commands/partition.py | 16 ++++++++--------
1 file 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 e864076..d9f77d9 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):
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])
@@ -282,7 +282,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])
@@ -327,7 +327,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])
@@ -380,7 +380,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)
@@ -419,7 +419,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)
@@ -447,7 +447,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)
@@ -472,7 +472,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
@@ -499,7 +499,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
--
2.1.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-21 9:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-21 7:29 [wic][PATCH] wic: Make sure file exists before removing it Ed Bartosh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.