diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-10-30 17:16:56 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-11-11 12:14:27 +0000 |
commit | fcb84383ce9b555c13772515ec4f1f1f9b34737d (patch) | |
tree | 3fcdcf426f97bc956c041867787b005937ec0bb0 /scripts/lib/devtool/upgrade.py | |
parent | f6e21d1bfcb5d9d10c14afa7715c128700282db8 (diff) | |
download | poky-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>
Diffstat (limited to 'scripts/lib/devtool/upgrade.py')
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 28 |
1 files changed, 23 insertions, 5 deletions
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 | ||
293 | def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil, rd): | 296 | def _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: |