From d9c4a7dec291f3f57296a1bf249887fa950bbcc1 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 25 Sep 2010 08:53:20 -0700 Subject: 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. --- pym/portage/dbapi/bintree.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'pym') 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: -- cgit v1.2.3-1-g7c22