From e2e709d85ed4dffada352c1fcdd048a783b81307 Mon Sep 17 00:00:00 2001 From: Hongxu Jia Date: Mon, 16 Jun 2025 16:12:45 +0800 Subject: [PATCH] scripts/wic: fix calling wic ls|cp|rm|write hung in bitbake task While calling wic ls/cp/rm/write in bitbake task along with do_image_wic, it hung without return. Due to commit [2255f28b57 wic: add WIC_SECTOR_SIZE variable][1] applied, It calls get_bitbake_var in `wic ls|cp|rm|write' to define sector size. By default, get_bitbake_var starts a `bitbake -e' to get variables which triggers nested bitbake in this situation Refer `wic create', adds option --vars and --image-name to support to read bitbake variables from .env files NOTE: This commit does not add -e for `wic write' to avoid confliction with existed option -e/--expand [1] https://github.com/openembedded/openembedded-core/commit/2255f28b579bc5db4138bcacbb829661ae0ee721 (From OE-Core rev: 793732a6ac2b3788d6c6635e5a496b117bd60584) Signed-off-by: Hongxu Jia Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- scripts/wic | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/scripts/wic b/scripts/wic index 06e0b48db0..9137208f5e 100755 --- a/scripts/wic +++ b/scripts/wic @@ -237,6 +237,13 @@ def wic_ls_subcommand(args, usage_str): Command-line handling for list content of images. The real work is done by engine.wic_ls() """ + + if args.image_name: + BB_VARS.default_image = args.image_name + + if args.vars_dir: + BB_VARS.vars_dir = args.vars_dir + engine.wic_ls(args, args.native_sysroot) def wic_cp_subcommand(args, usage_str): @@ -244,6 +251,12 @@ def wic_cp_subcommand(args, usage_str): Command-line handling for copying files/dirs to images. The real work is done by engine.wic_cp() """ + if args.image_name: + BB_VARS.default_image = args.image_name + + if args.vars_dir: + BB_VARS.vars_dir = args.vars_dir + engine.wic_cp(args, args.native_sysroot) def wic_rm_subcommand(args, usage_str): @@ -251,6 +264,12 @@ def wic_rm_subcommand(args, usage_str): Command-line handling for removing files/dirs from images. The real work is done by engine.wic_rm() """ + if args.image_name: + BB_VARS.default_image = args.image_name + + if args.vars_dir: + BB_VARS.vars_dir = args.vars_dir + engine.wic_rm(args, args.native_sysroot) def wic_write_subcommand(args, usage_str): @@ -258,6 +277,12 @@ def wic_write_subcommand(args, usage_str): Command-line handling for writing images. The real work is done by engine.wic_write() """ + if args.image_name: + BB_VARS.default_image = args.image_name + + if args.vars_dir: + BB_VARS.vars_dir = args.vars_dir + engine.wic_write(args, args.native_sysroot) def wic_help_subcommand(args, usage_str): @@ -390,6 +415,12 @@ def wic_init_parser_ls(subparser): help="image spec: [:[]]") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing the tools") + subparser.add_argument("-e", "--image-name", dest="image_name", + help="name of the image to use the artifacts from " + "e.g. core-image-sato") + subparser.add_argument("-v", "--vars", dest='vars_dir', + help="directory with .env files that store " + "bitbake variables") def imgpathtype(arg): img = imgtype(arg) @@ -404,6 +435,12 @@ def wic_init_parser_cp(subparser): help="image spec: :[] or ") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing the tools") + subparser.add_argument("-e", "--image-name", dest="image_name", + help="name of the image to use the artifacts from " + "e.g. core-image-sato") + subparser.add_argument("-v", "--vars", dest='vars_dir', + help="directory with .env files that store " + "bitbake variables") def wic_init_parser_rm(subparser): subparser.add_argument("path", type=imgpathtype, @@ -413,6 +450,12 @@ def wic_init_parser_rm(subparser): subparser.add_argument("-r", dest="recursive_delete", action="store_true", default=False, help="remove directories and their contents recursively, " " this only applies to ext* partition") + subparser.add_argument("-e", "--image-name", dest="image_name", + help="name of the image to use the artifacts from " + "e.g. core-image-sato") + subparser.add_argument("-v", "--vars", dest='vars_dir', + help="directory with .env files that store " + "bitbake variables") def expandtype(rules): """ @@ -454,6 +497,12 @@ def wic_init_parser_write(subparser): help="expand rules: auto or :[,:]") subparser.add_argument("-n", "--native-sysroot", help="path to the native sysroot containing the tools") + subparser.add_argument("--image-name", dest="image_name", + help="name of the image to use the artifacts from " + "e.g. core-image-sato") + subparser.add_argument("-v", "--vars", dest='vars_dir', + help="directory with .env files that store " + "bitbake variables") def wic_init_parser_help(subparser): helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage)