summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
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 2a5a84c3c7..8e63580db7 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
@@ -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
385def is_package(url): 402def is_package(url):
386 '''Check if a URL points to a package''' 403 '''Check if a URL points to a package'''