summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-08-31 11:54:11 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-31 23:30:02 +0100
commite97cd0017bcbaa9ccb065ba5af9ed437d45db079 (patch)
treefa0b2dd6ca0f4de00e051a7073fb42a0886a576e /scripts/lib
parent3be475019f5a707e1d899de1384c6e7b84836e28 (diff)
downloadpoky-e97cd0017bcbaa9ccb065ba5af9ed437d45db079.tar.gz
devtool: add: add explicit srcrev/branch options
At the moment when fetching source from a git repository you have to know that you can specify the revision and branch in the URL with ';rev=' and ';branch=' respectively, and you can also get thrown off by the shell splitting on the ; character if you forget to surround the URL in quotes. Add explicit -S/--srcrev and -B/--srcbranch options (consistent with devtool upgrade) to make this easier for the user to discover and use. (The rev and branch URL parameters will continue to work, however.) (From OE-Core rev: 2d86cac853d6daa496c0315a5cb0662ebf1165b0) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/devtool/standard.py17
-rw-r--r--scripts/lib/recipetool/create.py25
2 files changed, 37 insertions, 5 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index d79ebf1a4e..174cc861e1 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1,6 +1,6 @@
1# Development tool - standard commands plugin 1# Development tool - standard commands plugin
2# 2#
3# Copyright (C) 2014-2016 Intel Corporation 3# Copyright (C) 2014-2017 Intel Corporation
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as 6# it under the terms of the GNU General Public License version 2 as
@@ -66,6 +66,12 @@ def add(args, config, basepath, workspace):
66 elif os.path.isdir(args.recipename): 66 elif os.path.isdir(args.recipename):
67 logger.warn('Ambiguous argument "%s" - assuming you mean it to be the recipe name' % args.recipename) 67 logger.warn('Ambiguous argument "%s" - assuming you mean it to be the recipe name' % args.recipename)
68 68
69 if not args.fetchuri:
70 if args.srcrev:
71 raise DevtoolError('The -S/--srcrev option is only valid when fetching from an SCM repository')
72 if args.srcbranch:
73 raise DevtoolError('The -B/--srcbranch option is only valid when fetching from an SCM repository')
74
69 if args.srctree and os.path.isfile(args.srctree): 75 if args.srctree and os.path.isfile(args.srctree):
70 args.fetchuri = 'file://' + os.path.abspath(args.srctree) 76 args.fetchuri = 'file://' + os.path.abspath(args.srctree)
71 args.srctree = '' 77 args.srctree = ''
@@ -151,6 +157,10 @@ def add(args, config, basepath, workspace):
151 extracmdopts += ' --fetch-dev' 157 extracmdopts += ' --fetch-dev'
152 if args.mirrors: 158 if args.mirrors:
153 extracmdopts += ' --mirrors' 159 extracmdopts += ' --mirrors'
160 if args.srcrev:
161 extracmdopts += ' --srcrev %s' % args.srcrev
162 if args.srcbranch:
163 extracmdopts += ' --srcbranch %s' % args.srcbranch
154 164
155 tempdir = tempfile.mkdtemp(prefix='devtool') 165 tempdir = tempfile.mkdtemp(prefix='devtool')
156 try: 166 try:
@@ -1809,7 +1819,10 @@ def register_commands(subparsers, context):
1809 parser_add.add_argument('--fetch-dev', help='For npm, also fetch devDependencies', action="store_true") 1819 parser_add.add_argument('--fetch-dev', help='For npm, also fetch devDependencies', action="store_true")
1810 parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)') 1820 parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
1811 parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true") 1821 parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true")
1812 parser_add.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true") 1822 group = parser_add.add_mutually_exclusive_group()
1823 group.add_argument('--srcrev', '-S', help='Source revision to fetch if fetching from an SCM such as git (default latest)')
1824 group.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
1825 parser_add.add_argument('--srcbranch', '-B', help='Branch in source repository if fetching from an SCM such as git (default master)')
1813 parser_add.add_argument('--binary', '-b', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure). Useful with binary packages e.g. RPMs.', action='store_true') 1826 parser_add.add_argument('--binary', '-b', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure). Useful with binary packages e.g. RPMs.', action='store_true')
1814 parser_add.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true') 1827 parser_add.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
1815 parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') 1828 parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 26011451dd..834633610a 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -1,6 +1,6 @@
1# Recipe creation tool - create command plugin 1# Recipe creation tool - create command plugin
2# 2#
3# Copyright (C) 2014-2016 Intel Corporation 3# Copyright (C) 2014-2017 Intel Corporation
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as 6# it under the terms of the GNU General Public License version 2 as
@@ -440,14 +440,30 @@ def create_recipe(args):
440 rev_re = re.compile(';rev=([^;]+)') 440 rev_re = re.compile(';rev=([^;]+)')
441 res = rev_re.search(srcuri) 441 res = rev_re.search(srcuri)
442 if res: 442 if res:
443 if args.srcrev:
444 logger.error('rev= parameter and -S/--srcrev option cannot both be specified - use one or the other')
445 sys.exit(1)
446 if args.autorev:
447 logger.error('rev= parameter and -a/--autorev option cannot both be specified - use one or the other')
448 sys.exit(1)
443 srcrev = res.group(1) 449 srcrev = res.group(1)
444 srcuri = rev_re.sub('', srcuri) 450 srcuri = rev_re.sub('', srcuri)
451 elif args.srcrev:
452 srcrev = args.srcrev
445 453
446 # Check whether users provides any branch info in fetchuri. 454 # Check whether users provides any branch info in fetchuri.
447 # If true, we will skip all branch checking process to honor all user's input. 455 # If true, we will skip all branch checking process to honor all user's input.
448 scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(fetchuri) 456 scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(fetchuri)
449 srcbranch = params.get('branch') 457 srcbranch = params.get('branch')
458 if args.srcbranch:
459 if srcbranch:
460 logger.error('branch= parameter and -B/--srcbranch option cannot both be specified - use one or the other')
461 sys.exit(1)
462 srcbranch = args.srcbranch
450 nobranch = params.get('nobranch') 463 nobranch = params.get('nobranch')
464 if nobranch and srcbranch:
465 logger.error('nobranch= cannot be used if you specify a branch')
466 sys.exit(1)
451 tag = params.get('tag') 467 tag = params.get('tag')
452 if not srcbranch and not nobranch and srcrev != '${AUTOREV}': 468 if not srcbranch and not nobranch and srcrev != '${AUTOREV}':
453 # Append nobranch=1 in the following conditions: 469 # Append nobranch=1 in the following conditions:
@@ -523,7 +539,7 @@ def create_recipe(args):
523 else: 539 else:
524 # If get_branch contains more than one objects, then display error and exit. 540 # If get_branch contains more than one objects, then display error and exit.
525 mbrch = '\n ' + '\n '.join(get_branch) 541 mbrch = '\n ' + '\n '.join(get_branch)
526 logger.error('Revision %s was found on multiple branches: %s\nPlease provide the correct branch in the source URL with ;branch=<branch> (and ensure you use quotes around the URL to avoid the shell interpreting the ";")' % (srcrev, mbrch)) 542 logger.error('Revision %s was found on multiple branches: %s\nPlease provide the correct branch with -B/--srcbranch' % (srcrev, mbrch))
527 sys.exit(1) 543 sys.exit(1)
528 544
529 # Since we might have a value in srcbranch, we need to 545 # Since we might have a value in srcbranch, we need to
@@ -1277,7 +1293,10 @@ def register_commands(subparsers):
1277 parser_create.add_argument('-b', '--binary', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure)', action='store_true') 1293 parser_create.add_argument('-b', '--binary', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure)', action='store_true')
1278 parser_create.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true') 1294 parser_create.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
1279 parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') 1295 parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
1280 parser_create.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true") 1296 group = parser_create.add_mutually_exclusive_group()
1297 group.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
1298 group.add_argument('-S', '--srcrev', help='Source revision to fetch if fetching from an SCM such as git (default latest)')
1299 parser_create.add_argument('-B', '--srcbranch', help='Branch in source repository if fetching from an SCM such as git (default master)')
1281 parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') 1300 parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)')
1282 parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies') 1301 parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies')
1283 parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS) 1302 parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)