Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH V2 0/1] devtool: error out when using base name provided by multiple layers
@ 2019-06-28  6:25 Chen Qi
  2019-06-28  6:25 ` [PATCH V2 1/1] " Chen Qi
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Qi @ 2019-06-28  6:25 UTC (permalink / raw)
  To: openembedded-core

Changes in V2:
* Error out instead of just warning users.

The following changes since commit bfe3012ea4b2c973bd6ca5fa1de1adf51e1a9da4:

  busybox: Fix typo in syslog initscript (2019-06-27 13:28:48 +0100)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib ChenQi/devtool-finish
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/devtool-finish

Chen Qi (1):
  devtool: error out when using base name provided by multiple layers

 scripts/lib/devtool/standard.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

-- 
1.9.1



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

* [PATCH V2 1/1] devtool: error out when using base name provided by multiple layers
  2019-06-28  6:25 [PATCH V2 0/1] devtool: error out when using base name provided by multiple layers Chen Qi
@ 2019-06-28  6:25 ` Chen Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Chen Qi @ 2019-06-28  6:25 UTC (permalink / raw)
  To: openembedded-core

Currently `devtool finish RECIPE meta' will silently succeed even
if there are multiple layers having the same base name of 'meta'.
e.g. meta layer from oe-core and meta layer from meta-secure-core.

We should error out and give users useful information in such case.
With the patch, we will get error like below.

ERROR: Multiple layers have the same base name 'meta'. Consider using path instead of base name to specify layer:
        PROJ_DIR/oe-core/meta
        PROJ_DIR/meta-secure-core/meta

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 scripts/lib/devtool/standard.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index aca74b1..1841791 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1866,13 +1866,27 @@ def reset(args, config, basepath, workspace):
 def _get_layer(layername, d):
     """Determine the base layer path for the specified layer name/path"""
     layerdirs = d.getVar('BBLAYERS').split()
-    layers = {os.path.basename(p): p for p in layerdirs}
+    layers = {}    # {basename: layer_paths}
+    for p in layerdirs:
+        bn = os.path.basename(p)
+        if bn not in layers:
+            layers[bn] = [p]
+        else:
+            layers[bn].append(p)
     # Provide some shortcuts
     if layername.lower() in ['oe-core', 'openembedded-core']:
-        layerdir = layers.get('meta', None)
+        layername = 'meta'
+    layer_paths = layers.get(layername, None)
+    if not layer_paths:
+        return os.path.abspath(layername)
+    elif len(layer_paths) == 1:
+        return os.path.abspath(layer_paths[0])
     else:
-        layerdir = layers.get(layername, None)
-    return os.path.abspath(layerdir or layername)
+        # multiple layers having the same base name
+        msg = "Multiple layers have the same base name '%s'. " % layername
+        msg += "Consider using path instead of base name to specify layer:\n\t%s" % '\n\t'.join(layer_paths)
+        raise DevtoolError(msg)
+
 
 def finish(args, config, basepath, workspace):
     """Entry point for the devtool 'finish' subcommand"""
-- 
1.9.1



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

end of thread, other threads:[~2019-06-28  6:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-28  6:25 [PATCH V2 0/1] devtool: error out when using base name provided by multiple layers Chen Qi
2019-06-28  6:25 ` [PATCH V2 1/1] " Chen Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox