[layerindex-web][PATCH] import_layer.py: support import layer to non-master branch

Changqing Li

From: Changqing Li <changqing.li@...>

Before this commit, it only support create layer on master branch,
support import layer to other branch to fix following issue:

For layer A, it only works on NON-MASTER branch. If we import
it use this tool, it will by default import it to master branch.
In master branch, bitbake is newer, and use new overrides style, but
layer A use old style overrides style, which make update.py -b
master report error:
INFO: Collecting data for layer A on branch master (NON-MASTER)
NOTE: Starting bitbake server...
ERROR: Variable PREMIRRORS_append contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake.
ERROR: Traceback (most recent call last):
File "update_layer.py", line 486, in main
layer_config_data = layerconfparser.parse_layer(layerdir)
File "/path/to/layerindex-web/layerindex/layerconfparse.py", line 47, in parse_layer
utils.parse_layer_conf(layerdir, self.config_data_copy, logger=self.logger)
File "/path/to/layerindex-web/layerindex/utils.py", line 288, in parse_layer_conf
data = parse_conf(conf_file, data)
File "/path/to/layerindex-web/layerindex/utils.py", line 273, in parse_conf
data = bb.parse.handle(conf_file, d, include=True)
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/parse/__init__.py", line 107, in handle
return h['handle'](fn, data, include)
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 149, in handle
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/parse/ast.py", line 19, in eval
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/parse/ast.py", line 145, in eval
data.setVar(key, val, parsing=True, **loginfo)
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/tinfoil.py", line 97, in remoteCommand
ret = self.tinfoil.run_command('dataStoreConnectorCmd', self.dsindex, cmd, args, kwargs)
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/tinfoil.py", line 469, in run_command
result = self.server_connection.connection.runCommand(commandline)
File "/path/to/layerindex/git___lxgit_wrs_com_bitbake/lib/bb/server/process.py", line 410, in runCommand
raise bb.BBHandledException()

Signed-off-by: Changqing Li <changqing.li@...>
layerindex/tools/import_layer.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/layerindex/tools/import_layer.py b/layerindex/tools/import_layer.py
index dfe887c..0c4881f 100755
--- a/layerindex/tools/import_layer.py
+++ b/layerindex/tools/import_layer.py
@@ -236,6 +236,9 @@ def main():
parser.add_option("-a", "--actual-branch",
help = "Set actual branch",
action="store", dest="actual_branch")
+ parser.add_option("-b", "--branch",
+ help = "Set branch to import",
+ action="store", dest="branch", default="master")

options, args = parser.parse_args(sys.argv)

@@ -284,7 +287,7 @@ def main():
if not os.path.exists(fetchdir):

- master_branch = utils.get_branch('master')
+ master_branch = utils.get_branch(options.branch)
core_layer = None
with transaction.atomic():
@@ -311,7 +314,7 @@ def main():
logger.error("Fetch failed: %s" % str(e))

- actual_branch = 'master'
+ actual_branch = options.branch
if (options.actual_branch):
actual_branch = options.actual_branch
@@ -324,7 +327,7 @@ def main():
actual_branch = line.split('-> origin/')[-1]
if not actual_branch:
- logger.error("Repository has no master branch nor origin/HEAD")
+ logger.error("Repository has no %s branch nor origin/HEAD" % options.branch)
out = utils.runcmd(['git', 'checkout', 'origin/%s' % actual_branch], repodir, logger=logger)

@@ -332,7 +335,7 @@ def main():
if options.subdir:
layerdir = os.path.join(repodir, options.subdir)
if not os.path.exists(layerdir):
- logger.error("Subdirectory %s does not exist in repository for master branch" % options.subdir)
+ logger.error("Subdirectory %s does not exist in repository for %s branch" % (options.subdir, options.branch))
if not os.path.exists(os.path.join(layerdir, 'conf/layer.conf')):
logger.error("conf/layer.conf not found in subdirectory %s" % options.subdir)

Join yocto@lists.yoctoproject.org to automatically receive all group messages.