diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2015-09-08 11:39:12 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-09 14:27:52 +0100 |
commit | 3dd9fc39abdbccdbc313b577e7750974e3d6454e (patch) | |
tree | fb5458798559fa4c3def01120a1ae0c6b43c113e /scripts/lib/devtool/standard.py | |
parent | 0d0e50810a793f517b253e329339ba40d4bedd36 (diff) | |
download | poky-3dd9fc39abdbccdbc313b577e7750974e3d6454e.tar.gz |
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>
Diffstat (limited to 'scripts/lib/devtool/standard.py')
-rw-r--r-- | scripts/lib/devtool/standard.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index cbc023247e..f76c632e78 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -757,6 +757,31 @@ def _update_recipe_patch(args, config, srctree, rd, config_data): | |||
757 | 757 | ||
758 | _remove_patch_files(args, removepatches, destpath) | 758 | _remove_patch_files(args, removepatches, destpath) |
759 | 759 | ||
760 | def _guess_recipe_update_mode(srctree, rdata): | ||
761 | """Guess the recipe update mode to use""" | ||
762 | src_uri = (rdata.getVar('SRC_URI', False) or '').split() | ||
763 | git_uris = [uri for uri in src_uri if uri.startswith('git://')] | ||
764 | if not git_uris: | ||
765 | return 'patch' | ||
766 | # Just use the first URI for now | ||
767 | uri = git_uris[0] | ||
768 | # Check remote branch | ||
769 | upstr_branch = 'master' | ||
770 | for paramdef in uri.split(';')[1:]: | ||
771 | name, value = paramdef.split('=', 1) | ||
772 | if name == 'branch': | ||
773 | upstr_branch = value | ||
774 | # Check if current branch HEAD is found in upstream branch | ||
775 | stdout, _ = bb.process.run('git rev-parse HEAD', cwd=srctree) | ||
776 | head_rev = stdout.rstrip() | ||
777 | stdout, _ = bb.process.run('git branch -r --contains %s' % head_rev, | ||
778 | cwd=srctree) | ||
779 | remote_brs = [branch.strip() for branch in stdout.splitlines()] | ||
780 | if 'origin/' + upstr_branch in remote_brs: | ||
781 | return 'srcrev' | ||
782 | |||
783 | return 'patch' | ||
784 | |||
760 | def update_recipe(args, config, basepath, workspace): | 785 | def update_recipe(args, config, basepath, workspace): |
761 | """Entry point for the devtool 'update-recipe' subcommand""" | 786 | """Entry point for the devtool 'update-recipe' subcommand""" |
762 | if not args.recipename in workspace: | 787 | if not args.recipename in workspace: |
@@ -777,17 +802,12 @@ def update_recipe(args, config, basepath, workspace): | |||
777 | if not rd: | 802 | if not rd: |
778 | return 1 | 803 | return 1 |
779 | 804 | ||
780 | orig_src_uri = rd.getVar('SRC_URI', False) or '' | 805 | srctree = workspace[args.recipename]['srctree'] |
781 | if args.mode == 'auto': | 806 | if args.mode == 'auto': |
782 | if 'git://' in orig_src_uri: | 807 | mode = _guess_recipe_update_mode(srctree, rd) |
783 | mode = 'srcrev' | ||
784 | else: | ||
785 | mode = 'patch' | ||
786 | else: | 808 | else: |
787 | mode = args.mode | 809 | mode = args.mode |
788 | 810 | ||
789 | srctree = workspace[args.recipename]['srctree'] | ||
790 | |||
791 | if mode == 'srcrev': | 811 | if mode == 'srcrev': |
792 | _update_recipe_srcrev(args, srctree, rd, tinfoil.config_data) | 812 | _update_recipe_srcrev(args, srctree, rd, tinfoil.config_data) |
793 | elif mode == 'patch': | 813 | elif mode == 'patch': |