[oe-commits] [bitbake] 15/15: utils: add optional callback to edit_bblayers_conf()

git at git.openembedded.org git at git.openembedded.org
Mon Feb 25 22:28:36 UTC 2019

This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch 1.38
in repository bitbake.

commit 4f6ba26e8335f975038d90b9e1c1767160bd5272
Author: Paul Eggleton <paul.eggleton at linux.intel.com>
AuthorDate: Thu Jul 26 16:24:21 2018 +0200

    utils: add optional callback to edit_bblayers_conf()
    Add a callback that lets you modify or remove items in addition to the
    current scheme where you can only add or remove. This enables you to for
    example replace a layer with a temporary copy (which is what we will use
    this for first in OE's oe-selftest).
    Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
 lib/bb/utils.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 2ff7e82..b20cdab 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1290,7 +1290,7 @@ def edit_metadata_file(meta_file, variables, varfunc):
     return updated
-def edit_bblayers_conf(bblayers_conf, add, remove):
+def edit_bblayers_conf(bblayers_conf, add, remove, edit_cb=None):
     """Edit bblayers.conf, adding and/or removing layers
         bblayers_conf: path to bblayers.conf file to edit
@@ -1298,6 +1298,8 @@ def edit_bblayers_conf(bblayers_conf, add, remove):
             list to add nothing
         remove: layer path (or list of layer paths) to remove; None or
             empty list to remove nothing
+        edit_cb: optional callback function that will be called after
+            processing adds/removes once per existing entry.
     Returns a tuple:
         notadded: list of layers specified to be added but weren't
             (because they were already in the list)
@@ -1361,6 +1363,17 @@ def edit_bblayers_conf(bblayers_conf, add, remove):
             del addlayers[:]
+        if edit_cb:
+            newlist = []
+            for layer in bblayers:
+                res = edit_cb(layer, canonicalise_path(layer))
+                if res != layer:
+                    newlist.append(res)
+                    updated = True
+                else:
+                    newlist.append(layer)
+            bblayers = newlist
         if updated:
             if op == '+=' and not bblayers:
                 bblayers = None

To stop receiving notification emails like this one, please contact
the administrator of this repository.

More information about the Openembedded-commits mailing list