PORTAGE_BINHOST: sftp with FETCHCOMMAND_SFTP
authorZac Medico <zmedico@gentoo.org>
Fri, 17 May 2013 02:06:41 +0000 (19:06 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 17 May 2013 02:06:41 +0000 (19:06 -0700)
Do not generate the sftp command for downloading the Packages file, and
simply use the FETCHCOMMAND_SFTP setting.

pym/portage/dbapi/bintree.py

index 7f2d01765faae89bcf55df094d4494ff52ff1d40..14d05ad489e121a0127491679bb32e9ad891f084 100644 (file)
@@ -911,20 +911,10 @@ class binarytree(object):
 
                                        path = parsed_url.path.rstrip("/") + "/Packages"
 
-                                       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)
-                                               if port is not None:
-                                                       port_args = ['-P', "%s" % (port,)]
-                                               proc = subprocess.Popen(['sftp'] + port_args + \
-                                                       [user_passwd + host + ":" + path, tmp_filename])
-                                               if proc.wait() != os.EX_OK:
-                                                       raise EnvironmentError("sftp failed")
-                                               f = open(tmp_filename, 'rb')
-                                       elif parsed_url.scheme == 'ssh':
+                                       if parsed_url.scheme == 'ssh':
+                                               # Use a pipe so that we can terminate the download
+                                               # early if we detect that the TIMESTAMP header
+                                               # matches that of the cached Packages file.
                                                if port is not None:
                                                        port_args = ['-p', "%s" % (port,)]
                                                proc = subprocess.Popen(['ssh'] + port_args + \