diff options
Diffstat (limited to 'scripts/lib/wic/engine.py')
-rw-r--r-- | scripts/lib/wic/engine.py | 22 |
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 | ||
334 | def wic_ls(args, native_sysroot): | 348 | def wic_ls(args, native_sysroot): |