Re: [master][kirkstone][PATCH 3/5] lib/oe/utils: create get_current_recipe_layer function


Jose Quaresma
 

Hi Davide,

Davide Gardenal <davidegarde2000@...> escreveu no dia terça, 28/06/2022 à(s) 14:38:
get_current_recipe_layer returns the recipe layer given its
file path.

Signed-off-by: Davide Gardenal <davide.gardenal@...>
---
 meta/lib/oe/utils.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 46fc76c261..4e17b1b40e 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -584,3 +584,11 @@ def directory_size(root, blocksize=4096):
         total += sum(roundup(getsize(os.path.join(root, name))) for name in files)
         total += roundup(getsize(root))
     return total
+
+def get_current_recipe_layer(d):
+    """
+    Extract the recipe layer from it's path.
+    Returns the layer name.
+    """
+    fdir_name  = d.getVar("FILE_DIRNAME")
+    return fdir_name.split("/")[-3]

This doesn't seem very safe as you are assuming that all layers use the same directory structure for placing the recipes. 
So for example dynamic layer will not work with this patch.

Jose
 
--
2.34.1






--
Best regards,

José Quaresma

Join {openembedded-core@lists.openembedded.org to automatically receive all group messages.