summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-11-10 14:45:17 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-23 11:10:13 +0000
commit55a157f4e687de98d78f74e0ec7b4e9883599319 (patch)
tree8702aaff3d6782ccfce84ab1f17d5acf4c82433f /scripts
parentd316363b7ba57cbf5300c6cd3b4cc68fb3258d6f (diff)
downloadpoky-55a157f4e687de98d78f74e0ec7b4e9883599319.tar.gz
devtool: update-recipe: fix handling of compressed local patches
It is possible to use gzip or bzip2 to compress patches and still refer to them in compressed form in the SRC_URI value within a recipe. If you run "devtool modify" on such a recipe, make changes to the commit for the patch and then run devtool update-recipe, we need to correctly associate the commit back to the compressed patch file and re-compress the patch, neither of which we were doing previously. Additionally, add an oe-selftest test to ensure this doesn't regress in future. Fixes [YOCTO #8278]. (From OE-Core rev: e47d21624dfec6f71742b837e91da553f18a28c5) 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.py55
1 files changed, 37 insertions, 18 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 1511641099..af0d467985 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1128,7 +1128,7 @@ def _remove_source_files(append, files, destpath):
1128 raise 1128 raise
1129 1129
1130 1130
1131def _export_patches(srctree, rd, start_rev, destdir): 1131def _export_patches(srctree, rd, start_rev, destdir, changed_revs=None):
1132 """Export patches from srctree to given location. 1132 """Export patches from srctree to given location.
1133 Returns three-tuple of dicts: 1133 Returns three-tuple of dicts:
1134 1. updated - patches that already exist in SRCURI 1134 1. updated - patches that already exist in SRCURI
@@ -1157,18 +1157,44 @@ def _export_patches(srctree, rd, start_rev, destdir):
1157 # revision This does assume that people are using unique shortlog 1157 # revision This does assume that people are using unique shortlog
1158 # values, but they ought to be anyway... 1158 # values, but they ought to be anyway...
1159 new_basename = seqpatch_re.match(new_patch).group(2) 1159 new_basename = seqpatch_re.match(new_patch).group(2)
1160 found = False 1160 match_name = None
1161 for old_patch in existing_patches: 1161 for old_patch in existing_patches:
1162 old_basename = seqpatch_re.match(old_patch).group(2) 1162 old_basename = seqpatch_re.match(old_patch).group(2)
1163 if new_basename == old_basename: 1163 old_basename_splitext = os.path.splitext(old_basename)
1164 updated[new_patch] = existing_patches.pop(old_patch) 1164 if old_basename.endswith(('.gz', '.bz2', '.Z')) and old_basename_splitext[0] == new_basename:
1165 found = True 1165 old_patch_noext = os.path.splitext(old_patch)[0]
1166 # Rename patch files 1166 match_name = old_patch_noext
1167 if new_patch != old_patch:
1168 os.rename(os.path.join(destdir, new_patch),
1169 os.path.join(destdir, old_patch))
1170 break 1167 break
1171 if not found: 1168 elif new_basename == old_basename:
1169 match_name = old_patch
1170 break
1171 if match_name:
1172 # Rename patch files
1173 if new_patch != match_name:
1174 os.rename(os.path.join(destdir, new_patch),
1175 os.path.join(destdir, match_name))
1176 # Need to pop it off the list now before checking changed_revs
1177 oldpath = existing_patches.pop(old_patch)
1178 if changed_revs is not None:
1179 # Avoid updating patches that have not actually changed
1180 with open(os.path.join(destdir, match_name), 'r') as f:
1181 firstlineitems = f.readline().split()
1182 # Looking for "From <hash>" line
1183 if len(firstlineitems) > 1 and len(firstlineitems[1]) == 40:
1184 if not firstlineitems[1] in changed_revs:
1185 continue
1186 # Recompress if necessary
1187 if oldpath.endswith(('.gz', '.Z')):
1188 bb.process.run(['gzip', match_name], cwd=destdir)
1189 if oldpath.endswith('.gz'):
1190 match_name += '.gz'
1191 else:
1192 match_name += '.Z'
1193 elif oldpath.endswith('.bz2'):
1194 bb.process.run(['bzip2', match_name], cwd=destdir)
1195 match_name += '.bz2'
1196 updated[match_name] = oldpath
1197 else:
1172 added[new_patch] = None 1198 added[new_patch] = None
1173 return (updated, added, existing_patches) 1199 return (updated, added, existing_patches)
1174 1200
@@ -1415,7 +1441,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1415 # Get updated patches from source tree 1441 # Get updated patches from source tree
1416 patches_dir = tempfile.mkdtemp(dir=tempdir) 1442 patches_dir = tempfile.mkdtemp(dir=tempdir)
1417 upd_p, new_p, del_p = _export_patches(srctree, rd, update_rev, 1443 upd_p, new_p, del_p = _export_patches(srctree, rd, update_rev,
1418 patches_dir) 1444 patches_dir, changed_revs)
1419 updatefiles = False 1445 updatefiles = False
1420 updaterecipe = False 1446 updaterecipe = False
1421 destpath = None 1447 destpath = None
@@ -1453,13 +1479,6 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1453 updatefiles = True 1479 updatefiles = True
1454 for basepath, path in upd_p.items(): 1480 for basepath, path in upd_p.items():
1455 patchfn = os.path.join(patches_dir, basepath) 1481 patchfn = os.path.join(patches_dir, basepath)
1456 if changed_revs is not None:
1457 # Avoid updating patches that have not actually changed
1458 with open(patchfn, 'r') as f:
1459 firstlineitems = f.readline().split()
1460 if len(firstlineitems) > 1 and len(firstlineitems[1]) == 40:
1461 if not firstlineitems[1] in changed_revs:
1462 continue
1463 logger.info('Updating patch %s' % basepath) 1482 logger.info('Updating patch %s' % basepath)
1464 _move_file(patchfn, path) 1483 _move_file(patchfn, path)
1465 updatefiles = True 1484 updatefiles = True