summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/engine.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-06-13 14:22:13 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-14 10:18:29 +0100
commit6a8f4426b071ab97c89f36cc133cc48b4c671e56 (patch)
tree1f320da52c70cad71ddebe11617136477da562fc /scripts/lib/wic/engine.py
parentc5fadce5f90c7e49cb5e40943f1c38f95cc13588 (diff)
downloadpoky-6a8f4426b071ab97c89f36cc133cc48b4c671e56.tar.gz
wic: implement removing directories
Added support for removing directories using mdeltree utility to Disk.del method [YOCTO #11283] (From OE-Core rev: a5fc61d8f290d370f4bc51d4e2a67a5580edb1b1) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/engine.py')
-rw-r--r--scripts/lib/wic/engine.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 6fc8bb72c3..2c899dd386 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -239,6 +239,7 @@ class Disk:
239 self._mdir = None 239 self._mdir = None
240 self._mcopy = None 240 self._mcopy = None
241 self._mdel = None 241 self._mdel = None
242 self._mdeltree = None
242 self._partimages = {} 243 self._partimages = {}
243 244
244 # find parted 245 # find parted
@@ -290,6 +291,10 @@ class Disk:
290 def mdel(self): 291 def mdel(self):
291 return self._prop("mdel") 292 return self._prop("mdel")
292 293
294 @property
295 def mdeltree(self):
296 return self._prop("mdeltree")
297
293 def _get_part_image(self, pnum): 298 def _get_part_image(self, pnum):
294 if pnum not in self.partitions: 299 if pnum not in self.partitions:
295 raise WicError("Partition %s is not in the image") 300 raise WicError("Partition %s is not in the image")
@@ -325,10 +330,19 @@ class Disk:
325 330
326 def remove(self, pnum, path): 331 def remove(self, pnum, path):
327 """Remove files/dirs from the partition.""" 332 """Remove files/dirs from the partition."""
328 cmd = "{} -i {} ::{}".format(self.mdel, 333 partimg = self._get_part_image(pnum)
329 self._get_part_image(pnum), 334 cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
330 path) 335 try:
331 exec_cmd(cmd) 336 exec_cmd(cmd)
337 except WicError as err:
338 if "not found" in str(err) or "non empty" in str(err):
339 # mdel outputs 'File ... not found' or 'directory .. non empty"
340 # try to use mdeltree as path could be a directory
341 cmd = "{} -i {} ::{}".format(self.mdeltree,
342 partimg, path)
343 exec_cmd(cmd)
344 else:
345 raise err
332 self._put_part_image(pnum) 346 self._put_part_image(pnum)
333 347
334def wic_ls(args, native_sysroot): 348def wic_ls(args, native_sysroot):