summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAnuj Mittal <anuj.mittal@intel.com>2018-07-20 15:44:50 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-26 13:16:31 +0100
commita405383e63c35d7b56108f192ca74755b122a639 (patch)
treeb2c91fc599b7655e5af59b6c02f01d9c790b2e85 /scripts
parentca3f2f6b49edee7052ef941228dc477d9060bdd9 (diff)
downloadopenembedded-core-contrib-a405383e63c35d7b56108f192ca74755b122a639.tar.gz
openembedded-core-contrib-a405383e63c35d7b56108f192ca74755b122a639.tar.bz2
openembedded-core-contrib-a405383e63c35d7b56108f192ca74755b122a639.zip
wic/engine: improve error reporting when using rm with wic
When trying to delete something from an ext partition using debugfs, we don't show any error to the user when that operation fails. Change this behavior to show the error generated by debugfs. Also, fallback to use rmdir in case we are trying to delete a directory. However, unlike mdeltree that is used for a FAT partition, there's no easy way to delete a non empty directory. Show an error instead when that happens so user can take appropriate action. Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts')
-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: