summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/bintree.py
diff options
context:
space:
mode:
authorDavid James <davidjames@google.com>2011-02-11 09:25:26 -0800
committerZac Medico <zmedico@gentoo.org>2011-02-13 19:51:39 -0800
commit53f096c5d72dd15336fdf921f29ceae9b5842148 (patch)
treefcf3c3848afa378f4968e2094d672cf5daee3b16 /pym/portage/dbapi/bintree.py
parentb4f98ec5a1eb2e010a455b19db5bef8d61def241 (diff)
downloadportage-53f096c5d72dd15336fdf921f29ceae9b5842148.tar.gz
portage-53f096c5d72dd15336fdf921f29ceae9b5842148.tar.bz2
portage-53f096c5d72dd15336fdf921f29ceae9b5842148.zip
Add support for grabbing Packages files using external programs.
If the user specifies FETCHCOMMAND_*, Portage should honor this when grabbing Packages files. This allows users to setup support for grabbing Packages files from other protocols. BUG=chrome-os-partner:2026 TEST=Try downloading prebuilts from gs:// when FETCHCOMMAND_GS is setup in make.conf Change-Id: I96b239819351633dd02d608954e81a1c363a4687 Review URL: http://codereview.chromium.org/6458015
Diffstat (limited to 'pym/portage/dbapi/bintree.py')
-rw-r--r--pym/portage/dbapi/bintree.py16
1 files changed, 14 insertions, 2 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')