create.py: add command arg to add layer to bblayers.conf

Add command arg `--add-layer` which enables the create
and add layer in a single step.

(From OE-Core rev: f3be788a55a2dde1f627aa85b08dc3ffa55d751f)

Signed-off-by: Pedro Baptista <pedro.miguel.baptista@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Pedro Baptista 2023-02-21 11:49:21 +00:00 committed by Richard Purdie
parent f77bf57f26
commit 803e781e42

View File

@ -12,6 +12,7 @@ import shutil
import bb.utils
from bblayers.common import LayerPlugin
from bblayers.action import ActionPlugin
logger = logging.getLogger('bitbake-layers')
@ -69,11 +70,19 @@ class CreatePlugin(LayerPlugin):
with open(os.path.join(example, args.examplerecipe + '_%s.bb') % args.version, 'w') as fd:
fd.write(example_template)
logger.plain('Add your new layer with \'bitbake-layers add-layer %s\'' % args.layerdir)
if args.add_layer:
# Add the layer to bblayers.conf
args.layerdir = [layerdir]
ActionPlugin.do_add_layer(self, args)
logger.plain('Layer added %s' % args.layerdir)
else:
logger.plain('Add your new layer with \'bitbake-layers add-layer %s\'' % args.layerdir)
def register_commands(self, sp):
parser_create_layer = self.add_command(sp, 'create-layer', self.do_create_layer, parserecipes=False)
parser_create_layer.add_argument('layerdir', help='Layer directory to create')
parser_create_layer.add_argument('--add-layer', '-a', action='store_true', help='Add the layer to bblayers.conf after creation')
parser_create_layer.add_argument('--layerid', '-i', help='Layer id to use if different from layername')
parser_create_layer.add_argument('--priority', '-p', default=6, help='Priority of recipes in layer')
parser_create_layer.add_argument('--example-recipe-name', '-e', dest='examplerecipe', default='example', help='Filename of the example recipe')