Skip to contentSkip to conversation

devtool: warn user about multiple layer having the same base name

PATCH In review Chen Qi 2 participants 4 messages Jun 27, 2019 – Jun 28, 2019

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

cover devtool: warn user about multiple layer having the same base name

*** BLURB HERE ***
The following changes since commit 67266331b0f557c01cde1cc1b1a1de7197443a6c:

local.conf.sample.extended: remove redundant RUNTIMETARGET assignment (2019-06-24 17:34:25 +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: warn user about multiple layer having the same base name

 scripts/lib/devtool/standard.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 devtool: warn user about multiple layer having the same base name

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 at least give user a warning in such case. With the patch, we will get warning like below.

WARNING: Multiple layers have the same base name 'meta', use the first one '<PROJ_DIR>/oe-core/meta'.
WARNING: Consider using path instead of base name to specify layer:

	 	  <PROJ_DIR>/oe-core/meta
		  <PROJ_DIR>/meta-secure-core/meta
---
 scripts/lib/devtool/standard.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
scripts/lib/devtool/standard.py +18 -4
index aca74b1..47ed531 100644
@@ -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
+        logger.warning("Multiple layers have the same base name '%s', use the first one '%s'." % (layername, layer_paths[0]))
+        logger.warning("Consider using path instead of base name to specify layer:\n\t\t%s" % '\n\t\t'.join(layer_paths))
+        return os.path.abspath(layer_paths[0])
+
 
 def finish(args, config, basepath, workspace):
     """Entry point for the devtool 'finish' subcommand"""
Signature · 1 line
1.9.1
#2 lore raw
Quoted 3 lines · NZST Chen Qi

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.

Good catch!

Quoted 8 lines

We should at least give user a warning in such case. With the patch, we will get warning like below.

WARNING: Multiple layers have the same base name 'meta', use the first one '<PROJ_DIR>/oe-core/meta'.
WARNING: Consider using path instead of base name to specify layer:

	 	  <PROJ_DIR>/oe-core/meta
		  <PROJ_DIR>/meta-secure-core/meta

"use the first one" -> "using the first one"

However I'm wondering if this is the right behaviour. What if the user realises they actually wanted the second one? Given it's a warning the finish operation would have proceeded and the user will have to clean things up manually. Rather than a warning, should we in fact be erroring out and requiring the user to be more specific in this case?

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
author
#3 lore raw
Quoted 14 lines · Paul Eggleton
Quoted 3 lines · NZST Chen Qi

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.

Good catch!

Quoted 8 lines

We should at least give user a warning in such case. With the patch, we will get warning like below.

WARNING: Multiple layers have the same base name 'meta', use the first one '<PROJ_DIR>/oe-core/meta'.
WARNING: Consider using path instead of base name to specify layer:

	 	  <PROJ_DIR>/oe-core/meta
		  <PROJ_DIR>/meta-secure-core/meta
Quoted 7 lines

"use the first one" -> "using the first one"

However I'm wondering if this is the right behaviour. What if the user realises they actually wanted the second one? Given it's a warning the finish operation would have proceeded and the user will have to clean things up manually. Rather than a warning, should we in fact be erroring out and requiring the user to be more specific in this case?

Cheers,
Paul

More reasonable. I'll send out V2.

Best Regards,

Chen Qi