diff options
Diffstat (limited to 'scripts/wic')
-rwxr-xr-x | scripts/wic | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/scripts/wic b/scripts/wic index a741aed364..9137208f5e 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -22,9 +22,9 @@ import sys | |||
22 | import argparse | 22 | import argparse |
23 | import logging | 23 | import logging |
24 | import subprocess | 24 | import subprocess |
25 | import shutil | ||
25 | 26 | ||
26 | from collections import namedtuple | 27 | from collections import namedtuple |
27 | from distutils import spawn | ||
28 | 28 | ||
29 | # External modules | 29 | # External modules |
30 | scripts_path = os.path.dirname(os.path.realpath(__file__)) | 30 | scripts_path = os.path.dirname(os.path.realpath(__file__)) |
@@ -47,7 +47,7 @@ if os.environ.get('SDKTARGETSYSROOT'): | |||
47 | break | 47 | break |
48 | sdkroot = os.path.dirname(sdkroot) | 48 | sdkroot = os.path.dirname(sdkroot) |
49 | 49 | ||
50 | bitbake_exe = spawn.find_executable('bitbake') | 50 | bitbake_exe = shutil.which('bitbake') |
51 | if bitbake_exe: | 51 | if bitbake_exe: |
52 | bitbake_path = scriptpath.add_bitbake_lib_path() | 52 | bitbake_path = scriptpath.add_bitbake_lib_path() |
53 | import bb | 53 | import bb |
@@ -159,6 +159,9 @@ def wic_create_subcommand(options, usage_str): | |||
159 | "(Use -e/--image-name to specify it)") | 159 | "(Use -e/--image-name to specify it)") |
160 | native_sysroot = options.native_sysroot | 160 | native_sysroot = options.native_sysroot |
161 | 161 | ||
162 | if options.kernel_dir: | ||
163 | kernel_dir = options.kernel_dir | ||
164 | |||
162 | if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): | 165 | if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): |
163 | logger.info("Building wic-tools...\n") | 166 | logger.info("Building wic-tools...\n") |
164 | subprocess.check_call(["bitbake", "wic-tools"]) | 167 | subprocess.check_call(["bitbake", "wic-tools"]) |
@@ -206,7 +209,7 @@ def wic_create_subcommand(options, usage_str): | |||
206 | logger.info(" (Please check that the build artifacts for the machine") | 209 | logger.info(" (Please check that the build artifacts for the machine") |
207 | logger.info(" selected in local.conf actually exist and that they") | 210 | logger.info(" selected in local.conf actually exist and that they") |
208 | logger.info(" are the correct artifacts for the image (.wks file)).\n") | 211 | logger.info(" are the correct artifacts for the image (.wks file)).\n") |
209 | raise WicError("The artifact that couldn't be found was %s:\n %s", not_found, not_found_dir) | 212 | raise WicError("The artifact that couldn't be found was %s:\n %s" % (not_found, not_found_dir)) |
210 | 213 | ||
211 | krootfs_dir = options.rootfs_dir | 214 | krootfs_dir = options.rootfs_dir |
212 | if krootfs_dir is None: | 215 | if krootfs_dir is None: |
@@ -234,6 +237,13 @@ def wic_ls_subcommand(args, usage_str): | |||
234 | Command-line handling for list content of images. | 237 | Command-line handling for list content of images. |
235 | The real work is done by engine.wic_ls() | 238 | The real work is done by engine.wic_ls() |
236 | """ | 239 | """ |
240 | |||
241 | if args.image_name: | ||
242 | BB_VARS.default_image = args.image_name | ||
243 | |||
244 | if args.vars_dir: | ||
245 | BB_VARS.vars_dir = args.vars_dir | ||
246 | |||
237 | engine.wic_ls(args, args.native_sysroot) | 247 | engine.wic_ls(args, args.native_sysroot) |
238 | 248 | ||
239 | def wic_cp_subcommand(args, usage_str): | 249 | def wic_cp_subcommand(args, usage_str): |
@@ -241,6 +251,12 @@ def wic_cp_subcommand(args, usage_str): | |||
241 | Command-line handling for copying files/dirs to images. | 251 | Command-line handling for copying files/dirs to images. |
242 | The real work is done by engine.wic_cp() | 252 | The real work is done by engine.wic_cp() |
243 | """ | 253 | """ |
254 | if args.image_name: | ||
255 | BB_VARS.default_image = args.image_name | ||
256 | |||
257 | if args.vars_dir: | ||
258 | BB_VARS.vars_dir = args.vars_dir | ||
259 | |||
244 | engine.wic_cp(args, args.native_sysroot) | 260 | engine.wic_cp(args, args.native_sysroot) |
245 | 261 | ||
246 | def wic_rm_subcommand(args, usage_str): | 262 | def wic_rm_subcommand(args, usage_str): |
@@ -248,6 +264,12 @@ def wic_rm_subcommand(args, usage_str): | |||
248 | Command-line handling for removing files/dirs from images. | 264 | Command-line handling for removing files/dirs from images. |
249 | The real work is done by engine.wic_rm() | 265 | The real work is done by engine.wic_rm() |
250 | """ | 266 | """ |
267 | if args.image_name: | ||
268 | BB_VARS.default_image = args.image_name | ||
269 | |||
270 | if args.vars_dir: | ||
271 | BB_VARS.vars_dir = args.vars_dir | ||
272 | |||
251 | engine.wic_rm(args, args.native_sysroot) | 273 | engine.wic_rm(args, args.native_sysroot) |
252 | 274 | ||
253 | def wic_write_subcommand(args, usage_str): | 275 | def wic_write_subcommand(args, usage_str): |
@@ -255,6 +277,12 @@ def wic_write_subcommand(args, usage_str): | |||
255 | Command-line handling for writing images. | 277 | Command-line handling for writing images. |
256 | The real work is done by engine.wic_write() | 278 | The real work is done by engine.wic_write() |
257 | """ | 279 | """ |
280 | if args.image_name: | ||
281 | BB_VARS.default_image = args.image_name | ||
282 | |||
283 | if args.vars_dir: | ||
284 | BB_VARS.vars_dir = args.vars_dir | ||
285 | |||
258 | engine.wic_write(args, args.native_sysroot) | 286 | engine.wic_write(args, args.native_sysroot) |
259 | 287 | ||
260 | def wic_help_subcommand(args, usage_str): | 288 | def wic_help_subcommand(args, usage_str): |
@@ -346,6 +374,8 @@ def wic_init_parser_create(subparser): | |||
346 | default=False, help="output debug information") | 374 | default=False, help="output debug information") |
347 | subparser.add_argument("-i", "--imager", dest="imager", | 375 | subparser.add_argument("-i", "--imager", dest="imager", |
348 | default="direct", help="the wic imager plugin") | 376 | default="direct", help="the wic imager plugin") |
377 | subparser.add_argument("--extra-space", type=int, dest="extra_space", | ||
378 | default=0, help="additional free disk space to add to the image") | ||
349 | return | 379 | return |
350 | 380 | ||
351 | 381 | ||
@@ -385,6 +415,12 @@ def wic_init_parser_ls(subparser): | |||
385 | help="image spec: <image>[:<vfat partition>[<path>]]") | 415 | help="image spec: <image>[:<vfat partition>[<path>]]") |
386 | subparser.add_argument("-n", "--native-sysroot", | 416 | subparser.add_argument("-n", "--native-sysroot", |
387 | help="path to the native sysroot containing the tools") | 417 | help="path to the native sysroot containing the tools") |
418 | subparser.add_argument("-e", "--image-name", dest="image_name", | ||
419 | help="name of the image to use the artifacts from " | ||
420 | "e.g. core-image-sato") | ||
421 | subparser.add_argument("-v", "--vars", dest='vars_dir', | ||
422 | help="directory with <image>.env files that store " | ||
423 | "bitbake variables") | ||
388 | 424 | ||
389 | def imgpathtype(arg): | 425 | def imgpathtype(arg): |
390 | img = imgtype(arg) | 426 | img = imgtype(arg) |
@@ -399,6 +435,12 @@ def wic_init_parser_cp(subparser): | |||
399 | help="image spec: <image>:<vfat partition>[<path>] or <file>") | 435 | help="image spec: <image>:<vfat partition>[<path>] or <file>") |
400 | subparser.add_argument("-n", "--native-sysroot", | 436 | subparser.add_argument("-n", "--native-sysroot", |
401 | help="path to the native sysroot containing the tools") | 437 | help="path to the native sysroot containing the tools") |
438 | subparser.add_argument("-e", "--image-name", dest="image_name", | ||
439 | help="name of the image to use the artifacts from " | ||
440 | "e.g. core-image-sato") | ||
441 | subparser.add_argument("-v", "--vars", dest='vars_dir', | ||
442 | help="directory with <image>.env files that store " | ||
443 | "bitbake variables") | ||
402 | 444 | ||
403 | def wic_init_parser_rm(subparser): | 445 | def wic_init_parser_rm(subparser): |
404 | subparser.add_argument("path", type=imgpathtype, | 446 | subparser.add_argument("path", type=imgpathtype, |
@@ -408,6 +450,12 @@ def wic_init_parser_rm(subparser): | |||
408 | subparser.add_argument("-r", dest="recursive_delete", action="store_true", default=False, | 450 | subparser.add_argument("-r", dest="recursive_delete", action="store_true", default=False, |
409 | help="remove directories and their contents recursively, " | 451 | help="remove directories and their contents recursively, " |
410 | " this only applies to ext* partition") | 452 | " this only applies to ext* partition") |
453 | subparser.add_argument("-e", "--image-name", dest="image_name", | ||
454 | help="name of the image to use the artifacts from " | ||
455 | "e.g. core-image-sato") | ||
456 | subparser.add_argument("-v", "--vars", dest='vars_dir', | ||
457 | help="directory with <image>.env files that store " | ||
458 | "bitbake variables") | ||
411 | 459 | ||
412 | def expandtype(rules): | 460 | def expandtype(rules): |
413 | """ | 461 | """ |
@@ -449,6 +497,12 @@ def wic_init_parser_write(subparser): | |||
449 | help="expand rules: auto or <partition>:<size>[,<partition>:<size>]") | 497 | help="expand rules: auto or <partition>:<size>[,<partition>:<size>]") |
450 | subparser.add_argument("-n", "--native-sysroot", | 498 | subparser.add_argument("-n", "--native-sysroot", |
451 | help="path to the native sysroot containing the tools") | 499 | help="path to the native sysroot containing the tools") |
500 | subparser.add_argument("--image-name", dest="image_name", | ||
501 | help="name of the image to use the artifacts from " | ||
502 | "e.g. core-image-sato") | ||
503 | subparser.add_argument("-v", "--vars", dest='vars_dir', | ||
504 | help="directory with <image>.env files that store " | ||
505 | "bitbake variables") | ||
452 | 506 | ||
453 | def wic_init_parser_help(subparser): | 507 | def wic_init_parser_help(subparser): |
454 | helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) | 508 | helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) |