diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-07-26 16:24:21 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-07-30 12:45:15 +0100 |
commit | 6ed781e0719d8f72238e7451cc206e3f9a76af52 (patch) | |
tree | 06492f6474607e7d81770d7cb3ce5a7478a4970d /bitbake/lib/bb/utils.py | |
parent | 2a1f7ad84284ee56a629805f01f4cca8a3f12b40 (diff) | |
download | poky-6ed781e0719d8f72238e7451cc206e3f9a76af52.tar.gz |
bitbake: 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).
(Bitbake rev: bfedb4e85a84e817dbe5d8694b8f8fcdd6f2f22a)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 378e699e0c..9903183213 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -1285,7 +1285,7 @@ def edit_metadata_file(meta_file, variables, varfunc): | |||
1285 | return updated | 1285 | return updated |
1286 | 1286 | ||
1287 | 1287 | ||
1288 | def edit_bblayers_conf(bblayers_conf, add, remove): | 1288 | def edit_bblayers_conf(bblayers_conf, add, remove, edit_cb=None): |
1289 | """Edit bblayers.conf, adding and/or removing layers | 1289 | """Edit bblayers.conf, adding and/or removing layers |
1290 | Parameters: | 1290 | Parameters: |
1291 | bblayers_conf: path to bblayers.conf file to edit | 1291 | bblayers_conf: path to bblayers.conf file to edit |
@@ -1293,6 +1293,8 @@ def edit_bblayers_conf(bblayers_conf, add, remove): | |||
1293 | list to add nothing | 1293 | list to add nothing |
1294 | remove: layer path (or list of layer paths) to remove; None or | 1294 | remove: layer path (or list of layer paths) to remove; None or |
1295 | empty list to remove nothing | 1295 | empty list to remove nothing |
1296 | edit_cb: optional callback function that will be called after | ||
1297 | processing adds/removes once per existing entry. | ||
1296 | Returns a tuple: | 1298 | Returns a tuple: |
1297 | notadded: list of layers specified to be added but weren't | 1299 | notadded: list of layers specified to be added but weren't |
1298 | (because they were already in the list) | 1300 | (because they were already in the list) |
@@ -1356,6 +1358,17 @@ def edit_bblayers_conf(bblayers_conf, add, remove): | |||
1356 | bblayers.append(addlayer) | 1358 | bblayers.append(addlayer) |
1357 | del addlayers[:] | 1359 | del addlayers[:] |
1358 | 1360 | ||
1361 | if edit_cb: | ||
1362 | newlist = [] | ||
1363 | for layer in bblayers: | ||
1364 | res = edit_cb(layer, canonicalise_path(layer)) | ||
1365 | if res != layer: | ||
1366 | newlist.append(res) | ||
1367 | updated = True | ||
1368 | else: | ||
1369 | newlist.append(layer) | ||
1370 | bblayers = newlist | ||
1371 | |||
1359 | if updated: | 1372 | if updated: |
1360 | if op == '+=' and not bblayers: | 1373 | if op == '+=' and not bblayers: |
1361 | bblayers = None | 1374 | bblayers = None |