scripts/wic: Be consistent about how we call bitbake
PATCH 1/3 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.
Signed-off-by Richard Purdie <[email protected]>
--- scripts/wic | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
scripts/wic +5 -11
@@ -35,6 +35,7 @@ import os import sys import argparse import logging +import subprocess from collections import namedtuple from distutils import spawn
@@ -63,10 +64,7 @@ if os.environ.get('SDKTARGETSYSROOT'): bitbake_exe = spawn.find_executable('bitbake') if bitbake_exe: bitbake_path = scriptpath.add_bitbake_lib_path() - from bb import cookerdata - from bb.main import bitbake_main, BitBakeConfigParameters -else: - bitbake_main = None + import bb from wic import WicError from wic.misc import get_bitbake_var, BB_VARS
@@ -124,7 +122,7 @@ def wic_create_subcommand(options, usage_str): Command-line handling for image creation. The real work is done by image.engine.wic_create() """ - if options.build_rootfs and not bitbake_main: + if options.build_rootfs and not bitbake_exe: raise WicError("Can't build rootfs as bitbake is not in the $PATH") if not options.image_name:
@@ -160,9 +158,7 @@ def wic_create_subcommand(options, usage_str): argv.append("--debug") logger.info("Building rootfs...\n") - if bitbake_main(BitBakeConfigParameters(argv), - cookerdata.CookerConfiguration()): - raise WicError("bitbake exited with error") + subprocess.check_call(argv) rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name)
@@ -179,9 +175,7 @@ def wic_create_subcommand(options, usage_str): if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): logger.info("Building wic-tools...\n") - if bitbake_main(BitBakeConfigParameters("bitbake wic-tools".split()), - cookerdata.CookerConfiguration()): - raise WicError("bitbake wic-tools failed") + subprocess.check_call(["bitbake", "wic-tools"]) native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") if not native_sysroot:
Signature · 1 line
2.20.1
PATCH 2/3 oeqa/oetest: Drop unused import
Signed-off-by Richard Purdie <[email protected]>
--- meta/lib/oeqa/oetest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/oetest.py +1 -1
@@ -7,7 +7,7 @@ # It also has some helper functions and it's responsible for actually starting the tests -import os, re, mmap, sys +import os, re, sys import unittest import inspect import subprocess
Signature · 1 line
2.20.1
PATCH 3/3 oeqa/utils/metadata: Add commit_count to fallback logic
In reply to Richard PurdieCurrently if python3-git isn't installed we can get odd behaviours when the commit_count is absent. Avoid this set of bugs by adding a fallback here.
Signed-off-by Richard Purdie <[email protected]>
--- meta/lib/oeqa/utils/metadata.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
meta/lib/oeqa/utils/metadata.py +4 -2
@@ -72,8 +72,10 @@ def git_rev_info(path): info['commit'] = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path).decode('utf-8').strip() except subprocess.CalledProcessError: pass - return info - + try: + info['commit_count'] = int(subprocess.check_output(["git", "rev-list", "--count", "HEAD"], cwd=path).decode('utf-8').strip()) + except subprocess.CalledProcessError: + pass try: repo = Repo(path, search_parent_directories=True) except (InvalidGitRepositoryError, NoSuchPathError):
Signature · 1 line
2.20.1