summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-25 08:53:20 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-25 08:53:20 -0700
commitd9c4a7dec291f3f57296a1bf249887fa950bbcc1 (patch)
tree8bfb62b553d9d5accfbc48c9853613e40dc0b351
parentbb4bf67155698ef3650ebb8bb2713b7d1e41cd40 (diff)
downloadportage-d9c4a7dec291f3f57296a1bf249887fa950bbcc1.tar.gz
portage-d9c4a7dec291f3f57296a1bf249887fa950bbcc1.tar.bz2
portage-d9c4a7dec291f3f57296a1bf249887fa950bbcc1.zip
Implement PORTAGE_BINHOST ssh:// protocol support by spawning ssh
and using it to stream the Packages file on stdout. This assumes that you have ssh-agent running, for authentication. For now, you won't be able to use this unless you define your own FETCHCOMMAND_SSH and RESUMECOMMAND_SSH values. It's trivial to do this if you create a helper script that calls rsync after transforming the URI into the host:/path format that rsync uses.
-rw-r--r--pym/portage/dbapi/bintree.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index d8c40d4ef..f2a7cded9 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -36,6 +36,7 @@ import codecs
import errno
import re
import stat
+import subprocess
import sys
import textwrap
from itertools import chain
@@ -756,11 +757,22 @@ class binarytree(object):
raise
local_timestamp = pkgindex.header.get("TIMESTAMP", None)
rmt_idx = self._new_pkgindex()
+ parsed_url = urlparse(base_url)
+ proc = None
try:
# urlparse.urljoin() only works correctly with recognized
# protocols and requires the base url to have a trailing
# slash, so join manually...
- f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
+ try:
+ f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
+ except IOError:
+ if parsed_url.scheme != 'ssh':
+ raise
+ path = parsed_url.path.rstrip("/") + "/Packages"
+ proc = subprocess.Popen(['ssh', parsed_url.netloc, '--',
+ 'cat', path], stdout=subprocess.PIPE)
+ f = proc.stdout
+
f_dec = codecs.iterdecode(f,
_encodings['repo.content'], errors='replace')
try:
@@ -786,6 +798,11 @@ class binarytree(object):
writemsg("!!! %s\n\n" % str(e))
del e
pkgindex = None
+ if proc is not None:
+ if proc.poll() is None:
+ proc.kill()
+ proc.wait()
+ proc = None
if pkgindex is rmt_idx:
pkgindex.modified = False # don't update the header
try: