All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] bitbake-bblayers/create: Fix layer name generation
@ 2018-06-28 17:53 Joshua Watt
  2018-06-28 17:53 ` [PATCH 2/2] oe-selftest: Add bitbake-layer create-layer test Joshua Watt
  2018-06-29 17:54 ` [PATCH v2] " Joshua Watt
  0 siblings, 2 replies; 7+ messages in thread
From: Joshua Watt @ 2018-06-28 17:53 UTC (permalink / raw)
  To: openembedded-core

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]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 meta/lib/bblayers/create.py            |  7 +++++--
 meta/lib/bblayers/templates/README     | 12 ++++++------
 meta/lib/bblayers/templates/layer.conf | 16 ++++++++--------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/meta/lib/bblayers/create.py b/meta/lib/bblayers/create.py
index e06949c92b7..2ebf151ad18 100644
--- a/meta/lib/bblayers/create.py
+++ b/meta/lib/bblayers/create.py
@@ -30,8 +30,10 @@ class CreatePlugin(LayerPlugin):
         conf = os.path.join(layerdir, 'conf')
         bb.utils.mkdirhier(conf)
 
+        layername = os.path.basename(os.path.normpath(args.layerdir))
+
         # Create the README from templates/README
-        readme_template =  read_template('README') % (args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir, args.layerdir)
+        readme_template =  read_template('README').format(layername=layername)
         readme = os.path.join(layerdir, 'README')
         with open(readme, 'w') as fd:
             fd.write(readme_template)
@@ -47,7 +49,8 @@ class CreatePlugin(LayerPlugin):
         compat = self.tinfoil.config_data.getVar('LAYERSERIES_COMPAT_core') or ""
 
         # Create the layer.conf from templates/layer.conf
-        layerconf_template = read_template('layer.conf') % (args.layerdir, args.layerdir, args.layerdir, args.priority, args.layerdir, args.layerdir, compat)
+        layerconf_template = read_template('layer.conf').format(
+                layername=layername, priority=args.priority, compat=compat)
         layerconf = os.path.join(conf, 'layer.conf')
         with open(layerconf, 'w') as fd:
             fd.write(layerconf_template)
diff --git a/meta/lib/bblayers/templates/README b/meta/lib/bblayers/templates/README
index 5a77f8d3478..fb2d28e1771 100644
--- a/meta/lib/bblayers/templates/README
+++ b/meta/lib/bblayers/templates/README
@@ -1,4 +1,4 @@
-This README file contains information on the contents of the %s layer.
+This README file contains information on the contents of the {layername} layer.
 
 Please see the corresponding sections below for details.
 
@@ -18,7 +18,7 @@ Dependencies
 Patches
 =======
 
-Please submit any patches against the %s layer to the xxxx mailing list (xxxx@zzzz.org)
+Please submit any patches against the {layername} layer to the xxxx mailing list (xxxx@zzzz.org)
 and cc: the maintainer:
 
 Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
@@ -26,16 +26,16 @@ Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
 Table of Contents
 =================
 
-  I. Adding the %s layer to your build
+  I. Adding the {layername} layer to your build
  II. Misc
 
 
-I. Adding the %s layer to your build
+I. Adding the {layername} layer to your build
 =================================================
 
-Run 'bitbake-layers add-layer %s'
+Run 'bitbake-layers add-layer {layername}'
 
 II. Misc
 ========
 
---- replace with specific information about the %s layer ---
+--- 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 49f95cafc82..e2eaff43469 100644
--- a/meta/lib/bblayers/templates/layer.conf
+++ b/meta/lib/bblayers/templates/layer.conf
@@ -1,13 +1,13 @@
 # We have a conf and classes directory, add to BBPATH
-BBPATH .= ":${LAYERDIR}"
+BBPATH .= ":${{LAYERDIR}}"
 
 # We have recipes-* directories, add to BBFILES
-BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
-            ${LAYERDIR}/recipes-*/*/*.bbappend"
+BBFILES += "${{LAYERDIR}}/recipes-*/*/*.bb \
+            ${{LAYERDIR}}/recipes-*/*/*.bbappend"
 
-BBFILE_COLLECTIONS += "%s"
-BBFILE_PATTERN_%s = "^${LAYERDIR}/"
-BBFILE_PRIORITY_%s = "%s"
+BBFILE_COLLECTIONS += "{layername}"
+BBFILE_PATTERN_{layername} = "^${{LAYERDIR}}/"
+BBFILE_PRIORITY_{layername} = "{priority}"
 
-LAYERDEPENDS_%s = "core"
-LAYERSERIES_COMPAT_%s = "%s"
+LAYERDEPENDS_{layername} = "core"
+LAYERSERIES_COMPAT_{layername} = "{compat}"
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-30 16:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 17:53 [PATCH 1/2] bitbake-bblayers/create: Fix layer name generation Joshua Watt
2018-06-28 17:53 ` [PATCH 2/2] oe-selftest: Add bitbake-layer create-layer test Joshua Watt
2018-06-28 21:54   ` Richard Purdie
2018-06-29 17:54 ` [PATCH v2] " Joshua Watt
2018-06-30  9:57   ` Richard Purdie
2018-06-30 16:20     ` Joshua Watt
2018-06-30 16:16   ` [PATCH v3] " Joshua Watt

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.