update_layer.py: avoid calling setup_core_layer_sys_path() when --initial

Fixed:
$ update.py -b <new_branch>
[snip]
NOTE: Starting bitbake server...
Traceback (most recent call last):
  File "update_layer.py", line 471, in main
    utils.setup_core_layer_sys_path(settings, branch.name)
  File "/buildarea1/lyang1/layerindex-web/layerindex/utils.py", line 376, in setup_core_layer_sys_path
    core_layerdir = os.path.join(core_repodir, core_layerbranch.vcs_subdir)
AttributeError: 'NoneType' object has no attribute 'vcs_subdir'
[snip]

This is because core_layerbranch is not in database yet for completely new
branch, so it is None and we will get the error. Avoid calling
setup_core_layer_sys_path() when "update_layer.py --initial" will fix the
problem.

And also only add core layer's sys path when it is present, since core layer
may not be added yet for completely new branch.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Robert Yang 2018-07-06 11:09:37 +08:00 committed by Paul Eggleton
parent 5cfdfdca8b
commit 635187b594
2 changed files with 15 additions and 13 deletions

View File

@ -426,15 +426,6 @@ def main():
# why won't they just fix that?!)
tinfoil.config_data.setVar('LICENSE', '')
# Set up for recording patch info
utils.setup_core_layer_sys_path(settings, branch.name)
skip_patches = False
try:
import oe.recipeutils
except ImportError:
logger.warn('Failed to find lib/oe/recipeutils.py in layers - patch information will not be collected')
skip_patches = True
layerconfparser = layerconfparse.LayerConfParse(logger=logger, tinfoil=tinfoil)
layer_config_data = layerconfparser.parse_layer(layerdir)
if not layer_config_data:
@ -447,6 +438,16 @@ def main():
for i in ["BBFILE_COLLECTIONS", "LAYERVERSION", "LAYERDEPENDS", "LAYERRECOMMENDS"]:
print('%s = "%s"' % (i, utils.get_layer_var(layer_config_data, i, logger)))
sys.exit(0)
# Set up for recording patch info
utils.setup_core_layer_sys_path(settings, branch.name)
skip_patches = False
try:
import oe.recipeutils
except ImportError:
logger.warn('Failed to find lib/oe/recipeutils.py in layers - patch information will not be collected')
skip_patches = True
utils.add_dependencies(layerbranch, layer_config_data, logger=logger)
utils.add_recommends(layerbranch, layer_config_data, logger=logger)
layerbranch.save()

View File

@ -371,10 +371,11 @@ def setup_core_layer_sys_path(settings, branchname):
"""
core_layer = get_layer(settings.CORE_LAYER_NAME)
core_layerbranch = core_layer.get_layerbranch(branchname)
core_urldir = core_layer.get_fetch_dir()
core_repodir = os.path.join(settings.LAYER_FETCH_DIR, core_urldir)
core_layerdir = os.path.join(core_repodir, core_layerbranch.vcs_subdir)
sys.path.insert(0, os.path.join(core_layerdir, 'lib'))
if core_layerbranch:
core_urldir = core_layer.get_fetch_dir()
core_repodir = os.path.join(settings.LAYER_FETCH_DIR, core_urldir)
core_layerdir = os.path.join(core_repodir, core_layerbranch.vcs_subdir)
sys.path.insert(0, os.path.join(core_layerdir, 'lib'))
def run_command_interruptible(cmd):
"""