diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-28 12:24:49 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-28 17:47:10 +0000 |
commit | 3d59df60a6d5831a1cf27858f08ae24ba0d7419d (patch) | |
tree | 2d9a93ef3bf7ebf73f0b5310412b6db31bc7399f | |
parent | 8c662e768fc7c1a9e3769790bd3de0e2029df9cb (diff) | |
download | poky-3d59df60a6d5831a1cf27858f08ae24ba0d7419d.tar.gz |
scripts/wic: Be consistent about how we call bitbake
Whilst its tempting to call bitbake_main(), the script also directly executes
bitbake. By doing both this creates all kinds of races. Therefore
change to use subprocess execution in all cases.
(From OE-Core rev: 0507ec4c6069490c9a503e9e2b65f0e7b1962d34)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | scripts/wic | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/scripts/wic b/scripts/wic index 37dfe2dc58..b4b7212cfa 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -35,6 +35,7 @@ import os | |||
35 | import sys | 35 | import sys |
36 | import argparse | 36 | import argparse |
37 | import logging | 37 | import logging |
38 | import subprocess | ||
38 | 39 | ||
39 | from collections import namedtuple | 40 | from collections import namedtuple |
40 | from distutils import spawn | 41 | from distutils import spawn |
@@ -63,10 +64,7 @@ if os.environ.get('SDKTARGETSYSROOT'): | |||
63 | bitbake_exe = spawn.find_executable('bitbake') | 64 | bitbake_exe = spawn.find_executable('bitbake') |
64 | if bitbake_exe: | 65 | if bitbake_exe: |
65 | bitbake_path = scriptpath.add_bitbake_lib_path() | 66 | bitbake_path = scriptpath.add_bitbake_lib_path() |
66 | from bb import cookerdata | 67 | import bb |
67 | from bb.main import bitbake_main, BitBakeConfigParameters | ||
68 | else: | ||
69 | bitbake_main = None | ||
70 | 68 | ||
71 | from wic import WicError | 69 | from wic import WicError |
72 | from wic.misc import get_bitbake_var, BB_VARS | 70 | from wic.misc import get_bitbake_var, BB_VARS |
@@ -124,7 +122,7 @@ def wic_create_subcommand(options, usage_str): | |||
124 | Command-line handling for image creation. The real work is done | 122 | Command-line handling for image creation. The real work is done |
125 | by image.engine.wic_create() | 123 | by image.engine.wic_create() |
126 | """ | 124 | """ |
127 | if options.build_rootfs and not bitbake_main: | 125 | if options.build_rootfs and not bitbake_exe: |
128 | raise WicError("Can't build rootfs as bitbake is not in the $PATH") | 126 | raise WicError("Can't build rootfs as bitbake is not in the $PATH") |
129 | 127 | ||
130 | if not options.image_name: | 128 | if not options.image_name: |
@@ -160,9 +158,7 @@ def wic_create_subcommand(options, usage_str): | |||
160 | argv.append("--debug") | 158 | argv.append("--debug") |
161 | 159 | ||
162 | logger.info("Building rootfs...\n") | 160 | logger.info("Building rootfs...\n") |
163 | if bitbake_main(BitBakeConfigParameters(argv), | 161 | subprocess.check_call(argv) |
164 | cookerdata.CookerConfiguration()): | ||
165 | raise WicError("bitbake exited with error") | ||
166 | 162 | ||
167 | rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) | 163 | rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) |
168 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name) | 164 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name) |
@@ -179,9 +175,7 @@ def wic_create_subcommand(options, usage_str): | |||
179 | 175 | ||
180 | if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): | 176 | if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): |
181 | logger.info("Building wic-tools...\n") | 177 | logger.info("Building wic-tools...\n") |
182 | if bitbake_main(BitBakeConfigParameters("bitbake wic-tools".split()), | 178 | subprocess.check_call(["bitbake", "wic-tools"]) |
183 | cookerdata.CookerConfiguration()): | ||
184 | raise WicError("bitbake wic-tools failed") | ||
185 | native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") | 179 | native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") |
186 | 180 | ||
187 | if not native_sysroot: | 181 | if not native_sysroot: |