On Wed, 2021-12-15 at 13:12 +0100, Konrad Weihmann wrote:
> so one can get the layer name from a filepath
> 
> Signed-off-by: Konrad Weihmann <kweihm...@outlook.com>
> ---
> v2: order by path length to correctly map nested layer
> 
>  meta/lib/oe/recipeutils.py | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
> index a0c6974f04..557e0f9bd5 100644
> --- a/meta/lib/oe/recipeutils.py
> +++ b/meta/lib/oe/recipeutils.py
> @@ -21,7 +21,7 @@ import glob
>  import bb.tinfoil
>  
>  from collections import OrderedDict, defaultdict
> -from bb.utils import vercmp_string
> +from bb.utils import vercmp_string, get_collection_res
>  
>  # Help us to find places to insert values
>  recipe_progression = ['SUMMARY', 'DESCRIPTION', 'AUTHOR', 'HOMEPAGE', 
> 'BUGTRACKER', 'SECTION', 'LICENSE', 'LICENSE_FLAGS', 'LIC_FILES_CHKSUM', 
> 'PROVIDES', 'DEPENDS', 'PR', 'PV', 'SRCREV', 'SRCPV', 'SRC_URI', 'S', 
> 'do_fetch()', 'do_unpack()', 'do_patch()', 'EXTRA_OECONF', 'EXTRA_OECMAKE', 
> 'EXTRA_OESCONS', 'do_configure()', 'EXTRA_OEMAKE', 'do_compile()', 
> 'do_install()', 'do_populate_sysroot()', 'INITSCRIPT', 'USERADD', 'GROUPADD', 
> 'PACKAGES', 'FILES', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RPROVIDES', 
> 'RREPLACES', 'RCONFLICTS', 'ALLOW_EMPTY', 'populate_packages()', 
> 'do_package()', 'do_deploy()', 'BBCLASSEXTEND']
> @@ -928,6 +928,15 @@ def find_layerdir(fn):
>              return None
>      return layerdir
>  
> +def get_layer_name(fn, d):
> +    """ Get the layer name from a filename """
> +    pth = os.path.abspath(fn)
> +    collection = get_collection_res(d)
> +    # reverse ordering by length to catch nested layers
> +    for k, v in dict(sorted(collection.items(), key=lambda item: 
> len(item[1]), reverse=True)).items():
> +        if re.match(v, pth):
> +            return k
> +    return ""
>  
>  def replace_dir_vars(path, d):
>      """Replace common directory paths with appropriate variable references 
> (e.g. /etc becomes ${sysconfdir})"""


I suspect we should add something in bb.utils for this? I also think we should
probably do this at the bitbake level entirely, i.e. set some kind of variable
to the layername rather than having lots of metadata code trying to do it,
potentially badly?

Cheers,

Richard


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#159786): 
https://lists.openembedded.org/g/openembedded-core/message/159786
Mute This Topic: https://lists.openembedded.org/mt/87742384/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to