devtool: update-recipe: better 'auto' mode

Enhance the logic behind the 'auto' mode a bit by only updating the
SRCREV if the changes are already found upstream. The logic is simple:
update SRCREV only if the current local HEAD commit is found in the
remote branch (i.e. 'origin/<branch_name>'). Otherwise resort to
patching.

This affects a couple of the oe-selftest tests so update those as well.

[YOCTO #7907]

(From OE-Core rev: 9b9733b7d74032aef4979bec553019421e77da14)

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Markus Lehtonen
2015-09-08 11:39:12 +01:00
committed by Richard Purdie
parent 0d0e50810a
commit 3dd9fc39ab
2 changed files with 53 additions and 13 deletions

View File

@@ -757,6 +757,31 @@ def _update_recipe_patch(args, config, srctree, rd, config_data):
_remove_patch_files(args, removepatches, destpath)
def _guess_recipe_update_mode(srctree, rdata):
"""Guess the recipe update mode to use"""
src_uri = (rdata.getVar('SRC_URI', False) or '').split()
git_uris = [uri for uri in src_uri if uri.startswith('git://')]
if not git_uris:
return 'patch'
# Just use the first URI for now
uri = git_uris[0]
# Check remote branch
upstr_branch = 'master'
for paramdef in uri.split(';')[1:]:
name, value = paramdef.split('=', 1)
if name == 'branch':
upstr_branch = value
# Check if current branch HEAD is found in upstream branch
stdout, _ = bb.process.run('git rev-parse HEAD', cwd=srctree)
head_rev = stdout.rstrip()
stdout, _ = bb.process.run('git branch -r --contains %s' % head_rev,
cwd=srctree)
remote_brs = [branch.strip() for branch in stdout.splitlines()]
if 'origin/' + upstr_branch in remote_brs:
return 'srcrev'
return 'patch'
def update_recipe(args, config, basepath, workspace):
"""Entry point for the devtool 'update-recipe' subcommand"""
if not args.recipename in workspace:
@@ -777,17 +802,12 @@ def update_recipe(args, config, basepath, workspace):
if not rd:
return 1
orig_src_uri = rd.getVar('SRC_URI', False) or ''
srctree = workspace[args.recipename]['srctree']
if args.mode == 'auto':
if 'git://' in orig_src_uri:
mode = 'srcrev'
else:
mode = 'patch'
mode = _guess_recipe_update_mode(srctree, rd)
else:
mode = args.mode
srctree = workspace[args.recipename]['srctree']
if mode == 'srcrev':
_update_recipe_srcrev(args, srctree, rd, tinfoil.config_data)
elif mode == 'patch':