summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/upgrade.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-11-23 12:22:09 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:03 +0000
commitf79cc4d9c37cc8b08b51491f335119b8caf84671 (patch)
treefb2b5eb0ff2b67b8f8d268aac5deaec8b35e8f5f /scripts/lib/devtool/upgrade.py
parentb4d4d2116a90eedfc86dfae5ec0d282b62d1d292 (diff)
downloadpoky-f79cc4d9c37cc8b08b51491f335119b8caf84671.tar.gz
devtool: upgrade: provide a means to update the source branch
If you're upgrading a git recipe to a revision on a release branch that's different to the branch for the current revision, then you'll need to update the branch parameter in SRC_URI, so add a --srcbranch/-B command-line parameter to let you do that easily. It handles both when the branch is stated verbatim in the recipe, and when a reference to another variable is used (a common convention is to use a SRCBRANCH variable for this, though the code doesn't care what variable is used if any). (From OE-Core rev: e49a66fd898dd44e54c77a838ebef3d983ed2a03) 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.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 13e3096325..86d1214908 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -255,7 +255,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, branch, keep_temp, tin
255 255
256 return (rev, md5, sha256) 256 return (rev, md5, sha256)
257 257
258def _create_new_recipe(newpv, md5, sha256, srcrev, workspace, tinfoil, rd): 258def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil, rd):
259 """Creates the new recipe under workspace""" 259 """Creates the new recipe under workspace"""
260 crd = rd.createCopy() 260 crd = rd.createCopy()
261 261
@@ -276,6 +276,31 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, workspace, tinfoil, rd):
276 if srcrev: 276 if srcrev:
277 newvalues['SRCREV'] = srcrev 277 newvalues['SRCREV'] = srcrev
278 278
279 if srcbranch:
280 src_uri = oe.recipeutils.split_var_value(rd.getVar('SRC_URI', False) or '')
281 changed = False
282 replacing = True
283 new_src_uri = []
284 for entry in src_uri:
285 scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(entry)
286 if replacing and scheme in ['git', 'gitsm']:
287 branch = params.get('branch', 'master')
288 if rd.expand(branch) != srcbranch:
289 # Handle case where branch is set through a variable
290 res = re.match(r'\$\{([^}@]+)\}', branch)
291 if res:
292 newvalues[res.group(1)] = srcbranch
293 # We know we won't change SRC_URI now, so break out
294 break
295 else:
296 params['branch'] = srcbranch
297 entry = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params))
298 changed = True
299 replacing = False
300 new_src_uri.append(entry)
301 if changed:
302 newvalues['SRC_URI'] = ' '.join(new_src_uri)
303
279 if newvalues: 304 if newvalues:
280 rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data) 305 rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data)
281 oe.recipeutils.patch_recipe(rd, fullpath, newvalues) 306 oe.recipeutils.patch_recipe(rd, fullpath, newvalues)
@@ -295,6 +320,8 @@ def upgrade(args, config, basepath, workspace):
295 raise DevtoolError("recipe %s is already in your workspace" % args.recipename) 320 raise DevtoolError("recipe %s is already in your workspace" % args.recipename)
296 if not args.version and not args.srcrev: 321 if not args.version and not args.srcrev:
297 raise DevtoolError("You must provide a version using the --version/-V option, or for recipes that fetch from an SCM such as git, the --srcrev/-S option") 322 raise DevtoolError("You must provide a version using the --version/-V option, or for recipes that fetch from an SCM such as git, the --srcrev/-S option")
323 if args.srcbranch and not args.srcrev:
324 raise DevtoolError("If you specify --srcbranch/-B then you must use --srcrev/-S to specify the revision" % args.recipename)
298 325
299 reason = oe.recipeutils.validate_pn(args.recipename) 326 reason = oe.recipeutils.validate_pn(args.recipename)
300 if reason: 327 if reason:
@@ -322,7 +349,7 @@ def upgrade(args, config, basepath, workspace):
322 rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, 349 rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch,
323 args.srcrev, args.branch, args.keep_temp, 350 args.srcrev, args.branch, args.keep_temp,
324 tinfoil, rd) 351 tinfoil, rd)
325 rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, config.workspace_path, tinfoil, rd) 352 rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, args.srcbranch, config.workspace_path, tinfoil, rd)
326 except bb.process.CmdError as e: 353 except bb.process.CmdError as e:
327 _upgrade_error(e, rf, args.srctree) 354 _upgrade_error(e, rf, args.srctree)
328 except DevtoolError as e: 355 except DevtoolError as e:
@@ -343,6 +370,7 @@ def register_commands(subparsers, context):
343 parser_upgrade.add_argument('srctree', help='Path to where to extract the source tree') 370 parser_upgrade.add_argument('srctree', help='Path to where to extract the source tree')
344 parser_upgrade.add_argument('--version', '-V', help='Version to upgrade to (PV)') 371 parser_upgrade.add_argument('--version', '-V', help='Version to upgrade to (PV)')
345 parser_upgrade.add_argument('--srcrev', '-S', help='Source revision to upgrade to (if fetching from an SCM such as git)') 372 parser_upgrade.add_argument('--srcrev', '-S', help='Source revision to upgrade to (if fetching from an SCM such as git)')
373 parser_upgrade.add_argument('--srcbranch', '-B', help='Branch in source repository containing the revision to use (if fetching from an SCM such as git)')
346 parser_upgrade.add_argument('--branch', '-b', default="devtool", help='Name for new development branch to checkout (default "%(default)s")') 374 parser_upgrade.add_argument('--branch', '-b', default="devtool", help='Name for new development branch to checkout (default "%(default)s")')
347 parser_upgrade.add_argument('--no-patch', action="store_true", help='Do not apply patches from the recipe to the new source code') 375 parser_upgrade.add_argument('--no-patch', action="store_true", help='Do not apply patches from the recipe to the new source code')
348 group = parser_upgrade.add_mutually_exclusive_group() 376 group = parser_upgrade.add_mutually_exclusive_group()