wic: 'wic cp' to copy from image

currently 'wic cp' only works for copy file from local storage to
wic image.

enhance 'wic cp' to copy file/directory from wic image to local storage.

include selftest and 'wic help' updates.

[YOCTO#12169]

(From OE-Core rev: bd669c1809a378f93580eb9e0679a26ec6746cb8)

Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chee Yang Lee
2019-11-21 14:28:52 +08:00
committed by Richard Purdie
parent 4d6a9708e6
commit 89288705c6
4 changed files with 76 additions and 21 deletions

View File

@@ -392,9 +392,9 @@ def imgpathtype(arg):
def wic_init_parser_cp(subparser):
subparser.add_argument("src",
help="source spec")
subparser.add_argument("dest", type=imgpathtype,
help="image spec: <image>:<vfat partition>[<path>]")
help="image spec: <image>:<vfat partition>[<path>] or <file>")
subparser.add_argument("dest",
help="image spec: <image>:<vfat partition>[<path>] or <file>")
subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysroot containing the tools")
@@ -522,6 +522,16 @@ def main(argv):
hlpt[0](hlpt[1], hlpt[2])
return 0
# validate wic cp src and dest parameter to identify which one of it is
# image and cast it into imgtype
if args.command == "cp":
if ":" in args.dest:
args.dest = imgtype(args.dest)
elif ":" in args.src:
args.src = imgtype(args.src)
else:
raise argparse.ArgumentTypeError("no image or partition number specified.")
return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)