* [PATCH] action: bitbake-layers new plugin to create a layer
@ 2017-06-19 15:00 leonardo.sandoval.gonzalez
2017-07-20 15:58 ` Paul Eggleton
0 siblings, 1 reply; 3+ messages in thread
From: leonardo.sandoval.gonzalez @ 2017-06-19 15:00 UTC (permalink / raw)
To: bitbake-devel
From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Creates a simple layer with a example recipe, where the latter
has just a single task (do_build). Layer's license is MIT and
layer's priority defaults to 6. Recipe name and layer's priority
can changed specified through the command line.
[YOCTO #11567]
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
---
bitbake/lib/bblayers/action.py | 121 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 121 insertions(+)
diff --git a/bitbake/lib/bblayers/action.py b/bitbake/lib/bblayers/action.py
index b1326e5f53..2384ef6dc1 100644
--- a/bitbake/lib/bblayers/action.py
+++ b/bitbake/lib/bblayers/action.py
@@ -220,6 +220,122 @@ build results (as the layer priority order has effectively changed).
if not entry_found:
logger.warning("File %s does not match the flattened layer's BBFILES setting, you may need to edit conf/layer.conf or move the file elsewhere" % f1full)
+ def do_create_layer(self, args):
+ """Create a basic layer"""
+ layerdir = os.path.abspath(args.layerdir)
+ if os.path.exists(layerdir):
+ sys.stderr.write("Specified layer directory exists\n")
+ return 1
+
+ # create dirs
+ conf = os.path.join(layerdir, 'conf')
+ bb.utils.mkdirhier(conf)
+
+ # readme
+ readme = os.path.join(layerdir, 'README')
+ with open(readme, 'w') as fd:
+ fd.write("""\
+This README file contains information on the contents of the %s layer.
+
+Please see the corresponding sections below for details.
+
+Dependencies
+============
+
+ URI: <first dependency>
+ branch: <branch name>
+
+ URI: <second dependency>
+ branch: <branch name>
+
+ .
+ .
+ .
+
+Patches
+=======
+
+Please submit any patches against the %s layer to the xxxx mailing list (xxxx@zzzz.org)
+and cc: the maintainer:
+
+Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
+
+Table of Contents
+=================
+
+ I. Adding the %s layer to your build
+ II. Misc
+
+
+I. Adding the %s layer to your build
+=================================================
+
+Run 'bitbake-layers add-layer %s'
+
+II. Misc
+========
+
+--- replace with specific information about the %s layer ---
+""" % (args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir))
+
+ # license
+ copying = os.path.join(layerdir, 'COPYING.MIT')
+ with open(copying, 'w') as fd:
+ fd.write("""\
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.""")
+
+ # layer.conf
+ layer_conf = os.path.join(conf, 'layer.conf')
+ with open(layer_conf, 'w') as fd:
+ fd.write("""\
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= \":${LAYERDIR}\"
+
+# We have recipes-* directories, add to BBFILES
+BBFILES += \"${LAYERDIR}/recipes-*/*/*.bb \\
+ ${LAYERDIR}/recipes-*/*/*.bbappend\"
+
+BBFILE_COLLECTIONS += \"%s\"
+BBFILE_PATTERN_%s = \"^${LAYERDIR}/\"
+BBFILE_PRIORITY_%s = \"%s\"
+""" % (args.layerdir, args.layerdir, args.layerdir, args.priority))
+
+ # example
+ example = os.path.join(layerdir, 'recipes-' + args.examplerecipe, args.examplerecipe)
+ bb.utils.mkdirhier(example)
+ with open(os.path.join(example, args.examplerecipe + '.bb'), 'w') as fd:
+ fd.write("""\
+SUMMARY = \"bitbake-layers recipe\"
+DESCRIPTION = \"Recipe created by bitbake-layers\"
+LICENSE = \"MIT\"
+
+python do_build() {
+ bb.plain(\"***********************************************\");
+ bb.plain(\"* *\");
+ bb.plain(\"* Example recipe created by bitbake-layers *\");
+ bb.plain(\"* *\");
+ bb.plain(\"***********************************************\");
+}
+""")
+
+ logger.plain('Add your new layer with \'bitbake-layers add-layer %s\'' % args.layerdir)
+
def get_file_layer(self, filename):
layerdir = self.get_file_layerdir(filename)
if layerdir:
@@ -249,3 +365,8 @@ build results (as the layer priority order has effectively changed).
parser_flatten = self.add_command(sp, 'flatten', self.do_flatten)
parser_flatten.add_argument('layer', nargs='*', help='Optional layer(s) to flatten (otherwise all are flattened)')
parser_flatten.add_argument('outputdir', help='Output directory')
+
+ 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('--priority', '-p', default=6, help='Layer directory to create')
+ parser_create_layer.add_argument('--example-recipe-name', '-e', dest='examplerecipe', default='example', help='Filename of the example recipe')
--
2.12.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] action: bitbake-layers new plugin to create a layer
2017-06-19 15:00 [PATCH] action: bitbake-layers new plugin to create a layer leonardo.sandoval.gonzalez
@ 2017-07-20 15:58 ` Paul Eggleton
2017-07-24 15:12 ` Leonardo Sandoval
0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggleton @ 2017-07-20 15:58 UTC (permalink / raw)
To: leonardo.sandoval.gonzalez; +Cc: Chris Larson, Brian Avery, bitbake-devel
(Brian reminded me of this, sorry for not replying earlier)
On Monday, 19 June 2017 5:00:18 PM CEST
leonardo.sandoval.gonzalez@linux.intel.com wrote:
> From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
>
> Creates a simple layer with a example recipe, where the latter
> has just a single task (do_build). Layer's license is MIT and
> layer's priority defaults to 6. Recipe name and layer's priority
> can changed specified through the command line.
So I'm generally in favour of adding this functionality to bitbake-layers and
making it more widely available in preference to yocto-layer. However, I'm a
bit concerned about the template recipe - it really doesn't belong in bitbake.
We could resolve that in one of two ways:
1) Look for the template within the metadata and provide one in OE-Core, or
2) Put the template *and* the plugin in OE-Core, since bitbake-layers should
support loading plugins from the metadata
I don't mind which but I'd lean towards #2 since it will probably require less
additional plumbing.
Additionally we'll probably want to change "yocto-layer create" to call this
and show a deprecation warning for the next release or two, and then drop it
afterwards.
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] action: bitbake-layers new plugin to create a layer
2017-07-20 15:58 ` Paul Eggleton
@ 2017-07-24 15:12 ` Leonardo Sandoval
0 siblings, 0 replies; 3+ messages in thread
From: Leonardo Sandoval @ 2017-07-24 15:12 UTC (permalink / raw)
To: Paul Eggleton; +Cc: Chris Larson, Brian Avery, bitbake-devel
On Thu, 2017-07-20 at 17:58 +0200, Paul Eggleton wrote:
> (Brian reminded me of this, sorry for not replying earlier)
>
> On Monday, 19 June 2017 5:00:18 PM CEST
> leonardo.sandoval.gonzalez@linux.intel.com wrote:
> > From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
> >
> > Creates a simple layer with a example recipe, where the latter
> > has just a single task (do_build). Layer's license is MIT and
> > layer's priority defaults to 6. Recipe name and layer's priority
> > can changed specified through the command line.
>
> So I'm generally in favour of adding this functionality to bitbake-layers and
> making it more widely available in preference to yocto-layer. However, I'm a
> bit concerned about the template recipe - it really doesn't belong in bitbake.
> We could resolve that in one of two ways:
>
> 1) Look for the template within the metadata and provide one in OE-Core, or
>
> 2) Put the template *and* the plugin in OE-Core, since bitbake-layers should
> support loading plugins from the metadata
>
When I started this, I did not think about using OE-Core so this can be
more generic, meaning that there is no need for OE-Core metadata to have
this feature working.
Now with your inputs, I can see point 2 as an option so let I can work
in that direction if all agree.
Leo
> I don't mind which but I'd lean towards #2 since it will probably require less
> additional plumbing.
>
> Additionally we'll probably want to change "yocto-layer create" to call this
> and show a deprecation warning for the next release or two, and then drop it
> afterwards.
>
> Cheers,
> Paul
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-24 15:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-19 15:00 [PATCH] action: bitbake-layers new plugin to create a layer leonardo.sandoval.gonzalez
2017-07-20 15:58 ` Paul Eggleton
2017-07-24 15:12 ` Leonardo Sandoval
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.