diff options
author | Stanley Cheong Kwan, Phoong <stanley.cheong.kwan.phoong@intel.com> | 2017-07-12 17:25:45 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-17 14:01:38 +0100 |
commit | 0df60c7de2e4a3ccbab28e338ee54a12c3008089 (patch) | |
tree | ba77fd7275a6786c18487fbd2755d47f20bbbe6e /scripts | |
parent | 3ece2ff4df7a5070f5cc45165285adf2a86153e6 (diff) | |
download | poky-0df60c7de2e4a3ccbab28e338ee54a12c3008089.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: 0cd2fc8ca278ebaa76de95545eef26a07b350c8e)
Signed-off-by: Stanley Cheong Kwan, Phoong <stanley.cheong.kwan.phoong@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/recipetool/create.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 2a5a84c3c7..8e63580db7 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -26,7 +26,7 @@ import logging | |||
26 | import scriptutils | 26 | import scriptutils |
27 | from urllib.parse import urlparse, urldefrag, urlsplit | 27 | from urllib.parse import urlparse, urldefrag, urlsplit |
28 | import hashlib | 28 | import hashlib |
29 | 29 | import bb.fetch2 | |
30 | logger = logging.getLogger('recipetool') | 30 | logger = logging.getLogger('recipetool') |
31 | 31 | ||
32 | tinfoil = None | 32 | tinfoil = None |
@@ -373,14 +373,31 @@ def reformat_git_uri(uri): | |||
373 | '''Convert any http[s]://....git URI into git://...;protocol=http[s]''' | 373 | '''Convert any http[s]://....git URI into git://...;protocol=http[s]''' |
374 | checkuri = uri.split(';', 1)[0] | 374 | checkuri = uri.split(';', 1)[0] |
375 | if checkuri.endswith('.git') or '/git/' in checkuri or re.match('https?://github.com/[^/]+/[^/]+/?$', checkuri): | 375 | if checkuri.endswith('.git') or '/git/' in checkuri or re.match('https?://github.com/[^/]+/[^/]+/?$', checkuri): |
376 | res = re.match('(http|https|ssh)://([^;]+(\.git)?)(;.*)?$', uri) | 376 | # Appends scheme if the scheme is missing |
377 | if res: | 377 | if not '://' in uri: |
378 | # Need to switch the URI around so that the git fetcher is used | 378 | uri = 'git://' + uri |
379 | return 'git://%s;protocol=%s%s' % (res.group(2), res.group(1), res.group(4) or '') | 379 | scheme, host, path, user, pswd, parms = bb.fetch2.decodeurl(uri) |
380 | elif '@' in checkuri: | 380 | # Detection mechanism, this is required due to certain URL are formatter with ":" rather than "/" |
381 | # Catch e.g. git@git.example.com:repo.git | 381 | # which causes decodeurl to fail getting the right host and path |
382 | return 'git://%s;protocol=ssh' % checkuri.replace(':', '/', 1) | 382 | if len(host.split(':')) > 1: |
383 | return uri | 383 | splitslash = host.split(':') |
384 | host = splitslash[0] | ||
385 | path = '/' + splitslash[1] + path | ||
386 | #Algorithm: | ||
387 | # if user is defined, append protocol=ssh or if a protocol is defined, then honor the user-defined protocol | ||
388 | # if no user & password is defined, check for scheme type and append the protocol with the scheme type | ||
389 | # finally if protocols or if the url is well-formed, do nothing and rejoin everything back to normal | ||
390 | # Need to repackage the arguments for encodeurl, the format is: (scheme, host, path, user, password, OrderedDict([('key', 'value')])) | ||
391 | if user: | ||
392 | if not 'protocol' in parms: | ||
393 | parms.update({('protocol', 'ssh')}) | ||
394 | elif (scheme == "http" or scheme == 'https' or scheme == 'ssh') and not ('protocol' in parms): | ||
395 | parms.update({('protocol', scheme)}) | ||
396 | # Always append 'git://' | ||
397 | fUrl = bb.fetch2.encodeurl(('git', host, path, user, pswd, parms)) | ||
398 | return fUrl | ||
399 | else: | ||
400 | return uri | ||
384 | 401 | ||
385 | def is_package(url): | 402 | def is_package(url): |
386 | '''Check if a URL points to a package''' | 403 | '''Check if a URL points to a package''' |