summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-05-30 10:20:56 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-01 12:38:41 +0100
commitc93602c2ac2e1cec8317069075e23ba6c3293fab (patch)
tree6b2db2b8609fcefb955df06342964a83fd6762a8 /meta/lib
parentfcc2c3c4b3ca08528722442c90acd27e89291405 (diff)
downloadopenembedded-core-contrib-c93602c2ac2e1cec8317069075e23ba6c3293fab.tar.gz
openembedded-core-contrib-c93602c2ac2e1cec8317069075e23ba6c3293fab.tar.bz2
openembedded-core-contrib-c93602c2ac2e1cec8317069075e23ba6c3293fab.zip
lib/oe/recipeutils: split out patch_recipe_lines()
Split out a function from patch_recipe_file() that takes just the lines as input so we can edit recipe lines in memory. This will be used within recipetool to ensure we insert new values in the right place. (From OE-Core rev: d780642f950fb3a9699f466a405a2710d870dd08) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/recipeutils.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index 6c7adb5bdb..ef827550eb 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -158,9 +158,8 @@ def split_var_value(value, assignment=True):
return outlist
-def patch_recipe_file(fn, values, patch=False, relpath=''):
- """Update or insert variable values into a recipe file (assuming you
- have already identified the exact file you want to update.)
+def patch_recipe_lines(fromlines, values):
+ """Update or insert variable values into lines from a recipe.
Note that some manual inspection/intervention may be required
since this cannot handle all situations.
"""
@@ -247,8 +246,7 @@ def patch_recipe_file(fn, values, patch=False, relpath=''):
# First run - establish which values we want to set are already in the file
varlist = [re.escape(item) for item in values.keys()]
- with open(fn, 'r') as f:
- changed, fromlines = bb.utils.edit_metadata(f, varlist, patch_recipe_varfunc)
+ bb.utils.edit_metadata(fromlines, varlist, patch_recipe_varfunc)
# Second run - actually set everything
modifying = True
varlist.extend(recipe_progression_restrs)
@@ -260,6 +258,21 @@ def patch_recipe_file(fn, values, patch=False, relpath=''):
for k in remainingnames.keys():
outputvalue(k, tolines)
+ return changed, tolines
+
+
+def patch_recipe_file(fn, values, patch=False, relpath=''):
+ """Update or insert variable values into a recipe file (assuming you
+ have already identified the exact file you want to update.)
+ Note that some manual inspection/intervention may be required
+ since this cannot handle all situations.
+ """
+
+ with open(fn, 'r') as f:
+ fromlines = f.readlines()
+
+ _, tolines = patch_recipe_lines(fromlines, values)
+
if patch:
relfn = os.path.relpath(fn, relpath)
diff = difflib.unified_diff(fromlines, tolines, 'a/%s' % relfn, 'b/%s' % relfn)