summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/upgrade.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/devtool/upgrade.py')
-rw-r--r--scripts/lib/devtool/upgrade.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 0e53c8286e..a446c557bc 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -313,36 +313,44 @@ def upgrade(args, config, basepath, workspace):
313 if pn in workspace: 313 if pn in workspace:
314 raise DevtoolError("recipe %s is already in your workspace" % pn) 314 raise DevtoolError("recipe %s is already in your workspace" % pn)
315 315
316 if args.srctree:
317 srctree = os.path.abspath(args.srctree)
318 else:
319 srctree = standard.get_default_srctree(config, pn)
320
316 standard._check_compatible_recipe(pn, rd) 321 standard._check_compatible_recipe(pn, rd)
317 if rd.getVar('PV', True) == args.version and rd.getVar('SRCREV', True) == args.srcrev: 322 if rd.getVar('PV', True) == args.version and rd.getVar('SRCREV', True) == args.srcrev:
318 raise DevtoolError("Current and upgrade versions are the same version" % version) 323 raise DevtoolError("Current and upgrade versions are the same version" % version)
319 324
320 rf = None 325 rf = None
321 try: 326 try:
322 rev1 = standard._extract_source(args.srctree, False, 'devtool-orig', False, rd) 327 rev1 = standard._extract_source(srctree, False, 'devtool-orig', False, rd)
323 rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, 328 rev2, md5, sha256 = _extract_new_source(args.version, srctree, args.no_patch,
324 args.srcrev, args.branch, args.keep_temp, 329 args.srcrev, args.branch, args.keep_temp,
325 tinfoil, rd) 330 tinfoil, rd)
326 rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, args.srcbranch, config.workspace_path, tinfoil, rd) 331 rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, args.srcbranch, config.workspace_path, tinfoil, rd)
327 except bb.process.CmdError as e: 332 except bb.process.CmdError as e:
328 _upgrade_error(e, rf, args.srctree) 333 _upgrade_error(e, rf, srctree)
329 except DevtoolError as e: 334 except DevtoolError as e:
330 _upgrade_error(e, rf, args.srctree) 335 _upgrade_error(e, rf, srctree)
331 standard._add_md5(config, pn, os.path.dirname(rf)) 336 standard._add_md5(config, pn, os.path.dirname(rf))
332 337
333 af = _write_append(rf, args.srctree, args.same_dir, args.no_same_dir, rev2, 338 af = _write_append(rf, srctree, args.same_dir, args.no_same_dir, rev2,
334 config.workspace_path, rd) 339 config.workspace_path, rd)
335 standard._add_md5(config, pn, af) 340 standard._add_md5(config, pn, af)
336 logger.info('Upgraded source extracted to %s' % args.srctree) 341 logger.info('Upgraded source extracted to %s' % srctree)
337 return 0 342 return 0
338 343
339def register_commands(subparsers, context): 344def register_commands(subparsers, context):
340 """Register devtool subcommands from this plugin""" 345 """Register devtool subcommands from this plugin"""
346
347 defsrctree = standard.get_default_srctree(context.config)
348
341 parser_upgrade = subparsers.add_parser('upgrade', help='Upgrade an existing recipe', 349 parser_upgrade = subparsers.add_parser('upgrade', help='Upgrade an existing recipe',
342 description='Upgrades an existing recipe to a new upstream version. Puts the upgraded recipe file into the workspace along with any associated files, and extracts the source tree to a specified location (in case patches need rebasing or adding to as a result of the upgrade).', 350 description='Upgrades an existing recipe to a new upstream version. Puts the upgraded recipe file into the workspace along with any associated files, and extracts the source tree to a specified location (in case patches need rebasing or adding to as a result of the upgrade).',
343 group='starting') 351 group='starting')
344 parser_upgrade.add_argument('recipename', help='Name of recipe to upgrade (just name - no version, path or extension)') 352 parser_upgrade.add_argument('recipename', help='Name of recipe to upgrade (just name - no version, path or extension)')
345 parser_upgrade.add_argument('srctree', help='Path to where to extract the source tree') 353 parser_upgrade.add_argument('srctree', nargs='?', help='Path to where to extract the source tree. If not specified, a subdirectory of %s will be used.' % defsrctree)
346 parser_upgrade.add_argument('--version', '-V', help='Version to upgrade to (PV)') 354 parser_upgrade.add_argument('--version', '-V', help='Version to upgrade to (PV)')
347 parser_upgrade.add_argument('--srcrev', '-S', help='Source revision to upgrade to (if fetching from an SCM such as git)') 355 parser_upgrade.add_argument('--srcrev', '-S', help='Source revision to upgrade to (if fetching from an SCM such as git)')
348 parser_upgrade.add_argument('--srcbranch', '-B', help='Branch in source repository containing the revision to use (if fetching from an SCM such as git)') 356 parser_upgrade.add_argument('--srcbranch', '-B', help='Branch in source repository containing the revision to use (if fetching from an SCM such as git)')