diff options
| -rw-r--r-- | meta/lib/oe/recipeutils.py | 23 |
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): | |||
| 158 | return outlist | 158 | return outlist |
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | def patch_recipe_file(fn, values, patch=False, relpath=''): | 161 | def patch_recipe_lines(fromlines, values): |
| 162 | """Update or insert variable values into a recipe file (assuming you | 162 | """Update or insert variable values into lines from a recipe. |
| 163 | have already identified the exact file you want to update.) | ||
| 164 | Note that some manual inspection/intervention may be required | 163 | Note that some manual inspection/intervention may be required |
| 165 | since this cannot handle all situations. | 164 | since this cannot handle all situations. |
| 166 | """ | 165 | """ |
| @@ -247,8 +246,7 @@ def patch_recipe_file(fn, values, patch=False, relpath=''): | |||
| 247 | 246 | ||
| 248 | # First run - establish which values we want to set are already in the file | 247 | # First run - establish which values we want to set are already in the file |
| 249 | varlist = [re.escape(item) for item in values.keys()] | 248 | varlist = [re.escape(item) for item in values.keys()] |
| 250 | with open(fn, 'r') as f: | 249 | bb.utils.edit_metadata(fromlines, varlist, patch_recipe_varfunc) |
| 251 | changed, fromlines = bb.utils.edit_metadata(f, varlist, patch_recipe_varfunc) | ||
| 252 | # Second run - actually set everything | 250 | # Second run - actually set everything |
| 253 | modifying = True | 251 | modifying = True |
| 254 | varlist.extend(recipe_progression_restrs) | 252 | varlist.extend(recipe_progression_restrs) |
| @@ -260,6 +258,21 @@ def patch_recipe_file(fn, values, patch=False, relpath=''): | |||
| 260 | for k in remainingnames.keys(): | 258 | for k in remainingnames.keys(): |
| 261 | outputvalue(k, tolines) | 259 | outputvalue(k, tolines) |
| 262 | 260 | ||
| 261 | return changed, tolines | ||
| 262 | |||
| 263 | |||
| 264 | def patch_recipe_file(fn, values, patch=False, relpath=''): | ||
| 265 | """Update or insert variable values into a recipe file (assuming you | ||
| 266 | have already identified the exact file you want to update.) | ||
| 267 | Note that some manual inspection/intervention may be required | ||
| 268 | since this cannot handle all situations. | ||
| 269 | """ | ||
| 270 | |||
| 271 | with open(fn, 'r') as f: | ||
| 272 | fromlines = f.readlines() | ||
| 273 | |||
| 274 | _, tolines = patch_recipe_lines(fromlines, values) | ||
| 275 | |||
| 263 | if patch: | 276 | if patch: |
| 264 | relfn = os.path.relpath(fn, relpath) | 277 | relfn = os.path.relpath(fn, relpath) |
| 265 | diff = difflib.unified_diff(fromlines, tolines, 'a/%s' % relfn, 'b/%s' % relfn) | 278 | diff = difflib.unified_diff(fromlines, tolines, 'a/%s' % relfn, 'b/%s' % relfn) |
