devtool: modify: default source tree path

As per the changes to "devtool add", make the source tree path optional
and use the default path if none is specified.

(From OE-Core rev: 83707d1334fb094fd1877bcfd07a83866601048a)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton 2015-12-22 17:03:12 +13:00 committed by Richard Purdie
parent 110f4337f2
commit e11673960f
2 changed files with 19 additions and 11 deletions

View File

@ -152,6 +152,10 @@ def _create_workspace(workspacedir, config, basepath):
f.write('\nIf you no longer need to use devtool you can remove the path to this\n')
f.write('workspace layer from your conf/bblayers.conf file (and then delete the\n')
f.write('layer, if you wish).\n')
f.write('\nNote that by default, if devtool fetches and unpacks source code, it\n')
f.write('will place it in a subdirectory of a "sources" subdirectory of the\n')
f.write('layer. If you prefer it to be elsewhere you can specify the source\n')
f.write('tree path on the command line.\n')
def _enable_workspace_layer(workspacedir, config, basepath):
"""Ensure the workspace layer is in bblayers.conf"""

View File

@ -644,10 +644,15 @@ def modify(args, config, basepath, workspace):
raise DevtoolError("recipe %s is already in your workspace" %
args.recipename)
if not args.extract and not os.path.isdir(args.srctree):
if args.srctree:
srctree = os.path.abspath(args.srctree)
else:
srctree = get_default_srctree(config, args.recipename)
if not args.extract and not os.path.isdir(srctree):
raise DevtoolError("directory %s does not exist or not a directory "
"(specify -x to extract source from recipe)" %
args.srctree)
srctree)
if args.extract:
tinfoil = _prep_extract_operation(config, basepath, args.recipename)
if not tinfoil:
@ -679,29 +684,28 @@ def modify(args, config, basepath, workspace):
initial_rev = None
commits = []
srctree = os.path.abspath(args.srctree)
if args.extract:
initial_rev = _extract_source(args.srctree, False, args.branch, False, rd)
initial_rev = _extract_source(srctree, False, args.branch, False, rd)
if not initial_rev:
return 1
logger.info('Source tree extracted to %s' % srctree)
# Get list of commits since this revision
(stdout, _) = bb.process.run('git rev-list --reverse %s..HEAD' % initial_rev, cwd=args.srctree)
(stdout, _) = bb.process.run('git rev-list --reverse %s..HEAD' % initial_rev, cwd=srctree)
commits = stdout.split()
else:
if os.path.exists(os.path.join(args.srctree, '.git')):
if os.path.exists(os.path.join(srctree, '.git')):
# Check if it's a tree previously extracted by us
try:
(stdout, _) = bb.process.run('git branch --contains devtool-base', cwd=args.srctree)
(stdout, _) = bb.process.run('git branch --contains devtool-base', cwd=srctree)
except bb.process.ExecutionError:
stdout = ''
for line in stdout.splitlines():
if line.startswith('*'):
(stdout, _) = bb.process.run('git rev-parse devtool-base', cwd=args.srctree)
(stdout, _) = bb.process.run('git rev-parse devtool-base', cwd=srctree)
initial_rev = stdout.rstrip()
if not initial_rev:
# Otherwise, just grab the head revision
(stdout, _) = bb.process.run('git rev-parse HEAD', cwd=args.srctree)
(stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
initial_rev = stdout.rstrip()
# Check that recipe isn't using a shared workdir
@ -1282,9 +1286,9 @@ def register_commands(subparsers, context):
parser_add.set_defaults(func=add)
parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe',
description='Enables modifying the source for an existing recipe')
description='Enables modifying the source for an existing recipe. You can either provide your own pre-prepared source tree, or specify -x/--extract to extract the source being fetched by the recipe.')
parser_modify.add_argument('recipename', help='Name of existing recipe to edit (just name - no version, path or extension)')
parser_modify.add_argument('srctree', help='Path to external source tree')
parser_modify.add_argument('srctree', nargs='?', help='Path to external source tree. If not specified, a subdirectory of %s will be used.' % defsrctree)
parser_modify.add_argument('--wildcard', '-w', action="store_true", help='Use wildcard for unversioned bbappend')
parser_modify.add_argument('--extract', '-x', action="store_true", help='Extract source as well')
group = parser_modify.add_mutually_exclusive_group()