aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-11-04 18:42:58 -0700
committerZac Medico <zmedico@gentoo.org>2010-11-04 18:42:58 -0700
commit518fba727a978e1bc883d179924f535ed7323b33 (patch)
treebffc6745d8fcb8a559c878452641a3ea9505c713 /pym/portage/dbapi/bintree.py
parentcalc_depclean: use depgraph._pkg() (diff)
downloadportage-518fba727a978e1bc883d179924f535ed7323b33.tar.gz
portage-518fba727a978e1bc883d179924f535ed7323b33.tar.bz2
portage-518fba727a978e1bc883d179924f535ed7323b33.zip
binarytree: handle binhost port for sftp/ssh
Diffstat (limited to 'pym/portage/dbapi/bintree.py')
-rw-r--r--pym/portage/dbapi/bintree.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 03cfdb178..ee3721806 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -769,20 +769,32 @@ class binarytree(object):
f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
except IOError:
path = parsed_url.path.rstrip("/") + "/Packages"
+ host = parsed_url.netloc
+ port = parsed_url.port
+ port_args = []
+ if port is not None:
+ port_str = ":%s" % (port,)
+ if host.endswith(port_str):
+ host = host[:-len(port_str)]
+
if parsed_url.scheme == 'sftp':
# The sftp command complains about 'Illegal seek' if
# we try to make it write to /dev/stdout, so use a
# temp file instead.
fd, tmp_filename = tempfile.mkstemp()
os.close(fd)
- proc = subprocess.Popen(['sftp',
- parsed_url.netloc + ":" + path, tmp_filename])
+ if port is not None:
+ port_args = ['-P', port]
+ proc = subprocess.Popen(['sftp'] + port_args + \
+ [host + ":" + path, tmp_filename])
if proc.wait() != os.EX_OK:
raise
f = open(tmp_filename, 'rb')
elif parsed_url.scheme == 'ssh':
- proc = subprocess.Popen(['ssh', parsed_url.netloc, '--',
- 'cat', path], stdout=subprocess.PIPE)
+ if port is not None:
+ port_args = ['-p', port]
+ proc = subprocess.Popen(['ssh'] + port_args + \
+ [host, '--', 'cat', path], stdout=subprocess.PIPE)
f = proc.stdout
else:
raise