aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/wic/engine.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 11dedb8cac..850cec30e5 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -340,9 +340,21 @@ class Disk:
"""Remove files/dirs from the partition."""
partimg = self._get_part_image(pnum)
if self.partitions[pnum].fstype.startswith('ext'):
- exec_cmd("{} {} -wR 'rm {}'".format(self.debugfs,
+ cmd = "{} {} -wR 'rm {}'".format(self.debugfs,
self._get_part_image(pnum),
- path), as_shell=True)
+ path)
+ out = exec_cmd(cmd , as_shell=True)
+ for line in out.splitlines():
+ if line.startswith("rm:"):
+ if "file is a directory" in line:
+ # Try rmdir to see if this is an empty directory. This won't delete
+ # any non empty directory so let user know about any error that this might
+ # generate.
+ print(exec_cmd("{} {} -wR 'rmdir {}'".format(self.debugfs,
+ self._get_part_image(pnum),
+ path), as_shell=True))
+ else:
+ raise WicError("Could not complete operation: wic %s" % str(line))
else: # fat
cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
try: