summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-07-25 15:37:17 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-09 09:24:16 +0100
commit884f74250d0ccaa6ebeaf2b3d1d17179b1dcc09b (patch)
tree8cf121f34e9465f25025a8dbe15657b8349365f1
parent1df5a58b12c5f6d0e1492e20ddea81af5ec2221e (diff)
downloadpoky-884f74250d0ccaa6ebeaf2b3d1d17179b1dcc09b.tar.gz
action: new bitbake-layer plugin to create a simple layer
Though the script bitbake-layers (from the bitbake project), this plugin creates a simple layer with a example recipe, the latter with a single task (do_build). Layer's license and priority is MIT and 6, respectively. Example recipe and layer's priority can be specified through the command line. [YOCTO #11567] (From OE-Core rev: 2bd1dc287b8b0f7edac8c6fee076a70ebf7adf43) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/bblayers/create.py66
-rw-r--r--meta/lib/bblayers/templates/README41
-rw-r--r--meta/lib/bblayers/templates/example.bb11
-rw-r--r--meta/lib/bblayers/templates/layer.conf10
4 files changed, 128 insertions, 0 deletions
diff --git a/meta/lib/bblayers/create.py b/meta/lib/bblayers/create.py
new file mode 100644
index 0000000000..6a41fe0504
--- /dev/null
+++ b/meta/lib/bblayers/create.py
@@ -0,0 +1,66 @@
1import logging
2import os
3import sys
4import shutil
5
6import bb.utils
7
8from bblayers.common import LayerPlugin
9
10logger = logging.getLogger('bitbake-layers')
11
12def plugin_init(plugins):
13 return CreatePlugin()
14
15def read_template(template, template_dir='templates'):
16 lines = str()
17 with open(os.path.join(os.path.dirname(__file__), template_dir, template)) as fd:
18 lines = ''.join(fd.readlines())
19 return lines
20
21class CreatePlugin(LayerPlugin):
22 def do_create_layer(self, args):
23 """Create a basic layer"""
24 layerdir = os.path.abspath(args.layerdir)
25 if os.path.exists(layerdir):
26 sys.stderr.write("Specified layer directory exists\n")
27 return 1
28
29 # create dirs
30 conf = os.path.join(layerdir, 'conf')
31 bb.utils.mkdirhier(conf)
32
33 # Create the README from templates/README
34 readme_template = read_template('README') % (args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir)
35 readme = os.path.join(layerdir, 'README')
36 with open(readme, 'w') as fd:
37 fd.write(readme_template)
38
39 # Copy the MIT license from meta
40 copying = 'COPYING.MIT'
41 dn = os.path.dirname
42 license_src = os.path.join(dn(dn(dn(__file__))), copying)
43 license_dst = os.path.join(layerdir, copying)
44 shutil.copy(license_src, license_dst)
45
46 # Create the layer.conf from templates/layer.conf
47 layerconf_template = read_template('layer.conf') % (args.layerdir, args.layerdir, args.layerdir, args.priority)
48 layerconf = os.path.join(conf, 'layer.conf')
49 with open(layerconf, 'w') as fd:
50 fd.write(layerconf_template)
51
52 # Create the example from templates/example.bb
53 example_template = read_template('example.bb')
54 example = os.path.join(layerdir, 'recipes-' + args.examplerecipe, args.examplerecipe)
55 bb.utils.mkdirhier(example)
56 with open(os.path.join(example, args.examplerecipe + '.bb'), 'w') as fd:
57 fd.write(example_template)
58
59 logger.plain('Add your new layer with \'bitbake-layers add-layer %s\'' % args.layerdir)
60
61 def register_commands(self, sp):
62 parser_create_layer = self.add_command(sp, 'create-layer', self.do_create_layer, parserecipes=False)
63 parser_create_layer.add_argument('layerdir', help='Layer directory to create')
64 parser_create_layer.add_argument('--priority', '-p', default=6, help='Layer directory to create')
65 parser_create_layer.add_argument('--example-recipe-name', '-e', dest='examplerecipe', default='example', help='Filename of the example recipe')
66
diff --git a/meta/lib/bblayers/templates/README b/meta/lib/bblayers/templates/README
new file mode 100644
index 0000000000..5a77f8d347
--- /dev/null
+++ b/meta/lib/bblayers/templates/README
@@ -0,0 +1,41 @@
1This README file contains information on the contents of the %s layer.
2
3Please see the corresponding sections below for details.
4
5Dependencies
6============
7
8 URI: <first dependency>
9 branch: <branch name>
10
11 URI: <second dependency>
12 branch: <branch name>
13
14 .
15 .
16 .
17
18Patches
19=======
20
21Please submit any patches against the %s layer to the xxxx mailing list (xxxx@zzzz.org)
22and cc: the maintainer:
23
24Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
25
26Table of Contents
27=================
28
29 I. Adding the %s layer to your build
30 II. Misc
31
32
33I. Adding the %s layer to your build
34=================================================
35
36Run 'bitbake-layers add-layer %s'
37
38II. Misc
39========
40
41--- replace with specific information about the %s layer ---
diff --git a/meta/lib/bblayers/templates/example.bb b/meta/lib/bblayers/templates/example.bb
new file mode 100644
index 0000000000..c4b873d593
--- /dev/null
+++ b/meta/lib/bblayers/templates/example.bb
@@ -0,0 +1,11 @@
1SUMMARY = "bitbake-layers recipe"
2DESCRIPTION = "Recipe created by bitbake-layers"
3LICENSE = "MIT"
4
5python do_build() {
6 bb.plain("***********************************************");
7 bb.plain("* *");
8 bb.plain("* Example recipe created by bitbake-layers *");
9 bb.plain("* *");
10 bb.plain("***********************************************");
11}
diff --git a/meta/lib/bblayers/templates/layer.conf b/meta/lib/bblayers/templates/layer.conf
new file mode 100644
index 0000000000..e0d9ba2fde
--- /dev/null
+++ b/meta/lib/bblayers/templates/layer.conf
@@ -0,0 +1,10 @@
1# We have a conf and classes directory, add to BBPATH
2BBPATH .= ":${LAYERDIR}"
3
4# We have recipes-* directories, add to BBFILES
5BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \\
6 ${LAYERDIR}/recipes-*/*/*.bbappend"
7
8BBFILE_COLLECTIONS += "%s"
9BBFILE_PATTERN_%s = "^${LAYERDIR}/"
10BBFILE_PRIORITY_%s = "%s"