mirror of
https://git.yoctoproject.org/poky
synced 2026-09-13 09:49:32 +02:00
devtool: second fix for running from a different directory
Do not change change current working directory permanently, but, only
for the duration of tinfoil initialization instead. The previous fix
caused very unintuitive behavior where using relative paths were solved
with respect to the builddir instead of the current working directory.
E.g. calling "devtool extract zlib ./zlib" would always create create
srctree in ${TOPDIR}/zlib, independent of the users cwd.
(From OE-Core rev: 4c7f159b0e17a0475a4a4e9dc4dd012e3d2e6a1f)
(From OE-Core rev: 05060699e63cd25d089e83e9aa56c11d5baa8fd8)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
6363a95550
commit
85d8b4a92f
@@ -221,9 +221,6 @@ def main():
|
|||||||
if not config.read():
|
if not config.read():
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
# We need to be in this directory or we won't be able to initialise tinfoil
|
|
||||||
os.chdir(basepath)
|
|
||||||
|
|
||||||
bitbake_subdir = config.get('General', 'bitbake_subdir', '')
|
bitbake_subdir = config.get('General', 'bitbake_subdir', '')
|
||||||
if bitbake_subdir:
|
if bitbake_subdir:
|
||||||
# Normally set for use within the SDK
|
# Normally set for use within the SDK
|
||||||
@@ -244,7 +241,7 @@ def main():
|
|||||||
scriptutils.logger_setup_color(logger, global_args.color)
|
scriptutils.logger_setup_color(logger, global_args.color)
|
||||||
|
|
||||||
if global_args.bbpath is None:
|
if global_args.bbpath is None:
|
||||||
tinfoil = setup_tinfoil(config_only=True)
|
tinfoil = setup_tinfoil(config_only=True, basepath=basepath)
|
||||||
global_args.bbpath = tinfoil.config_data.getVar('BBPATH', True)
|
global_args.bbpath = tinfoil.config_data.getVar('BBPATH', True)
|
||||||
else:
|
else:
|
||||||
tinfoil = None
|
tinfoil = None
|
||||||
|
|||||||
@@ -96,9 +96,12 @@ def exec_fakeroot(d, cmd, **kwargs):
|
|||||||
newenv[splitval[0]] = splitval[1]
|
newenv[splitval[0]] = splitval[1]
|
||||||
return subprocess.call("%s %s" % (fakerootcmd, cmd), env=newenv, **kwargs)
|
return subprocess.call("%s %s" % (fakerootcmd, cmd), env=newenv, **kwargs)
|
||||||
|
|
||||||
def setup_tinfoil(config_only=False):
|
def setup_tinfoil(config_only=False, basepath=None):
|
||||||
"""Initialize tinfoil api from bitbake"""
|
"""Initialize tinfoil api from bitbake"""
|
||||||
import scriptpath
|
import scriptpath
|
||||||
|
orig_cwd = os.path.abspath(os.curdir)
|
||||||
|
if basepath:
|
||||||
|
os.chdir(basepath)
|
||||||
bitbakepath = scriptpath.add_bitbake_lib_path()
|
bitbakepath = scriptpath.add_bitbake_lib_path()
|
||||||
if not bitbakepath:
|
if not bitbakepath:
|
||||||
logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
|
logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
|
||||||
@@ -108,6 +111,7 @@ def setup_tinfoil(config_only=False):
|
|||||||
tinfoil = bb.tinfoil.Tinfoil()
|
tinfoil = bb.tinfoil.Tinfoil()
|
||||||
tinfoil.prepare(config_only)
|
tinfoil.prepare(config_only)
|
||||||
tinfoil.logger.setLevel(logger.getEffectiveLevel())
|
tinfoil.logger.setLevel(logger.getEffectiveLevel())
|
||||||
|
os.chdir(orig_cwd)
|
||||||
return tinfoil
|
return tinfoil
|
||||||
|
|
||||||
def get_recipe_file(cooker, pn):
|
def get_recipe_file(cooker, pn):
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ def build_image(args, config, basepath, workspace):
|
|||||||
if os.path.isfile(appendfile):
|
if os.path.isfile(appendfile):
|
||||||
os.unlink(appendfile)
|
os.unlink(appendfile)
|
||||||
|
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
rd = parse_recipe(config, tinfoil, image, True)
|
rd = parse_recipe(config, tinfoil, image, True)
|
||||||
if not rd:
|
if not rd:
|
||||||
# Error already shown
|
# Error already shown
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def deploy(args, config, basepath, workspace):
|
|||||||
deploy_dir = os.path.join(basepath, 'target_deploy', args.target)
|
deploy_dir = os.path.join(basepath, 'target_deploy', args.target)
|
||||||
deploy_file = os.path.join(deploy_dir, args.recipename + '.list')
|
deploy_file = os.path.join(deploy_dir, args.recipename + '.list')
|
||||||
|
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
try:
|
try:
|
||||||
rd = oe.recipeutils.parse_recipe_simple(tinfoil.cooker, args.recipename, tinfoil.config_data)
|
rd = oe.recipeutils.parse_recipe_simple(tinfoil.cooker, args.recipename, tinfoil.config_data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def package(args, config, basepath, workspace):
|
|||||||
|
|
||||||
image_pkgtype = config.get('Package', 'image_pkgtype', '')
|
image_pkgtype = config.get('Package', 'image_pkgtype', '')
|
||||||
if not image_pkgtype:
|
if not image_pkgtype:
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
try:
|
try:
|
||||||
tinfoil.prepare(config_only=True)
|
tinfoil.prepare(config_only=True)
|
||||||
image_pkgtype = tinfoil.config_data.getVar('IMAGE_PKGTYPE', True)
|
image_pkgtype = tinfoil.config_data.getVar('IMAGE_PKGTYPE', True)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ logger = logging.getLogger('devtool')
|
|||||||
def runqemu(args, config, basepath, workspace):
|
def runqemu(args, config, basepath, workspace):
|
||||||
"""Entry point for the devtool 'runqemu' subcommand"""
|
"""Entry point for the devtool 'runqemu' subcommand"""
|
||||||
|
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
machine = tinfoil.config_data.getVar('MACHINE', True)
|
machine = tinfoil.config_data.getVar('MACHINE', True)
|
||||||
bindir_native = tinfoil.config_data.getVar('STAGING_BINDIR_NATIVE', True)
|
bindir_native = tinfoil.config_data.getVar('STAGING_BINDIR_NATIVE', True)
|
||||||
tinfoil.shutdown()
|
tinfoil.shutdown()
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ logger = logging.getLogger('devtool')
|
|||||||
def search(args, config, basepath, workspace):
|
def search(args, config, basepath, workspace):
|
||||||
"""Entry point for the devtool 'search' subcommand"""
|
"""Entry point for the devtool 'search' subcommand"""
|
||||||
|
|
||||||
tinfoil = setup_tinfoil(config_only=True)
|
tinfoil = setup_tinfoil(config_only=True, basepath=basepath)
|
||||||
pkgdata_dir = tinfoil.config_data.getVar('PKGDATA_DIR', True)
|
pkgdata_dir = tinfoil.config_data.getVar('PKGDATA_DIR', True)
|
||||||
tinfoil.shutdown()
|
tinfoil.shutdown()
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ def add(args, config, basepath, workspace):
|
|||||||
(stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
|
(stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
|
||||||
initial_rev = stdout.rstrip()
|
initial_rev = stdout.rstrip()
|
||||||
|
|
||||||
tinfoil = setup_tinfoil(config_only=True)
|
tinfoil = setup_tinfoil(config_only=True, basepath=basepath)
|
||||||
rd = oe.recipeutils.parse_recipe(recipefile, None, tinfoil.config_data)
|
rd = oe.recipeutils.parse_recipe(recipefile, None, tinfoil.config_data)
|
||||||
if not rd:
|
if not rd:
|
||||||
return 1
|
return 1
|
||||||
@@ -231,7 +231,7 @@ class BbTaskExecutor(object):
|
|||||||
def _prep_extract_operation(config, basepath, recipename):
|
def _prep_extract_operation(config, basepath, recipename):
|
||||||
"""HACK: Ugly workaround for making sure that requirements are met when
|
"""HACK: Ugly workaround for making sure that requirements are met when
|
||||||
trying to extract a package. Returns the tinfoil instance to be used."""
|
trying to extract a package. Returns the tinfoil instance to be used."""
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
rd = parse_recipe(config, tinfoil, recipename, True)
|
rd = parse_recipe(config, tinfoil, recipename, True)
|
||||||
|
|
||||||
if bb.data.inherits_class('kernel-yocto', rd):
|
if bb.data.inherits_class('kernel-yocto', rd):
|
||||||
@@ -239,7 +239,7 @@ def _prep_extract_operation(config, basepath, recipename):
|
|||||||
try:
|
try:
|
||||||
stdout, _ = exec_build_env_command(config.init_path, basepath,
|
stdout, _ = exec_build_env_command(config.init_path, basepath,
|
||||||
'bitbake kern-tools-native')
|
'bitbake kern-tools-native')
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
except bb.process.ExecutionError as err:
|
except bb.process.ExecutionError as err:
|
||||||
raise DevtoolError("Failed to build kern-tools-native:\n%s" %
|
raise DevtoolError("Failed to build kern-tools-native:\n%s" %
|
||||||
err.stdout)
|
err.stdout)
|
||||||
@@ -443,7 +443,7 @@ def modify(args, config, basepath, workspace):
|
|||||||
if args.extract:
|
if args.extract:
|
||||||
tinfoil = _prep_extract_operation(config, basepath, args.recipename)
|
tinfoil = _prep_extract_operation(config, basepath, args.recipename)
|
||||||
else:
|
else:
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
|
|
||||||
rd = parse_recipe(config, tinfoil, args.recipename, True)
|
rd = parse_recipe(config, tinfoil, args.recipename, True)
|
||||||
if not rd:
|
if not rd:
|
||||||
@@ -797,7 +797,7 @@ def update_recipe(args, config, basepath, workspace):
|
|||||||
raise DevtoolError('conf/layer.conf not found in bbappend '
|
raise DevtoolError('conf/layer.conf not found in bbappend '
|
||||||
'destination layer "%s"' % args.append)
|
'destination layer "%s"' % args.append)
|
||||||
|
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
|
|
||||||
rd = parse_recipe(config, tinfoil, args.recipename, True)
|
rd = parse_recipe(config, tinfoil, args.recipename, True)
|
||||||
if not rd:
|
if not rd:
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ def upgrade(args, config, basepath, workspace):
|
|||||||
if reason:
|
if reason:
|
||||||
raise DevtoolError(reason)
|
raise DevtoolError(reason)
|
||||||
|
|
||||||
tinfoil = setup_tinfoil()
|
tinfoil = setup_tinfoil(basepath=basepath)
|
||||||
|
|
||||||
rd = parse_recipe(config, tinfoil, args.recipename, True)
|
rd = parse_recipe(config, tinfoil, args.recipename, True)
|
||||||
if not rd:
|
if not rd:
|
||||||
|
|||||||
Reference in New Issue
Block a user