diff options
| -rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 7 | ||||
| -rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 42 |
2 files changed, 45 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 914553aaf7..5f0e6c9266 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
| @@ -327,7 +327,7 @@ class URI(object): | |||
| 327 | def path(self, path): | 327 | def path(self, path): |
| 328 | self._path = path | 328 | self._path = path |
| 329 | 329 | ||
| 330 | if re.compile("^/").match(path): | 330 | if not path or re.compile("^/").match(path): |
| 331 | self.relative = False | 331 | self.relative = False |
| 332 | else: | 332 | else: |
| 333 | self.relative = True | 333 | self.relative = True |
| @@ -375,9 +375,12 @@ def decodeurl(url): | |||
| 375 | if locidx != -1 and type.lower() != 'file': | 375 | if locidx != -1 and type.lower() != 'file': |
| 376 | host = location[:locidx] | 376 | host = location[:locidx] |
| 377 | path = location[locidx:] | 377 | path = location[locidx:] |
| 378 | else: | 378 | elif type.lower() == 'file': |
| 379 | host = "" | 379 | host = "" |
| 380 | path = location | 380 | path = location |
| 381 | else: | ||
| 382 | host = location | ||
| 383 | path = "" | ||
| 381 | if user: | 384 | if user: |
| 382 | m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user) | 385 | m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user) |
| 383 | if m: | 386 | if m: |
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 81b22d025f..d8a36836d6 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
| @@ -228,7 +228,38 @@ class URITest(unittest.TestCase): | |||
| 228 | 'params': {}, | 228 | 'params': {}, |
| 229 | 'query': {}, | 229 | 'query': {}, |
| 230 | 'relative': False | 230 | 'relative': False |
| 231 | }, | ||
| 232 | "http://somesite.net;someparam=1": { | ||
| 233 | 'uri': 'http://somesite.net;someparam=1', | ||
| 234 | 'scheme': 'http', | ||
| 235 | 'hostname': 'somesite.net', | ||
| 236 | 'port': None, | ||
| 237 | 'hostport': 'somesite.net', | ||
| 238 | 'path': '', | ||
| 239 | 'userinfo': '', | ||
| 240 | 'userinfo': '', | ||
| 241 | 'username': '', | ||
| 242 | 'password': '', | ||
| 243 | 'params': {"someparam" : "1"}, | ||
| 244 | 'query': {}, | ||
| 245 | 'relative': False | ||
| 246 | }, | ||
| 247 | "file://somelocation;someparam=1": { | ||
| 248 | 'uri': 'file:somelocation;someparam=1', | ||
| 249 | 'scheme': 'file', | ||
| 250 | 'hostname': '', | ||
| 251 | 'port': None, | ||
| 252 | 'hostport': '', | ||
| 253 | 'path': 'somelocation', | ||
| 254 | 'userinfo': '', | ||
| 255 | 'userinfo': '', | ||
| 256 | 'username': '', | ||
| 257 | 'password': '', | ||
| 258 | 'params': {"someparam" : "1"}, | ||
| 259 | 'query': {}, | ||
| 260 | 'relative': True | ||
| 231 | } | 261 | } |
| 262 | |||
| 232 | } | 263 | } |
| 233 | 264 | ||
| 234 | def test_uri(self): | 265 | def test_uri(self): |
| @@ -627,11 +658,18 @@ class URLHandle(unittest.TestCase): | |||
| 627 | "http://www.google.com/index.html" : ('http', 'www.google.com', '/index.html', '', '', {}), | 658 | "http://www.google.com/index.html" : ('http', 'www.google.com', '/index.html', '', '', {}), |
| 628 | "cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg" : ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'}), | 659 | "cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg" : ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'}), |
| 629 | "cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg" : ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'}), | 660 | "cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg" : ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'}), |
| 630 | "git://git.openembedded.org/bitbake;branch=@foo" : ('git', 'git.openembedded.org', '/bitbake', '', '', {'branch': '@foo'}) | 661 | "git://git.openembedded.org/bitbake;branch=@foo" : ('git', 'git.openembedded.org', '/bitbake', '', '', {'branch': '@foo'}), |
| 662 | "file://somelocation;someparam=1": ('file', '', 'somelocation', '', '', {'someparam': '1'}), | ||
| 631 | } | 663 | } |
| 664 | # we require a pathname to encodeurl but users can still pass such urls to | ||
| 665 | # decodeurl and we need to handle them | ||
| 666 | decodedata = datatable.copy() | ||
| 667 | decodedata.update({ | ||
| 668 | "http://somesite.net;someparam=1": ('http', 'somesite.net', '', '', '', {'someparam': '1'}), | ||
| 669 | }) | ||
| 632 | 670 | ||
| 633 | def test_decodeurl(self): | 671 | def test_decodeurl(self): |
| 634 | for k, v in self.datatable.items(): | 672 | for k, v in self.decodedata.items(): |
| 635 | result = bb.fetch.decodeurl(k) | 673 | result = bb.fetch.decodeurl(k) |
| 636 | self.assertEqual(result, v) | 674 | self.assertEqual(result, v) |
| 637 | 675 | ||
