summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/engine.py35
-rw-r--r--scripts/lib/wic/help.py29
2 files changed, 46 insertions, 18 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
552def wic_cp(args, native_sysroot): 567def 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
560def wic_rm(args, native_sysroot): 579def wic_rm(args, native_sysroot):
561 """ 580 """
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 812ebe3ec8..29c4e436d8 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -341,12 +341,15 @@ DESCRIPTION
341 341
342wic_cp_usage = """ 342wic_cp_usage = """
343 343
344 Copy files and directories to the vfat or ext* partition 344 Copy files and directories to/from the vfat or ext* partition
345 345
346 usage: wic cp <src> <image>:<partition>[<path>] [--native-sysroot <path>] 346 usage: wic cp <src> <dest> [--native-sysroot <path>]
347 347
348 This command copies local files or directories to the vfat or ext* partitions 348 source/destination image in format <image>:<partition>[<path>]
349of partitioned image. 349
350 This command copies files or directories either
351 - from local to vfat or ext* partitions of partitioned image
352 - from vfat or ext* partitions of partitioned image to local
350 353
351 See 'wic help cp' for more detailed instructions. 354 See 'wic help cp' for more detailed instructions.
352 355
@@ -355,16 +358,18 @@ of partitioned image.
355wic_cp_help = """ 358wic_cp_help = """
356 359
357NAME 360NAME
358 wic cp - copy files and directories to the vfat or ext* partitions 361 wic cp - copy files and directories to/from the vfat or ext* partitions
359 362
360SYNOPSIS 363SYNOPSIS
361 wic cp <src> <image>:<partition> 364 wic cp <src> <dest>:<partition>
362 wic cp <src> <image>:<partition><path> 365 wic cp <src>:<partition> <dest>
363 wic cp <src> <image>:<partition><path> --native-sysroot <path> 366 wic cp <src> <dest-image>:<partition><path>
367 wic cp <src> <dest-image>:<partition><path> --native-sysroot <path>
364 368
365DESCRIPTION 369DESCRIPTION
366 This command copies files and directories to the vfat or ext* partition of 370 This command copies files or directories either
367 the partitioned image. 371 - from local to vfat or ext* partitions of partitioned image
372 - from vfat or ext* partitions of partitioned image to local
368 373
369 The first form of it copies file or directory to the root directory of 374 The first form of it copies file or directory to the root directory of
370 the partition: 375 the partition:
@@ -397,6 +402,10 @@ DESCRIPTION
397 4 files 0 bytes 402 4 files 0 bytes
398 15 675 392 bytes free 403 15 675 392 bytes free
399 404
405 The third form of the command copies file or directory from the specified directory
406 on the partition to local:
407 $ wic cp tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1/vmlinuz test
408
400 The -n option is used to specify the path to the native sysroot 409 The -n option is used to specify the path to the native sysroot
401 containing the tools(parted and mtools) to use. 410 containing the tools(parted and mtools) to use.
402""" 411"""