diff options
Diffstat (limited to 'scripts/lib/devtool')
-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': |