All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 3/7] wic: implement ext fs support for 'wic rm'
Date: Tue,  5 Sep 2017 14:54:38 +0300	[thread overview]
Message-ID: <0031f028b6900418d8c2474f9e7fd0cfb6cc5e73.1504611134.git.ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <cover.1504611134.git.ed.bartosh@linux.intel.com>

Implemented removing files or directories from the ext
partition using debugfs tool.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 scripts/lib/wic/engine.py | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 9ebd93ae278..edcfab39ef5 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -339,18 +339,23 @@ class Disk:
     def remove(self, pnum, path):
         """Remove files/dirs from the partition."""
         partimg = self._get_part_image(pnum)
-        cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
-        try:
-            exec_cmd(cmd)
-        except WicError as err:
-            if "not found" in str(err) or "non empty" in str(err):
-                # mdel outputs 'File ... not found' or 'directory .. non empty"
-                # try to use mdeltree as path could be a directory
-                cmd = "{} -i {} ::{}".format(self.mdeltree,
-                                             partimg, path)
+        if self.partitions[pnum].fstype.startswith('ext'):
+            exec_cmd("{} {} -wR 'rm {}'".format(self.debugfs,
+                                                self._get_part_image(pnum),
+                                                path), as_shell=True)
+        else: # fat
+            cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
+            try:
                 exec_cmd(cmd)
-            else:
-                raise err
+            except WicError as err:
+                if "not found" in str(err) or "non empty" in str(err):
+                    # mdel outputs 'File ... not found' or 'directory .. non empty"
+                    # try to use mdeltree as path could be a directory
+                    cmd = "{} -i {} ::{}".format(self.mdeltree,
+                                                 partimg, path)
+                    exec_cmd(cmd)
+                else:
+                    raise err
         self._put_part_image(pnum)
 
     def write(self, target, expand):
-- 
2.13.5



  parent reply	other threads:[~2017-09-05 11:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05 11:54 [PATCH 0/7] implement wic ls/cp/rm for ext partitions Ed Bartosh
2017-09-05 11:54 ` [PATCH 1/7] wic: implement ext fs support for 'wic ls' Ed Bartosh
2017-09-05 11:54 ` [PATCH 2/7] wic: implement ext fs support for 'wic cp' Ed Bartosh
2017-09-05 11:54 ` Ed Bartosh [this message]
2017-09-05 11:54 ` [PATCH 4/7] wic: update help content Ed Bartosh
2017-09-05 11:54 ` [PATCH 5/7] wic: selftest: add test_wic_ls_ext test case Ed Bartosh
2017-09-05 11:54 ` [PATCH 6/7] wic: selftest: add test_wic_cp_ext " Ed Bartosh
2017-09-05 11:54 ` [PATCH 7/7] wic: selftest: add test_wic_rm_ext " Ed Bartosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0031f028b6900418d8c2474f9e7fd0cfb6cc5e73.1504611134.git.ed.bartosh@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.