diff options
Diffstat (limited to 'scripts/lib/wic/engine.py')
-rw-r--r-- | scripts/lib/wic/engine.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 7e6620747d..24797511e5 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -323,16 +323,31 @@ class Disk: | |||
323 | self._get_part_image(pnum), | 323 | self._get_part_image(pnum), |
324 | path)) | 324 | path)) |
325 | 325 | ||
326 | def copy(self, src, pnum, path): | 326 | def copy(self, src, dest): |
327 | """Copy partition image into wic image.""" | 327 | """Copy partition image into wic image.""" |
328 | pnum = dest.part if isinstance(src, str) else src.part | ||
329 | |||
328 | if self.partitions[pnum].fstype.startswith('ext'): | 330 | if self.partitions[pnum].fstype.startswith('ext'): |
329 | cmd = "printf 'cd {}\nwrite {} {}\n' | {} -w {}".\ | 331 | if isinstance(src, str): |
330 | format(path, src, os.path.basename(src), | 332 | cmd = "printf 'cd {}\nwrite {} {}\n' | {} -w {}".\ |
333 | format(os.path.dirname(dest.path), src, os.path.basename(src), | ||
331 | self.debugfs, self._get_part_image(pnum)) | 334 | self.debugfs, self._get_part_image(pnum)) |
335 | else: # copy from wic | ||
336 | # run both dump and rdump to support both files and directory | ||
337 | cmd = "printf 'cd {}\ndump /{} {}\nrdump /{} {}\n' | {} {}".\ | ||
338 | format(os.path.dirname(src.path), src.path, | ||
339 | dest, src.path, dest, self.debugfs, | ||
340 | self._get_part_image(pnum)) | ||
332 | else: # fat | 341 | else: # fat |
333 | cmd = "{} -i {} -snop {} ::{}".format(self.mcopy, | 342 | if isinstance(src, str): |
343 | cmd = "{} -i {} -snop {} ::{}".format(self.mcopy, | ||
344 | self._get_part_image(pnum), | ||
345 | src, dest.path) | ||
346 | else: | ||
347 | cmd = "{} -i {} -snop ::{} {}".format(self.mcopy, | ||
334 | self._get_part_image(pnum), | 348 | self._get_part_image(pnum), |
335 | src, path) | 349 | src.path, dest) |
350 | |||
336 | exec_cmd(cmd, as_shell=True) | 351 | exec_cmd(cmd, as_shell=True) |
337 | self._put_part_image(pnum) | 352 | self._put_part_image(pnum) |
338 | 353 | ||
@@ -551,11 +566,15 @@ def wic_ls(args, native_sysroot): | |||
551 | 566 | ||
552 | def wic_cp(args, native_sysroot): | 567 | def wic_cp(args, native_sysroot): |
553 | """ | 568 | """ |
554 | Copy local file or directory to the vfat partition of | 569 | Copy file or directory to/from the vfat/ext partition of |
555 | partitioned image. | 570 | partitioned image. |
556 | """ | 571 | """ |
557 | disk = Disk(args.dest.image, native_sysroot) | 572 | if isinstance(args.dest, str): |
558 | disk.copy(args.src, args.dest.part, args.dest.path) | 573 | disk = Disk(args.src.image, native_sysroot) |
574 | else: | ||
575 | disk = Disk(args.dest.image, native_sysroot) | ||
576 | disk.copy(args.src, args.dest) | ||
577 | |||
559 | 578 | ||
560 | def wic_rm(args, native_sysroot): | 579 | def wic_rm(args, native_sysroot): |
561 | """ | 580 | """ |