]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
lib/oe/recipeutils: allow patch_recipe_file() to be re-called
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Wed, 29 Nov 2017 02:00:52 +0000 (15:00 +1300)
committerPaul Eggleton <paul.eggleton@linux.intel.com>
Tue, 5 Dec 2017 01:39:23 +0000 (14:39 +1300)
If patch_recipe_file() is called with output redirection on the same
file twice in succession, then we don't want to wipe out the changes the
first call made so we need to be reading in the redirected file if it
exists instead of the original one.

This is important to enable devtool finish to work with multiple source
trees within the same recipe.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
meta/lib/oe/recipeutils.py

index 4e0859e6d902cdfbf93cef715dd6758e17e543e3..49287273c9f64765cba90ad701b1cb0ca03ed756 100644 (file)
@@ -258,13 +258,18 @@ def patch_recipe_file(fn, values, patch=False, relpath='', redirect_output=None)
        since this cannot handle all situations.
     """
 
-    with open(fn, 'r') as f:
+    read_fn = fn
+    if redirect_output:
+        redirect_fn = os.path.join(redirect_output, os.path.basename(fn))
+        if os.path.exists(redirect_fn):
+            read_fn = redirect_fn
+    with open(read_fn, 'r') as f:
         fromlines = f.readlines()
 
     _, tolines = patch_recipe_lines(fromlines, values)
 
     if redirect_output:
-        with open(os.path.join(redirect_output, os.path.basename(fn)), 'w') as f:
+        with open(redirect_fn, 'w') as f:
             f.writelines(tolines)
         return None
     elif patch: