diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-19 23:05:11 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-19 23:07:23 -0800 |
commit | 7d22ef28e64de06b6238d0ef9b664c0bee6efa46 (patch) | |
tree | 3bbd32be336c32cc0cf2973c5e0d1bea268d5387 /bitbake | |
parent | 6bf55c6e67b371c0467ae1be4d7f713d6a3dcf3b (diff) | |
download | poky-7d22ef28e64de06b6238d0ef9b664c0bee6efa46.tar.gz |
bitbake: Revert "fetch2: Adapt encode/decode url to use URI class"1.4_M4.rc11.4_M4.final1.4_M4
This reverts commit 21fe2683aefde10e847e66c11c26d4f4c1e07cfd
since bitbake-selftest doesn't pass when this is applied and
we're seeing multiple build failures from this change.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 8118fc2510..4cfe08957d 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -322,9 +322,40 @@ def decodeurl(url): | |||
322 | user, password, parameters). | 322 | user, password, parameters). |
323 | """ | 323 | """ |
324 | 324 | ||
325 | urlo = URI(url) | 325 | m = re.compile('(?P<type>[^:]*)://((?P<user>.+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url) |
326 | return (urlo.scheme, urlo.hostport, urlo.path, | 326 | if not m: |
327 | urlo.username, urlo.password, urlo.params) | 327 | raise MalformedUrl(url) |
328 | |||
329 | type = m.group('type') | ||
330 | location = m.group('location') | ||
331 | if not location: | ||
332 | raise MalformedUrl(url) | ||
333 | user = m.group('user') | ||
334 | parm = m.group('parm') | ||
335 | |||
336 | locidx = location.find('/') | ||
337 | if locidx != -1 and type.lower() != 'file': | ||
338 | host = location[:locidx] | ||
339 | path = location[locidx:] | ||
340 | else: | ||
341 | host = "" | ||
342 | path = location | ||
343 | if user: | ||
344 | m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user) | ||
345 | if m: | ||
346 | user = m.group('user') | ||
347 | pswd = m.group('pswd') | ||
348 | else: | ||
349 | user = '' | ||
350 | pswd = '' | ||
351 | |||
352 | p = {} | ||
353 | if parm: | ||
354 | for s in parm.split(';'): | ||
355 | s1, s2 = s.split('=') | ||
356 | p[s1] = s2 | ||
357 | |||
358 | return type, host, urllib.unquote(path), user, pswd, p | ||
328 | 359 | ||
329 | def encodeurl(decoded): | 360 | def encodeurl(decoded): |
330 | """Encodes a URL from tokens (scheme, network location, path, | 361 | """Encodes a URL from tokens (scheme, network location, path, |
@@ -333,26 +364,27 @@ def encodeurl(decoded): | |||
333 | 364 | ||
334 | type, host, path, user, pswd, p = decoded | 365 | type, host, path, user, pswd, p = decoded |
335 | 366 | ||
336 | urlo = URI() | ||
337 | |||
338 | if not path: | 367 | if not path: |
339 | raise MissingParameterError('path', "encoded from the data %s" % str(decoded)) | 368 | raise MissingParameterError('path', "encoded from the data %s" % str(decoded)) |
340 | if not type: | 369 | if not type: |
341 | raise MissingParameterError('type', "encoded from the data %s" % str(decoded)) | 370 | raise MissingParameterError('type', "encoded from the data %s" % str(decoded)) |
342 | 371 | url = '%s://' % type | |
343 | urlo.scheme = type | 372 | if user and type != "file": |
344 | urlo.path = path | 373 | url += "%s" % user |
345 | 374 | if pswd: | |
346 | if host: | 375 | url += ":%s" % pswd |
347 | urlo.hostname = host | 376 | url += "@" |
348 | if user: | 377 | if host and type != "file": |
349 | urlo.username = user | 378 | url += "%s" % host |
350 | if pswd: | 379 | # Standardise path to ensure comparisons work |
351 | urlo.password = pswd | 380 | while '//' in path: |
381 | path = path.replace("//", "/") | ||
382 | url += "%s" % urllib.quote(path) | ||
352 | if p: | 383 | if p: |
353 | urlo.params = p | 384 | for parm in p: |
385 | url += ";%s=%s" % (parm, p[parm]) | ||
354 | 386 | ||
355 | return str(urlo) | 387 | return url |
356 | 388 | ||
357 | def uri_replace(ud, uri_find, uri_replace, replacements, d): | 389 | def uri_replace(ud, uri_find, uri_replace, replacements, d): |
358 | if not ud.url or not uri_find or not uri_replace: | 390 | if not ud.url or not uri_find or not uri_replace: |