From 47634cab962105f07a90175a87cb3aa1d5789852 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Mon, 20 Jan 2014 12:03:20 +0100 Subject: [PATCH] bitbake: fetch2.URI: Coerce urlparse to use netloc for all schemes (Bitbake rev: 4d502578f022bcf772780550c047b8c09ba01443) Signed-off-by: Olof Johansson Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index f1f2ee6..5c6180b 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -33,9 +33,6 @@ import glob import logging import urllib import urlparse -if 'git' not in urlparse.uses_netloc: - urlparse.uses_netloc.append('git') -from urlparse import urlparse import operator import bb.persist_data, bb.utils import bb.checksum @@ -209,13 +206,25 @@ class URI(object): if not uri: return - urlp = urlparse(uri) + urlp = urlparse.urlparse(uri) self.scheme = urlp.scheme - # Convert URI to be relative + reparse = 0 + + # Coerce urlparse to make URI scheme use netloc + if not self.scheme in urlparse.uses_netloc: + urlparse.uses_params.append(self.scheme) + reparse = 1 + + # Make urlparse happy(/ier) by converting local resources + # to RFC compliant URL format. E.g.: + # file://foo.diff -> file:foo.diff if urlp.scheme in self._netloc_forbidden: uri = re.sub("(?<=:)//(?!/)", "", uri, 1) - urlp = urlparse(uri) + reparse = 1 + + if reparse: + urlp = urlparse.urlparse(uri) # Identify if the URI is relative or not if urlp.scheme in self._relative_schemes and \ -- 2.7.4