[oe-commits] [openembedded-core] 26/58: wic/engine: improve error reporting when using rm with wic

git at git.openembedded.org git at git.openembedded.org
Wed Jul 25 21:45:56 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit a4cb6687f3f45e4820f8192322afcbdc789c511b
Author: Anuj Mittal <anuj.mittal at intel.com>
AuthorDate: Fri Jul 20 15:44:50 2018 +0800

    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 at intel.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 scripts/lib/wic/engine.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 11dedb8..850cec3 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:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list