diff options
-rw-r--r-- | pym/portage/dbapi/bintree.py | 16 | ||||
-rw-r--r-- | pym/portage/getbinpkg.py | 6 |
2 files changed, 18 insertions, 4 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 993df7714..78eb42999 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -770,8 +770,9 @@ class binarytree(object): # urlparse.urljoin() only works correctly with recognized # protocols and requires the base url to have a trailing # slash, so join manually... + url = base_url.rstrip("/") + "/Packages" try: - f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages") + f = urllib_request_urlopen(url) except IOError: path = parsed_url.path.rstrip("/") + "/Packages" @@ -796,7 +797,18 @@ class binarytree(object): stdout=subprocess.PIPE) f = proc.stdout else: - raise + setting = 'FETCHCOMMAND_' + parsed_url.scheme.upper() + fcmd = self.settings.get(setting) + if not fcmd: + raise + fd, tmp_filename = tempfile.mkstemp() + tmp_dirname, tmp_basename = os.path.split(tmp_filename) + os.close(fd) + success = portage.getbinpkg.file_get(url, + tmp_dirname, fcmd=fcmd, filename=tmp_basename) + if not success: + raise portage.exception.FileNotFound(url) + f = open(tmp_filename, 'rb') f_dec = codecs.iterdecode(f, _encodings['repo.content'], errors='replace') diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index f85b65c00..43a6bf5f7 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -431,17 +431,19 @@ def file_get_metadata(baseurl,conn=None, chunk_size=3000): return myid -def file_get(baseurl,dest,conn=None,fcmd=None): +def file_get(baseurl,dest,conn=None,fcmd=None,filename=None): """(baseurl,dest,fcmd=) -- Takes a base url to connect to and read from. URI should be in the form <proto>://[user[:pass]@]<site>[:port]<path>""" if not fcmd: return file_get_lib(baseurl,dest,conn) + if not filename: + filename = os.path.basename(baseurl) variables = { "DISTDIR": dest, "URI": baseurl, - "FILE": os.path.basename(baseurl) + "FILE": filename } from portage.util import varexpand |