summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorStanley Cheong Kwan, Phoong <stanley.cheong.kwan.phoong@intel.com>2017-07-12 17:25:45 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-27 22:36:45 +0100
commit0ffe27ffef5d58be47a0affea8a7cda67f8d0f92 (patch)
tree2461f5e7bf10fc10d6fd7a74c6a45ec7138b8f4f /scripts
parent182e0a290d647bf51ea44b2741eaf4f812d95ad1 (diff)
downloadpoky-0ffe27ffef5d58be47a0affea8a7cda67f8d0f92.tar.gz
recipetool: git reformat URI mangling & parameter stripped
recipetool seems to be mangling and stripping out the parameters for git URI. This will fix this issue as well as resolve the conflict of protocol parameter added by user. If a user adds their own protocol as an argument, it'll be honored. [YOCTO #11390] [YOCTO #11391] (From OE-Core rev: e3c832e49a9596537198a46075ed3d6794639953) Signed-off-by: Stanley Cheong Kwan, Phoong <stanley.cheong.kwan.phoong@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> (cherry picked from commit 0cd2fc8ca278ebaa76de95545eef26a07b350c8e) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/recipetool/create.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 5af58a12f7..4de52fc30f 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -26,7 +26,7 @@ import logging
26import scriptutils 26import scriptutils
27from urllib.parse import urlparse, urldefrag, urlsplit 27from urllib.parse import urlparse, urldefrag, urlsplit
28import hashlib 28import hashlib
29 29import bb.fetch2
30logger = logging.getLogger('recipetool') 30logger = logging.getLogger('recipetool')
31 31
32tinfoil = None 32tinfoil = None
@@ -368,14 +368,31 @@ def reformat_git_uri(uri):
368 '''Convert any http[s]://....git URI into git://...;protocol=http[s]''' 368 '''Convert any http[s]://....git URI into git://...;protocol=http[s]'''
369 checkuri = uri.split(';', 1)[0] 369 checkuri = uri.split(';', 1)[0]
370 if checkuri.endswith('.git') or '/git/' in checkuri or re.match('https?://github.com/[^/]+/[^/]+/?$', checkuri): 370 if checkuri.endswith('.git') or '/git/' in checkuri or re.match('https?://github.com/[^/]+/[^/]+/?$', checkuri):
371 res = re.match('(http|https|ssh)://([^;]+(\.git)?)(;.*)?$', uri) 371 # Appends scheme if the scheme is missing
372 if res: 372 if not '://' in uri:
373 # Need to switch the URI around so that the git fetcher is used 373 uri = 'git://' + uri
374 return 'git://%s;protocol=%s%s' % (res.group(2), res.group(1), res.group(4) or '') 374 scheme, host, path, user, pswd, parms = bb.fetch2.decodeurl(uri)
375 elif '@' in checkuri: 375 # Detection mechanism, this is required due to certain URL are formatter with ":" rather than "/"
376 # Catch e.g. git@git.example.com:repo.git 376 # which causes decodeurl to fail getting the right host and path
377 return 'git://%s;protocol=ssh' % checkuri.replace(':', '/', 1) 377 if len(host.split(':')) > 1:
378 return uri 378 splitslash = host.split(':')
379 host = splitslash[0]
380 path = '/' + splitslash[1] + path
381 #Algorithm:
382 # if user is defined, append protocol=ssh or if a protocol is defined, then honor the user-defined protocol
383 # if no user & password is defined, check for scheme type and append the protocol with the scheme type
384 # finally if protocols or if the url is well-formed, do nothing and rejoin everything back to normal
385 # Need to repackage the arguments for encodeurl, the format is: (scheme, host, path, user, password, OrderedDict([('key', 'value')]))
386 if user:
387 if not 'protocol' in parms:
388 parms.update({('protocol', 'ssh')})
389 elif (scheme == "http" or scheme == 'https' or scheme == 'ssh') and not ('protocol' in parms):
390 parms.update({('protocol', scheme)})
391 # Always append 'git://'
392 fUrl = bb.fetch2.encodeurl(('git', host, path, user, pswd, parms))
393 return fUrl
394 else:
395 return uri
379 396
380def is_package(url): 397def is_package(url):
381 '''Check if a URL points to a package''' 398 '''Check if a URL points to a package'''