public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/
Date: Mon, 14 Feb 2011 04:02:18 +0000 (UTC)	[thread overview]
Message-ID: <53f096c5d72dd15336fdf921f29ceae9b5842148.zmedico@gentoo> (raw)

commit:     53f096c5d72dd15336fdf921f29ceae9b5842148
Author:     David James <davidjames <AT> google <DOT> com>
AuthorDate: Fri Feb 11 17:25:26 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 14 03:51:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=53f096c5

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

---
 pym/portage/dbapi/bintree.py |   16 ++++++++++++++--
 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 993df77..78eb429 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 f85b65c..43a6bf5 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



             reply	other threads:[~2011-02-14  4:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-14  4:02 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-03-27 20:57 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/ Zac Medico
2011-05-05 15:13 Zac Medico
2011-09-06 18:35 Zac Medico
2011-10-16 21:13 Zac Medico
2014-08-03 21:53 Pavel Kazakov
2014-08-04 21:41 Arfrever Frehtes Taifersar Arahesis
2014-08-19  7:01 Michał Górny
2014-08-19  7:01 Michał Górny
2016-12-28  0:01 Zac Medico
2018-05-17 18:40 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53f096c5d72dd15336fdf921f29ceae9b5842148.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox