summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-10-30 17:16:56 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-11 12:14:27 +0000
commitfcb84383ce9b555c13772515ec4f1f1f9b34737d (patch)
tree3fcdcf426f97bc956c041867787b005937ec0bb0
parentf6e21d1bfcb5d9d10c14afa7715c128700282db8 (diff)
downloadpoky-fcb84383ce9b555c13772515ec4f1f1f9b34737d.tar.gz
devtool: upgrade: automatically handle changes to source subdirectory
If the directory where the source code extracts to changes (for example, when upgrading iucode-tool from 1.5 to 2.1.1, the subdirectory in the tarball changed from "iucode_tool-${PV}" to "iucode-tool-${PV}") then handle this automatically. Also handle when it changes to match the default S value (i.e. "${WORKDIR}/${BP}") in which case we just drop setting S in the recipe. Fixes [YOCTO #10939]. (From OE-Core rev: d29881a652bf03627d257a1eac5f02ec17315b8b) 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>
-rw-r--r--scripts/lib/devtool/standard.py9
-rw-r--r--scripts/lib/devtool/upgrade.py28
2 files changed, 28 insertions, 9 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 166862f12f..5ac678b3b1 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -409,7 +409,7 @@ def extract(args, config, basepath, workspace):
409 return 1 409 return 1
410 410
411 srctree = os.path.abspath(args.srctree) 411 srctree = os.path.abspath(args.srctree)
412 initial_rev = _extract_source(srctree, args.keep_temp, args.branch, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil) 412 initial_rev, _ = _extract_source(srctree, args.keep_temp, args.branch, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil)
413 logger.info('Source tree extracted to %s' % srctree) 413 logger.info('Source tree extracted to %s' % srctree)
414 414
415 if initial_rev: 415 if initial_rev:
@@ -433,7 +433,7 @@ def sync(args, config, basepath, workspace):
433 return 1 433 return 1
434 434
435 srctree = os.path.abspath(args.srctree) 435 srctree = os.path.abspath(args.srctree)
436 initial_rev = _extract_source(srctree, args.keep_temp, args.branch, True, config, basepath, workspace, args.fixed_setup, rd, tinfoil) 436 initial_rev, _ = _extract_source(srctree, args.keep_temp, args.branch, True, config, basepath, workspace, args.fixed_setup, rd, tinfoil)
437 logger.info('Source tree %s synchronized' % srctree) 437 logger.info('Source tree %s synchronized' % srctree)
438 438
439 if initial_rev: 439 if initial_rev:
@@ -549,6 +549,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
549 549
550 with open(os.path.join(tempdir, 'srcsubdir'), 'r') as f: 550 with open(os.path.join(tempdir, 'srcsubdir'), 'r') as f:
551 srcsubdir = f.read() 551 srcsubdir = f.read()
552 srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 'workdir'))
552 553
553 tempdir_localdir = os.path.join(tempdir, 'oe-local-files') 554 tempdir_localdir = os.path.join(tempdir, 'oe-local-files')
554 srctree_localdir = os.path.join(srctree, 'oe-local-files') 555 srctree_localdir = os.path.join(srctree, 'oe-local-files')
@@ -615,7 +616,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
615 logger.info('Preserving temporary directory %s' % tempdir) 616 logger.info('Preserving temporary directory %s' % tempdir)
616 else: 617 else:
617 shutil.rmtree(tempdir) 618 shutil.rmtree(tempdir)
618 return initial_rev 619 return initial_rev, srcsubdir_rel
619 620
620def _add_md5(config, recipename, filename): 621def _add_md5(config, recipename, filename):
621 """Record checksum of a file (or recursively for a directory) to the md5-file of the workspace""" 622 """Record checksum of a file (or recursively for a directory) to the md5-file of the workspace"""
@@ -713,7 +714,7 @@ def modify(args, config, basepath, workspace):
713 initial_rev = None 714 initial_rev = None
714 commits = [] 715 commits = []
715 if not args.no_extract: 716 if not args.no_extract:
716 initial_rev = _extract_source(srctree, args.keep_temp, args.branch, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil) 717 initial_rev, _ = _extract_source(srctree, args.keep_temp, args.branch, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil)
717 if not initial_rev: 718 if not initial_rev:
718 return 1 719 return 1
719 logger.info('Source tree extracted to %s' % srctree) 720 logger.info('Source tree extracted to %s' % srctree)
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index e7d47b9755..0db2a50e90 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -191,6 +191,8 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
191 __run('git tag -f devtool-base-new') 191 __run('git tag -f devtool-base-new')
192 md5 = None 192 md5 = None
193 sha256 = None 193 sha256 = None
194 _, _, _, _, _, params = bb.fetch2.decodeurl(uri)
195 srcsubdir_rel = params.get('destsuffix', 'git')
194 if not srcbranch: 196 if not srcbranch:
195 check_branch, check_branch_err = __run('git branch -r --contains %s' % srcrev) 197 check_branch, check_branch_err = __run('git branch -r --contains %s' % srcrev)
196 get_branch = [x.strip() for x in check_branch.splitlines()] 198 get_branch = [x.strip() for x in check_branch.splitlines()]
@@ -225,6 +227,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
225 227
226 tmpsrctree = _get_srctree(tmpdir) 228 tmpsrctree = _get_srctree(tmpdir)
227 srctree = os.path.abspath(srctree) 229 srctree = os.path.abspath(srctree)
230 srcsubdir_rel = os.path.relpath(tmpsrctree, tmpdir)
228 231
229 # Delete all sources so we ensure no stray files are left over 232 # Delete all sources so we ensure no stray files are left over
230 for item in os.listdir(srctree): 233 for item in os.listdir(srctree):
@@ -288,9 +291,9 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
288 else: 291 else:
289 shutil.rmtree(tmpsrctree) 292 shutil.rmtree(tmpsrctree)
290 293
291 return (rev, md5, sha256, srcbranch) 294 return (rev, md5, sha256, srcbranch, srcsubdir_rel)
292 295
293def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil, rd): 296def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd):
294 """Creates the new recipe under workspace""" 297 """Creates the new recipe under workspace"""
295 298
296 bpn = rd.getVar('BPN') 299 bpn = rd.getVar('BPN')
@@ -384,6 +387,21 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil
384 newvalues['SRC_URI[%smd5sum]' % nameprefix] = md5 387 newvalues['SRC_URI[%smd5sum]' % nameprefix] = md5
385 newvalues['SRC_URI[%ssha256sum]' % nameprefix] = sha256 388 newvalues['SRC_URI[%ssha256sum]' % nameprefix] = sha256
386 389
390 if srcsubdir_new != srcsubdir_old:
391 s_subdir_old = os.path.relpath(os.path.abspath(rd.getVar('S')), rd.getVar('WORKDIR'))
392 s_subdir_new = os.path.relpath(os.path.abspath(crd.getVar('S')), crd.getVar('WORKDIR'))
393 if srcsubdir_old == s_subdir_old and srcsubdir_new != s_subdir_new:
394 # Subdir for old extracted source matches what S points to (it should!)
395 # but subdir for new extracted source doesn't match what S will be
396 newvalues['S'] = '${WORKDIR}/%s' % srcsubdir_new.replace(newpv, '${PV}')
397 if crd.expand(newvalues['S']) == crd.expand('${WORKDIR}/${BP}'):
398 # It's the default, drop it
399 # FIXME what if S is being set in a .inc?
400 newvalues['S'] = None
401 logger.info('Source subdirectory has changed, dropping S value since it now matches the default ("${WORKDIR}/${BP}")')
402 else:
403 logger.info('Source subdirectory has changed, updating S value')
404
387 rd = tinfoil.parse_recipe_file(fullpath, False) 405 rd = tinfoil.parse_recipe_file(fullpath, False)
388 oe.recipeutils.patch_recipe(rd, fullpath, newvalues) 406 oe.recipeutils.patch_recipe(rd, fullpath, newvalues)
389 407
@@ -458,12 +476,12 @@ def upgrade(args, config, basepath, workspace):
458 rf = None 476 rf = None
459 try: 477 try:
460 logger.info('Extracting current version source...') 478 logger.info('Extracting current version source...')
461 rev1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil) 479 rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil)
462 logger.info('Extracting upgraded version source...') 480 logger.info('Extracting upgraded version source...')
463 rev2, md5, sha256, srcbranch = _extract_new_source(args.version, srctree, args.no_patch, 481 rev2, md5, sha256, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch,
464 args.srcrev, args.srcbranch, args.branch, args.keep_temp, 482 args.srcrev, args.srcbranch, args.branch, args.keep_temp,
465 tinfoil, rd) 483 tinfoil, rd)
466 rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, config.workspace_path, tinfoil, rd) 484 rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd)
467 except bb.process.CmdError as e: 485 except bb.process.CmdError as e:
468 _upgrade_error(e, rf, srctree) 486 _upgrade_error(e, rf, srctree)
469 except DevtoolError as e: 487 except DevtoolError as e: