diff options
authorPaul Eggleton <>2016-11-10 14:45:18 +1300
committerRichard Purdie <>2016-11-23 11:02:27 +0000
commita19c26cc78a181f9dd2706dd42e7e450d7ad4082 (patch)
parente47d21624dfec6f71742b837e91da553f18a28c5 (diff)
devtool: update-recipe: support replacing remote patches
If you have a patch remotely fetched in a recipe (e.g. from an http server) that needs updating then add a local version and substitute the entry in SRC_URI to point to it. One can argue about how desirable it is to be modifying patches fetched in this way, but then one can argue about how desirable it is to have such patches in the recipe in the first place - and in any case if devtool update-recipe is to correctly transfer changes to such patches made in the git repository within the source tree to the recipe then there isn't much choice but to do it this way. Signed-off-by: Paul Eggleton <> Signed-off-by: Ross Burton <>
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/lib/devtool/ b/scripts/lib/devtool/
index af0d467985..34de7bd623 100644
--- a/scripts/lib/devtool/
+++ b/scripts/lib/devtool/
@@ -1104,6 +1104,15 @@ def _remove_file_entries(srcuri, filelist):
return entries, remaining
+def _replace_srcuri_entry(srcuri, filename, newentry):
+ """Replace entry corresponding to specified file with a new entry"""
+ basename = os.path.basename(filename)
+ for i in range(len(srcuri)):
+ if os.path.basename(srcuri[i].split(';')[0]) == basename:
+ srcuri.pop(i)
+ srcuri.insert(i, newentry)
+ break
def _remove_source_files(append, files, destpath):
"""Unlink existing patch files"""
for path in files:
@@ -1424,6 +1433,10 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
raise DevtoolError('Unable to find initial revision - please specify '
'it with --initial-rev')
+ dl_dir = rd.getVar('DL_DIR', True)
+ if not dl_dir.endswith('/'):
+ dl_dir += '/'
tempdir = tempfile.mkdtemp(prefix='devtool')
local_files_dir = tempfile.mkdtemp(dir=tempdir)
@@ -1468,6 +1481,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil'No patches or local source files needed updating')
# Update existing files
+ files_dir = _determine_files_dir(rd)
for basepath, path in upd_f.items():'Updating file %s' % basepath)
if os.path.isabs(basepath):
@@ -1479,11 +1493,19 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
updatefiles = True
for basepath, path in upd_p.items():
patchfn = os.path.join(patches_dir, basepath)
-'Updating patch %s' % basepath)
+ if os.path.dirname(path) + '/' == dl_dir:
+ # This is a a downloaded patch file - we now need to
+ # replace the entry in SRC_URI with our local version
+'Replacing remote patch %s with updated local version' % basepath)
+ path = os.path.join(files_dir, basepath)
+ _replace_srcuri_entry(srcuri, basepath, 'file://%s' % basepath)
+ updaterecipe = True
+ else:
+'Updating patch %s' % basepath)
+ logger.debug('Moving new patch %s to %s' % (patchfn, path))
_move_file(patchfn, path)
updatefiles = True
# Add any new files
- files_dir = _determine_files_dir(rd)
for basepath, path in new_f.items():'Adding new file %s' % basepath)
_move_file(os.path.join(local_files_dir, basepath),