summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-06-28 12:53:41 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-06-29 11:07:45 +0100
commit44b1fe43b0e97b1d01b95cd6ce40fbad78e65ab3 (patch)
treece88e4936b1de13dd3376c9c79970b18b546dfb3
parent1dec2101f9603d5340139f24d36c2e9f396eb311 (diff)
downloadpoky-44b1fe43b0e97b1d01b95cd6ce40fbad78e65ab3.tar.gz
bitbake-bblayers/create: Fix layer name generation
The path to where the layer was being created was taken verbatim as the name of the layer when generating the layer.conf and README files from templates. This causes problems in the layer.conf file because it would result in strangely named variables like BBFILE_PATTERN_../my-layer = "..." Instead of blindly taking the path, use the name of the last component of the path as the layer name. Additionally, rework the template files to use python format strings with named parameters so that the same argument doesn't have to be repeated multiple times. [YOCTO #12808] (From OE-Core rev: 01071c5d524a878d9de4814196cba2f15739796e) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/bblayers/create.py7
-rw-r--r--meta/lib/bblayers/templates/README12
-rw-r--r--meta/lib/bblayers/templates/layer.conf16
3 files changed, 19 insertions, 16 deletions
diff --git a/meta/lib/bblayers/create.py b/meta/lib/bblayers/create.py
index e06949c92b..2ebf151ad1 100644
--- a/meta/lib/bblayers/create.py
+++ b/meta/lib/bblayers/create.py
@@ -30,8 +30,10 @@ class CreatePlugin(LayerPlugin):
30 conf = os.path.join(layerdir, 'conf') 30 conf = os.path.join(layerdir, 'conf')
31 bb.utils.mkdirhier(conf) 31 bb.utils.mkdirhier(conf)
32 32
33 layername = os.path.basename(os.path.normpath(args.layerdir))
34
33 # Create the README from templates/README 35 # Create the README from templates/README
34 readme_template = read_template('README') % (args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir) 36 readme_template = read_template('README').format(layername=layername)
35 readme = os.path.join(layerdir, 'README') 37 readme = os.path.join(layerdir, 'README')
36 with open(readme, 'w') as fd: 38 with open(readme, 'w') as fd:
37 fd.write(readme_template) 39 fd.write(readme_template)
@@ -47,7 +49,8 @@ class CreatePlugin(LayerPlugin):
47 compat = self.tinfoil.config_data.getVar('LAYERSERIES_COMPAT_core') or "" 49 compat = self.tinfoil.config_data.getVar('LAYERSERIES_COMPAT_core') or ""
48 50
49 # Create the layer.conf from templates/layer.conf 51 # Create the layer.conf from templates/layer.conf
50 layerconf_template = read_template('layer.conf') % (args.layerdir, args.layerdir, args.layerdir, args.priority, args.layerdir, args.layerdir, compat) 52 layerconf_template = read_template('layer.conf').format(
53 layername=layername, priority=args.priority, compat=compat)
51 layerconf = os.path.join(conf, 'layer.conf') 54 layerconf = os.path.join(conf, 'layer.conf')
52 with open(layerconf, 'w') as fd: 55 with open(layerconf, 'w') as fd:
53 fd.write(layerconf_template) 56 fd.write(layerconf_template)
diff --git a/meta/lib/bblayers/templates/README b/meta/lib/bblayers/templates/README
index 5a77f8d347..fb2d28e177 100644
--- a/meta/lib/bblayers/templates/README
+++ b/meta/lib/bblayers/templates/README
@@ -1,4 +1,4 @@
1This README file contains information on the contents of the %s layer. 1This README file contains information on the contents of the {layername} layer.
2 2
3Please see the corresponding sections below for details. 3Please see the corresponding sections below for details.
4 4
@@ -18,7 +18,7 @@ Dependencies
18Patches 18Patches
19======= 19=======
20 20
21Please submit any patches against the %s layer to the xxxx mailing list (xxxx@zzzz.org) 21Please submit any patches against the {layername} layer to the xxxx mailing list (xxxx@zzzz.org)
22and cc: the maintainer: 22and cc: the maintainer:
23 23
24Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com> 24Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
@@ -26,16 +26,16 @@ Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
26Table of Contents 26Table of Contents
27================= 27=================
28 28
29 I. Adding the %s layer to your build 29 I. Adding the {layername} layer to your build
30 II. Misc 30 II. Misc
31 31
32 32
33I. Adding the %s layer to your build 33I. Adding the {layername} layer to your build
34================================================= 34=================================================
35 35
36Run 'bitbake-layers add-layer %s' 36Run 'bitbake-layers add-layer {layername}'
37 37
38II. Misc 38II. Misc
39======== 39========
40 40
41--- replace with specific information about the %s layer --- 41--- replace with specific information about the {layername} layer ---
diff --git a/meta/lib/bblayers/templates/layer.conf b/meta/lib/bblayers/templates/layer.conf
index 49f95cafc8..e2eaff4346 100644
--- a/meta/lib/bblayers/templates/layer.conf
+++ b/meta/lib/bblayers/templates/layer.conf
@@ -1,13 +1,13 @@
1# We have a conf and classes directory, add to BBPATH 1# We have a conf and classes directory, add to BBPATH
2BBPATH .= ":${LAYERDIR}" 2BBPATH .= ":${{LAYERDIR}}"
3 3
4# We have recipes-* directories, add to BBFILES 4# We have recipes-* directories, add to BBFILES
5BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ 5BBFILES += "${{LAYERDIR}}/recipes-*/*/*.bb \
6 ${LAYERDIR}/recipes-*/*/*.bbappend" 6 ${{LAYERDIR}}/recipes-*/*/*.bbappend"
7 7
8BBFILE_COLLECTIONS += "%s" 8BBFILE_COLLECTIONS += "{layername}"
9BBFILE_PATTERN_%s = "^${LAYERDIR}/" 9BBFILE_PATTERN_{layername} = "^${{LAYERDIR}}/"
10BBFILE_PRIORITY_%s = "%s" 10BBFILE_PRIORITY_{layername} = "{priority}"
11 11
12LAYERDEPENDS_%s = "core" 12LAYERDEPENDS_{layername} = "core"
13LAYERSERIES_COMPAT_%s = "%s" 13LAYERSERIES_COMPAT_{layername} = "{compat}"