summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-09-22 17:21:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-23 09:53:17 +0100
commit3bd0f335058208ce29caffd25391fb023c2d719f (patch)
tree82366931a022f7923692f33a97e205a2346b5c0a /scripts
parente759b0b75db25d0b5f43e9c6e488a6be17fbe332 (diff)
downloadpoky-3bd0f335058208ce29caffd25391fb023c2d719f.tar.gz
devtool: add: set up fetched source as a git repository by default
If the fetched source isn't already a git repository, initialise it as one and then branch and tag, just as we do with "devtool modify". This makes it easier to make changes, commit them and then use the "devtool update-recipe" command to turn those commits into patches on the recipe. (From OE-Core rev: 2dd865086c37c9eff63c6d0bbfa9f2e909f9fffe) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/__init__.py17
-rw-r--r--scripts/lib/devtool/standard.py13
2 files changed, 23 insertions, 7 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index 07a3636e9b..f815ef27fa 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -170,3 +170,20 @@ def use_external_build(same_dir, no_same_dir, d):
170 else: 170 else:
171 b_is_s = False 171 b_is_s = False
172 return b_is_s 172 return b_is_s
173
174def setup_git_repo(repodir, version, devbranch, basetag='devtool-base'):
175 """
176 Set up the git repository for the source tree
177 """
178 import bb.process
179 if not os.path.exists(os.path.join(repodir, '.git')):
180 bb.process.run('git init', cwd=repodir)
181 bb.process.run('git add .', cwd=repodir)
182 if version:
183 commitmsg = "Initial commit from upstream at version %s" % version
184 else:
185 commitmsg = "Initial commit from upstream"
186 bb.process.run('git commit -q -m "%s"' % commitmsg, cwd=repodir)
187
188 bb.process.run('git checkout -b %s' % devbranch, cwd=repodir)
189 bb.process.run('git tag -f %s' % basetag, cwd=repodir)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ff79c05e39..4a05c1d2e0 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -25,7 +25,7 @@ import logging
25import argparse 25import argparse
26import scriptutils 26import scriptutils
27import errno 27import errno
28from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, DevtoolError 28from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, setup_git_repo, DevtoolError
29from devtool import parse_recipe 29from devtool import parse_recipe
30 30
31logger = logging.getLogger('devtool') 31logger = logging.getLogger('devtool')
@@ -102,6 +102,9 @@ def add(args, config, basepath, workspace):
102 102
103 _add_md5(config, args.recipename, recipefile) 103 _add_md5(config, args.recipename, recipefile)
104 104
105 if args.fetch and not args.no_git:
106 setup_git_repo(srctree, args.version, 'devtool')
107
105 initial_rev = None 108 initial_rev = None
106 if os.path.exists(os.path.join(srctree, '.git')): 109 if os.path.exists(os.path.join(srctree, '.git')):
107 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree) 110 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
@@ -340,16 +343,11 @@ def _extract_source(srctree, keep_temp, devbranch, d):
340 "correct source directory could not be " 343 "correct source directory could not be "
341 "determined" % pn) 344 "determined" % pn)
342 345
343 if not os.path.exists(os.path.join(srcsubdir, '.git')): 346 setup_git_repo(srcsubdir, crd.getVar('PV', True), devbranch)
344 bb.process.run('git init', cwd=srcsubdir)
345 bb.process.run('git add .', cwd=srcsubdir)
346 bb.process.run('git commit -q -m "Initial commit from upstream at version %s"' % crd.getVar('PV', True), cwd=srcsubdir)
347 347
348 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srcsubdir) 348 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srcsubdir)
349 initial_rev = stdout.rstrip() 349 initial_rev = stdout.rstrip()
350 350
351 bb.process.run('git checkout -b %s' % devbranch, cwd=srcsubdir)
352 bb.process.run('git tag -f devtool-base', cwd=srcsubdir)
353 crd.setVar('PATCHTOOL', 'git') 351 crd.setVar('PATCHTOOL', 'git')
354 352
355 logger.info('Patching...') 353 logger.info('Patching...')
@@ -885,6 +883,7 @@ def register_commands(subparsers, context):
885 group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") 883 group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true")
886 parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree', metavar='URI') 884 parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree', metavar='URI')
887 parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)') 885 parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
886 parser_add.add_argument('--no-git', '-g', help='If -f/--fetch is specified, do not set up source tree as a git repository', action="store_true")
888 parser_add.set_defaults(func=add) 887 parser_add.set_defaults(func=add)
889 888
890 parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe', 889 parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe',