summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-11-10 14:45:18 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-23 11:10:13 +0000
commit13c3a4bfa279ae66937c257586f11df6713d9297 (patch)
tree63a9e6582985568854c0e656512aba97f4d47a4a /scripts
parent55a157f4e687de98d78f74e0ec7b4e9883599319 (diff)
downloadpoky-13c3a4bfa279ae66937c257586f11df6713d9297.tar.gz
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. (From OE-Core rev: a19c26cc78a181f9dd2706dd42e7e450d7ad4082) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/standard.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index af0d467985..34de7bd623 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1104,6 +1104,15 @@ def _remove_file_entries(srcuri, filelist):
1104 break 1104 break
1105 return entries, remaining 1105 return entries, remaining
1106 1106
1107def _replace_srcuri_entry(srcuri, filename, newentry):
1108 """Replace entry corresponding to specified file with a new entry"""
1109 basename = os.path.basename(filename)
1110 for i in range(len(srcuri)):
1111 if os.path.basename(srcuri[i].split(';')[0]) == basename:
1112 srcuri.pop(i)
1113 srcuri.insert(i, newentry)
1114 break
1115
1107def _remove_source_files(append, files, destpath): 1116def _remove_source_files(append, files, destpath):
1108 """Unlink existing patch files""" 1117 """Unlink existing patch files"""
1109 for path in files: 1118 for path in files:
@@ -1424,6 +1433,10 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1424 raise DevtoolError('Unable to find initial revision - please specify ' 1433 raise DevtoolError('Unable to find initial revision - please specify '
1425 'it with --initial-rev') 1434 'it with --initial-rev')
1426 1435
1436 dl_dir = rd.getVar('DL_DIR', True)
1437 if not dl_dir.endswith('/'):
1438 dl_dir += '/'
1439
1427 tempdir = tempfile.mkdtemp(prefix='devtool') 1440 tempdir = tempfile.mkdtemp(prefix='devtool')
1428 try: 1441 try:
1429 local_files_dir = tempfile.mkdtemp(dir=tempdir) 1442 local_files_dir = tempfile.mkdtemp(dir=tempdir)
@@ -1468,6 +1481,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1468 logger.info('No patches or local source files needed updating') 1481 logger.info('No patches or local source files needed updating')
1469 else: 1482 else:
1470 # Update existing files 1483 # Update existing files
1484 files_dir = _determine_files_dir(rd)
1471 for basepath, path in upd_f.items(): 1485 for basepath, path in upd_f.items():
1472 logger.info('Updating file %s' % basepath) 1486 logger.info('Updating file %s' % basepath)
1473 if os.path.isabs(basepath): 1487 if os.path.isabs(basepath):
@@ -1479,11 +1493,19 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1479 updatefiles = True 1493 updatefiles = True
1480 for basepath, path in upd_p.items(): 1494 for basepath, path in upd_p.items():
1481 patchfn = os.path.join(patches_dir, basepath) 1495 patchfn = os.path.join(patches_dir, basepath)
1482 logger.info('Updating patch %s' % basepath) 1496 if os.path.dirname(path) + '/' == dl_dir:
1497 # This is a a downloaded patch file - we now need to
1498 # replace the entry in SRC_URI with our local version
1499 logger.info('Replacing remote patch %s with updated local version' % basepath)
1500 path = os.path.join(files_dir, basepath)
1501 _replace_srcuri_entry(srcuri, basepath, 'file://%s' % basepath)
1502 updaterecipe = True
1503 else:
1504 logger.info('Updating patch %s' % basepath)
1505 logger.debug('Moving new patch %s to %s' % (patchfn, path))
1483 _move_file(patchfn, path) 1506 _move_file(patchfn, path)
1484 updatefiles = True 1507 updatefiles = True
1485 # Add any new files 1508 # Add any new files
1486 files_dir = _determine_files_dir(rd)
1487 for basepath, path in new_f.items(): 1509 for basepath, path in new_f.items():
1488 logger.info('Adding new file %s' % basepath) 1510 logger.info('Adding new file %s' % basepath)
1489 _move_file(os.path.join(local_files_dir, basepath), 1511 _move_file(os.path.join(local_files_dir, basepath),