diff options
author | Stanley Phoong <stanley.cheong.kwan.phoong@intel.com> | 2017-08-21 17:39:42 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-23 08:47:02 +0100 |
commit | fe62cedd4b81ea0537c3cc7c5141c8e492222e7a (patch) | |
tree | 860e847853c79f5af19a8cb7bf6a37ec3f2c89f2 /scripts | |
parent | 62d5035ffca049e1c817b53be3074b2d13a6d2d7 (diff) | |
download | poky-fe62cedd4b81ea0537c3cc7c5141c8e492222e7a.tar.gz |
recipetool: create: handle git URLs specifying only a tag
If a git URL is passed to recipetool create with a tag=, recipetool
should handle it assuming that the tag is valid.
[YOCTO #11393]
(From OE-Core rev: 3afdcbdc9a3e65bc925ec61717784ffec67d529d)
Signed-off-by: Stanley Phoong <stanley.cheong.kwan.phoong@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')
-rw-r--r-- | scripts/lib/recipetool/create.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 8d59e65a8f..e48e418df5 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -423,6 +423,7 @@ def create_recipe(args): | |||
423 | srcsubdir = '' | 423 | srcsubdir = '' |
424 | srcrev = '${AUTOREV}' | 424 | srcrev = '${AUTOREV}' |
425 | srcbranch = '' | 425 | srcbranch = '' |
426 | storeTagName = '' | ||
426 | 427 | ||
427 | if os.path.isfile(source): | 428 | if os.path.isfile(source): |
428 | source = 'file://%s' % os.path.abspath(source) | 429 | source = 'file://%s' % os.path.abspath(source) |
@@ -446,13 +447,21 @@ def create_recipe(args): | |||
446 | scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(fetchuri) | 447 | scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(fetchuri) |
447 | srcbranch = params.get('branch') | 448 | srcbranch = params.get('branch') |
448 | nobranch = params.get('nobranch') | 449 | nobranch = params.get('nobranch') |
450 | tag = params.get('tag') | ||
449 | if not srcbranch and not nobranch and srcrev != '${AUTOREV}': | 451 | if not srcbranch and not nobranch and srcrev != '${AUTOREV}': |
450 | # Append nobranch=1 in the following conditions: | 452 | # Append nobranch=1 in the following conditions: |
451 | # 1. User did not set 'branch=' in srcuri, and | 453 | # 1. User did not set 'branch=' in srcuri, and |
452 | # 2. User did not set 'nobranch=1' in srcuri, and | 454 | # 2. User did not set 'nobranch=1' in srcuri, and |
453 | # 3. Source revision is not '${AUTOREV}' | 455 | # 3. Source revision is not '${AUTOREV}' |
454 | params['nobranch'] = '1' | 456 | params['nobranch'] = '1' |
455 | fetchuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params)) | 457 | if tag: |
458 | # Keep a copy of tag and append nobranch=1 then remove tag from URL. | ||
459 | # Bitbake fetcher unable to fetch when {AUTOREV} and tag is set at the same time. | ||
460 | # We will re-introduce tag argument after bitbake fetcher process is complete. | ||
461 | storeTagName = params['tag'] | ||
462 | params['nobranch'] = '1' | ||
463 | del params['tag'] | ||
464 | fetchuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params)) | ||
456 | 465 | ||
457 | tmpparent = tinfoil.config_data.getVar('BASE_WORKDIR') | 466 | tmpparent = tinfoil.config_data.getVar('BASE_WORKDIR') |
458 | bb.utils.mkdirhier(tmpparent) | 467 | bb.utils.mkdirhier(tmpparent) |
@@ -523,6 +532,18 @@ def create_recipe(args): | |||
523 | params['branch'] = srcbranch | 532 | params['branch'] = srcbranch |
524 | srcuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params)) | 533 | srcuri = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params)) |
525 | 534 | ||
535 | if storeTagName: | ||
536 | # Re-introduced tag variable from storeTagName | ||
537 | # Check srcrev using tag and check validity of the tag | ||
538 | cmd = ('git rev-parse --verify %s' % (storeTagName)) | ||
539 | try: | ||
540 | check_tag, check_tag_err = bb.process.run('%s' % cmd, cwd=srctree) | ||
541 | srcrev = check_tag.split()[0] | ||
542 | except bb.process.ExecutionError as err: | ||
543 | logger.error(str(err)) | ||
544 | logger.error("Possibly wrong tag name is provided") | ||
545 | sys.exit(1) | ||
546 | |||
526 | if os.path.exists(os.path.join(srctree, '.gitmodules')) and srcuri.startswith('git://'): | 547 | if os.path.exists(os.path.join(srctree, '.gitmodules')) and srcuri.startswith('git://'): |
527 | srcuri = 'gitsm://' + srcuri[6:] | 548 | srcuri = 'gitsm://' + srcuri[6:] |
528 | logger.info('Fetching submodules...') | 549 | logger.info('Fetching submodules...') |