diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-08-25 23:12:27 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-27 22:30:07 +0100 |
commit | cdef76e42414c092667761f8d9476e0d29828e75 (patch) | |
tree | d8ce5b0f0ab12fde54b5373c217a54d7ea63bfb3 /scripts/wic | |
parent | cee58f1d411e3321182f18bf2230aa5882178b1f (diff) | |
download | poky-cdef76e42414c092667761f8d9476e0d29828e75.tar.gz |
wic: implement 'wic write' command
This command writes image to the media or another file with
the possibility to expand partitions to fill free target space.
[YOCTO #11278]
(From OE-Core rev: ac5fc0d691aad66ac01a5cde34c331c928e9e25a)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/wic')
-rwxr-xr-x | scripts/wic | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/wic b/scripts/wic index 02bc82ce42..592a0e4c25 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -257,6 +257,13 @@ def wic_rm_subcommand(args, usage_str): | |||
257 | """ | 257 | """ |
258 | engine.wic_rm(args, args.native_sysroot) | 258 | engine.wic_rm(args, args.native_sysroot) |
259 | 259 | ||
260 | def wic_write_subcommand(args, usage_str): | ||
261 | """ | ||
262 | Command-line handling for writing images. | ||
263 | The real work is done by engine.wic_write() | ||
264 | """ | ||
265 | engine.wic_write(args, args.native_sysroot) | ||
266 | |||
260 | def wic_help_subcommand(args, usage_str): | 267 | def wic_help_subcommand(args, usage_str): |
261 | """ | 268 | """ |
262 | Command-line handling for help subcommand to keep the current | 269 | Command-line handling for help subcommand to keep the current |
@@ -298,6 +305,9 @@ helptopics = { | |||
298 | "rm": [wic_help_topic_subcommand, | 305 | "rm": [wic_help_topic_subcommand, |
299 | wic_help_topic_usage, | 306 | wic_help_topic_usage, |
300 | hlp.wic_rm_help], | 307 | hlp.wic_rm_help], |
308 | "write": [wic_help_topic_subcommand, | ||
309 | wic_help_topic_usage, | ||
310 | hlp.wic_write_help], | ||
301 | "list": [wic_help_topic_subcommand, | 311 | "list": [wic_help_topic_subcommand, |
302 | wic_help_topic_usage, | 312 | wic_help_topic_usage, |
303 | hlp.wic_list_help] | 313 | hlp.wic_list_help] |
@@ -397,6 +407,47 @@ def wic_init_parser_rm(subparser): | |||
397 | subparser.add_argument("-n", "--native-sysroot", | 407 | subparser.add_argument("-n", "--native-sysroot", |
398 | help="path to the native sysroot containing the tools") | 408 | help="path to the native sysroot containing the tools") |
399 | 409 | ||
410 | def expandtype(rules): | ||
411 | """ | ||
412 | Custom type for ArgumentParser | ||
413 | Converts expand rules to the dictionary {<partition>: size} | ||
414 | """ | ||
415 | if rules == 'auto': | ||
416 | return {} | ||
417 | result = {} | ||
418 | for rule in rules.split('-'): | ||
419 | try: | ||
420 | part, size = rule.split(':') | ||
421 | except ValueError: | ||
422 | raise argparse.ArgumentTypeError("Incorrect rule format: %s" % rule) | ||
423 | |||
424 | if not part.isdigit(): | ||
425 | raise argparse.ArgumentTypeError("Rule '%s': partition number must be integer" % rule) | ||
426 | |||
427 | # validate size | ||
428 | multiplier = 1 | ||
429 | for suffix, mult in [('K', 1024), ('M', 1024 * 1024), ('G', 1024 * 1024 * 1024)]: | ||
430 | if size.upper().endswith(suffix): | ||
431 | multiplier = mult | ||
432 | size = size[:-1] | ||
433 | break | ||
434 | if not size.isdigit(): | ||
435 | raise argparse.ArgumentTypeError("Rule '%s': size must be integer" % rule) | ||
436 | |||
437 | result[int(part)] = int(size) * multiplier | ||
438 | |||
439 | return result | ||
440 | |||
441 | def wic_init_parser_write(subparser): | ||
442 | subparser.add_argument("image", | ||
443 | help="path to the wic image") | ||
444 | subparser.add_argument("target", | ||
445 | help="target file or device") | ||
446 | subparser.add_argument("-e", "--expand", type=expandtype, | ||
447 | help="expand rules: auto or <partition>:<size>[,<partition>:<size>]") | ||
448 | subparser.add_argument("-n", "--native-sysroot", | ||
449 | help="path to the native sysroot containing the tools") | ||
450 | |||
400 | def wic_init_parser_help(subparser): | 451 | def wic_init_parser_help(subparser): |
401 | helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) | 452 | helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) |
402 | for helptopic in helptopics: | 453 | for helptopic in helptopics: |
@@ -425,6 +476,10 @@ subcommands = { | |||
425 | hlp.wic_rm_usage, | 476 | hlp.wic_rm_usage, |
426 | hlp.wic_rm_help, | 477 | hlp.wic_rm_help, |
427 | wic_init_parser_rm], | 478 | wic_init_parser_rm], |
479 | "write": [wic_write_subcommand, | ||
480 | hlp.wic_write_usage, | ||
481 | hlp.wic_write_help, | ||
482 | wic_init_parser_write], | ||
428 | "help": [wic_help_subcommand, | 483 | "help": [wic_help_subcommand, |
429 | wic_help_topic_usage, | 484 | wic_help_topic_usage, |
430 | hlp.wic_help_help, | 485 | hlp.wic_help_help, |