diff options
| -rwxr-xr-x | scripts/wic | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/wic b/scripts/wic index 49cad869e2..6c9a30da7d 100755 --- a/scripts/wic +++ b/scripts/wic | |||
| @@ -35,6 +35,8 @@ import os | |||
| 35 | import sys | 35 | import sys |
| 36 | import argparse | 36 | import argparse |
| 37 | import logging | 37 | import logging |
| 38 | |||
| 39 | from collections import namedtuple | ||
| 38 | from distutils import spawn | 40 | from distutils import spawn |
| 39 | 41 | ||
| 40 | # External modules | 42 | # External modules |
| @@ -317,6 +319,29 @@ def wic_init_parser_list(subparser): | |||
| 317 | "defined inside the .wks file") | 319 | "defined inside the .wks file") |
| 318 | return | 320 | return |
| 319 | 321 | ||
| 322 | def imgtype(arg): | ||
| 323 | """ | ||
| 324 | Custom type for ArgumentParser | ||
| 325 | Converts path spec to named tuple: (image, partition, path) | ||
| 326 | """ | ||
| 327 | image = arg | ||
| 328 | part = path = None | ||
| 329 | if ':' in image: | ||
| 330 | image, part = image.split(':') | ||
| 331 | if '/' in part: | ||
| 332 | part, path = part.split('/', 1) | ||
| 333 | |||
| 334 | if not os.path.isfile(image): | ||
| 335 | err = "%s is not a regular file or symlink" % image | ||
| 336 | raise argparse.ArgumentTypeError(err) | ||
| 337 | |||
| 338 | return namedtuple('ImgType', 'image part path')(image, part, path) | ||
| 339 | |||
| 340 | def wic_init_parser_ls(subparser): | ||
| 341 | subparser.add_argument("path", type=imgtype, | ||
| 342 | help="image spec: <image>[:<vfat partition>[<path>]]") | ||
| 343 | subparser.add_argument("-n", "--native-sysroot", | ||
| 344 | help="path to the native sysroot containing the tools") | ||
| 320 | 345 | ||
| 321 | def wic_init_parser_help(subparser): | 346 | def wic_init_parser_help(subparser): |
| 322 | helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) | 347 | helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) |
