diff options
Diffstat (limited to 'meta/lib/bblayers/create.py')
-rw-r--r-- | meta/lib/bblayers/create.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/meta/lib/bblayers/create.py b/meta/lib/bblayers/create.py index 542f31fc81..517554c587 100644 --- a/meta/lib/bblayers/create.py +++ b/meta/lib/bblayers/create.py | |||
@@ -1,4 +1,6 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: GPL-2.0-only | 4 | # SPDX-License-Identifier: GPL-2.0-only |
3 | # | 5 | # |
4 | 6 | ||
@@ -10,6 +12,7 @@ import shutil | |||
10 | import bb.utils | 12 | import bb.utils |
11 | 13 | ||
12 | from bblayers.common import LayerPlugin | 14 | from bblayers.common import LayerPlugin |
15 | from bblayers.action import ActionPlugin | ||
13 | 16 | ||
14 | logger = logging.getLogger('bitbake-layers') | 17 | logger = logging.getLogger('bitbake-layers') |
15 | 18 | ||
@@ -35,6 +38,7 @@ class CreatePlugin(LayerPlugin): | |||
35 | bb.utils.mkdirhier(conf) | 38 | bb.utils.mkdirhier(conf) |
36 | 39 | ||
37 | layername = os.path.basename(os.path.normpath(args.layerdir)) | 40 | layername = os.path.basename(os.path.normpath(args.layerdir)) |
41 | layerid = args.layerid if args.layerid is not None else layername | ||
38 | 42 | ||
39 | # Create the README from templates/README | 43 | # Create the README from templates/README |
40 | readme_template = read_template('README').format(layername=layername) | 44 | readme_template = read_template('README').format(layername=layername) |
@@ -50,11 +54,11 @@ class CreatePlugin(LayerPlugin): | |||
50 | shutil.copy(license_src, license_dst) | 54 | shutil.copy(license_src, license_dst) |
51 | 55 | ||
52 | # Get the compat value for core layer. | 56 | # Get the compat value for core layer. |
53 | compat = self.tinfoil.config_data.getVar('LAYERSERIES_COMPAT_core') or "" | 57 | compat = self.tinfoil.config_data.getVar('LAYERSERIES_CORENAMES') or "" |
54 | 58 | ||
55 | # Create the layer.conf from templates/layer.conf | 59 | # Create the layer.conf from templates/layer.conf |
56 | layerconf_template = read_template('layer.conf').format( | 60 | layerconf_template = read_template('layer.conf').format( |
57 | layername=layername, priority=args.priority, compat=compat) | 61 | layerid=layerid, priority=args.priority, compat=compat) |
58 | layerconf = os.path.join(conf, 'layer.conf') | 62 | layerconf = os.path.join(conf, 'layer.conf') |
59 | with open(layerconf, 'w') as fd: | 63 | with open(layerconf, 'w') as fd: |
60 | fd.write(layerconf_template) | 64 | fd.write(layerconf_template) |
@@ -66,12 +70,21 @@ class CreatePlugin(LayerPlugin): | |||
66 | with open(os.path.join(example, args.examplerecipe + '_%s.bb') % args.version, 'w') as fd: | 70 | with open(os.path.join(example, args.examplerecipe + '_%s.bb') % args.version, 'w') as fd: |
67 | fd.write(example_template) | 71 | fd.write(example_template) |
68 | 72 | ||
69 | logger.plain('Add your new layer with \'bitbake-layers add-layer %s\'' % args.layerdir) | 73 | if args.add_layer: |
74 | # Add the layer to bblayers.conf | ||
75 | args.layerdir = [layerdir] | ||
76 | ActionPlugin.do_add_layer(self, args) | ||
77 | logger.plain('Layer added %s' % args.layerdir) | ||
78 | |||
79 | else: | ||
80 | logger.plain('Add your new layer with \'bitbake-layers add-layer %s\'' % args.layerdir) | ||
70 | 81 | ||
71 | def register_commands(self, sp): | 82 | def register_commands(self, sp): |
72 | parser_create_layer = self.add_command(sp, 'create-layer', self.do_create_layer, parserecipes=False) | 83 | parser_create_layer = self.add_command(sp, 'create-layer', self.do_create_layer, parserecipes=False) |
73 | parser_create_layer.add_argument('layerdir', help='Layer directory to create') | 84 | parser_create_layer.add_argument('layerdir', help='Layer directory to create') |
74 | parser_create_layer.add_argument('--priority', '-p', default=6, help='Layer directory to create') | 85 | parser_create_layer.add_argument('--add-layer', '-a', action='store_true', help='Add the layer to bblayers.conf after creation') |
86 | parser_create_layer.add_argument('--layerid', '-i', help='Layer id to use if different from layername') | ||
87 | parser_create_layer.add_argument('--priority', '-p', default=6, help='Priority of recipes in layer') | ||
75 | parser_create_layer.add_argument('--example-recipe-name', '-e', dest='examplerecipe', default='example', help='Filename of the example recipe') | 88 | parser_create_layer.add_argument('--example-recipe-name', '-e', dest='examplerecipe', default='example', help='Filename of the example recipe') |
76 | parser_create_layer.add_argument('--example-recipe-version', '-v', dest='version', default='0.1', help='Version number for the example recipe') | 89 | parser_create_layer.add_argument('--example-recipe-version', '-v', dest='version', default='0.1', help='Version number for the example recipe') |
77 | 90 | ||