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:40 +0100
commitb7b203d8ea30056b5e03e7ef04504e5d5bee1a1a (patch)
tree5758f2f01ab0f5cb0dc23c6fc23cae6021f03482 /scripts
parent866e437f21bfe491ae7dbcd9a7cbb0fd465b3669 (diff)
downloadpoky-b7b203d8ea30056b5e03e7ef04504e5d5bee1a1a.tar.gz
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. (From OE-Core rev: a405383e63c35d7b56108f192ca74755b122a639) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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:
340 """Remove files/dirs from the partition.""" 340 """Remove files/dirs from the partition."""
341 partimg = self._get_part_image(pnum) 341 partimg = self._get_part_image(pnum)
342 if self.partitions[pnum].fstype.startswith('ext'): 342 if self.partitions[pnum].fstype.startswith('ext'):
343 exec_cmd("{} {} -wR 'rm {}'".format(self.debugfs, 343 cmd = "{} {} -wR 'rm {}'".format(self.debugfs,
344 self._get_part_image(pnum), 344 self._get_part_image(pnum),
345 path), as_shell=True) 345 path)
346 out = exec_cmd(cmd , as_shell=True)
347 for line in out.splitlines():
348 if line.startswith("rm:"):
349 if "file is a directory" in line:
350 # Try rmdir to see if this is an empty directory. This won't delete
351 # any non empty directory so let user know about any error that this might
352 # generate.
353 print(exec_cmd("{} {} -wR 'rmdir {}'".format(self.debugfs,
354 self._get_part_image(pnum),
355 path), as_shell=True))
356 else:
357 raise WicError("Could not complete operation: wic %s" % str(line))
346 else: # fat 358 else: # fat
347 cmd = "{} -i {} ::{}".format(self.mdel, partimg, path) 359 cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
348 try: 360 try: