[OE-core] [PATCH] recipetool: create: handle git URLs specifying only a tag
Stanley Phoong
stanley.cheong.kwan.phoong at intel.com
Thu Jul 20 03:26:37 UTC 2017
If a git URL is passed to recipetool create with a tag=, recipetool
should handle it assuming that the tag is valid. Also, during the
creation of recipe, it seems that the automation for replacing
${PV} at the SRCURI for tag, (e.g mbed-tls-${PV}) is causing some
issue due to PV assuming it's a git source. A fix is implemented in
this patch as a workaround for this issue. This fix will be submitted
in a separate patch as a separate issue.
[YOCTO #11393]
Signed-off-by: Stanley Phoong <stanley.cheong.kwan.phoong at intel.com>
---
scripts/lib/recipetool/create.py | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index a45b90d..0619428 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -434,6 +434,18 @@ def create_recipe(args):
# 2. User did not set 'nobranch=1' in srcuri, and
# 3. Source revision is not '${AUTOREV}'
fetchuri = fetchuri + ';nobranch=1'
+ # Create an empty storeTagName to ensure the checkers do not point to a null variable
+ storeTagName = ''
+ tag_re = re.compile(';tag=([^;]+)')
+ tag = tag_re.search(fetchuri)
+ if tag:
+ scheme, host, path, user, pswd, parms = bb.fetch2.decodeurl(fetchuri)
+ # Keep a copy of tag and append nobranch=1 then remove tag from URL,
+ # Will re-introduce tag argument after bitbake fetcher process is complete.
+ storeTagName = parms['tag']
+ parms.update({('nobranch', '1')})
+ del parms['tag']
+ fetchuri = bb.fetch2.encodeurl((scheme, host, path, user, pswd, parms))
tempsrc = tempfile.mkdtemp(prefix='recipetool-')
srctree = tempsrc
d = bb.data.createCopy(tinfoil.config_data)
@@ -488,6 +500,17 @@ def create_recipe(args):
mbrch = '\n ' + '\n '.join(get_branch)
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))
sys.exit(1)
+ if storeTagName:
+ # Re-introduced tag variable from storeTagName
+ # Check srcrev using tag and check validity of the tag
+ try:
+ cmd = ('git rev-list -n 1 %s' % (storeTagName))
+ check_tag, check_tag_err = bb.process.run('%s' % cmd, cwd=srctree)
+ srcrev = check_tag.split()[0]
+ except bb.process.ExecutionError as err:
+ logger.error(str(err))
+ logger.error("Possibly wrong tag name is provided")
+ sys.exit(1)
if os.path.exists(os.path.join(srctree, '.gitmodules')) and srcuri.startswith('git://'):
srcuri = 'gitsm://' + srcuri[6:]
logger.info('Fetching submodules...')
@@ -628,10 +651,12 @@ def create_recipe(args):
lines_before.append('SRC_URI[md5sum] = "%s"' % md5value)
if sha256value:
lines_before.append('SRC_URI[sha256sum] = "%s"' % sha256value)
+ pv_srcpv = False
if srcuri and supports_srcrev(srcuri):
lines_before.append('')
lines_before.append('# Modify these as desired')
lines_before.append('PV = "%s+git${SRCPV}"' % (realpv or '1.0'))
+ pv_srcpv = True
if not args.autorev and srcrev == '${AUTOREV}':
if os.path.exists(os.path.join(srctree, '.git')):
(stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
@@ -758,7 +783,7 @@ def create_recipe(args):
skipblank = True
continue
elif line.startswith('SRC_URI = '):
- if realpv:
+ if realpv and not pv_srcpv:
line = line.replace(realpv, '${PV}')
elif line.startswith('PV = '):
if realpv:
--
2.7.4
More information about the Openembedded-core
mailing list