From 492b1eb1d2457bea2fd8fdd8fb5ef4e69a3af790 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 22 Feb 2016 11:54:40 +1300 Subject: devtool: upgrade: make source tree path optional Make devtool upgrade consistent with devtool add/modify in defaulting to sources/ under the workspace if no source tree path is specified. (From OE-Core rev: 8a952407b192313515e91570632446b6dff01665) Signed-off-by: Paul Eggleton Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- scripts/lib/devtool/upgrade.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'scripts/lib/devtool') 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): if pn in workspace: raise DevtoolError("recipe %s is already in your workspace" % pn) + if args.srctree: + srctree = os.path.abspath(args.srctree) + else: + srctree = standard.get_default_srctree(config, pn) + standard._check_compatible_recipe(pn, rd) if rd.getVar('PV', True) == args.version and rd.getVar('SRCREV', True) == args.srcrev: raise DevtoolError("Current and upgrade versions are the same version" % version) rf = None try: - rev1 = standard._extract_source(args.srctree, False, 'devtool-orig', False, rd) - rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, + rev1 = standard._extract_source(srctree, False, 'devtool-orig', False, rd) + rev2, md5, sha256 = _extract_new_source(args.version, srctree, args.no_patch, args.srcrev, args.branch, args.keep_temp, tinfoil, rd) rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, args.srcbranch, config.workspace_path, tinfoil, rd) except bb.process.CmdError as e: - _upgrade_error(e, rf, args.srctree) + _upgrade_error(e, rf, srctree) except DevtoolError as e: - _upgrade_error(e, rf, args.srctree) + _upgrade_error(e, rf, srctree) standard._add_md5(config, pn, os.path.dirname(rf)) - af = _write_append(rf, args.srctree, args.same_dir, args.no_same_dir, rev2, + af = _write_append(rf, srctree, args.same_dir, args.no_same_dir, rev2, config.workspace_path, rd) standard._add_md5(config, pn, af) - logger.info('Upgraded source extracted to %s' % args.srctree) + logger.info('Upgraded source extracted to %s' % srctree) return 0 def register_commands(subparsers, context): """Register devtool subcommands from this plugin""" + + defsrctree = standard.get_default_srctree(context.config) + parser_upgrade = subparsers.add_parser('upgrade', help='Upgrade an existing recipe', 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).', group='starting') parser_upgrade.add_argument('recipename', help='Name of recipe to upgrade (just name - no version, path or extension)') - parser_upgrade.add_argument('srctree', help='Path to where to extract the source tree') + 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) parser_upgrade.add_argument('--version', '-V', help='Version to upgrade to (PV)') parser_upgrade.add_argument('--srcrev', '-S', help='Source revision to upgrade to (if fetching from an SCM such as git)') parser_upgrade.add_argument('--srcbranch', '-B', help='Branch in source repository containing the revision to use (if fetching from an SCM such as git)') -- cgit 1.2.3-korg