OLD | NEW |
1 # Copyright 1998-2010 Gentoo Foundation | 1 # Copyright 1998-2010 Gentoo Foundation |
2 # Distributed under the terms of the GNU General Public License v2 | 2 # Distributed under the terms of the GNU General Public License v2 |
3 | 3 |
4 __all__ = ["bindbapi", "binarytree"] | 4 __all__ = ["bindbapi", "binarytree"] |
5 | 5 |
6 import portage | 6 import portage |
7 portage.proxy.lazyimport.lazyimport(globals(), | 7 portage.proxy.lazyimport.lazyimport(globals(), |
8 'portage.checksum:hashfunc_map,perform_multiple_checksums,verify_all', | 8 'portage.checksum:hashfunc_map,perform_multiple_checksums,verify_all', |
9 'portage.dbapi.dep_expand:dep_expand', | 9 'portage.dbapi.dep_expand:dep_expand', |
10 'portage.dep:dep_getkey,isjustname,match_from_list', | 10 'portage.dep:dep_getkey,isjustname,match_from_list', |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 if e.errno != errno.ENOENT: | 765 if e.errno != errno.ENOENT: |
766 raise | 766 raise |
767 local_timestamp = pkgindex.header.get("TIMESTAMP", None) | 767 local_timestamp = pkgindex.header.get("TIMESTAMP", None) |
768 rmt_idx = self._new_pkgindex() | 768 rmt_idx = self._new_pkgindex() |
769 proc = None | 769 proc = None |
770 tmp_filename = None | 770 tmp_filename = None |
771 try: | 771 try: |
772 # urlparse.urljoin() only works correctly with r
ecognized | 772 # urlparse.urljoin() only works correctly with r
ecognized |
773 # protocols and requires the base url to have a
trailing | 773 # protocols and requires the base url to have a
trailing |
774 # slash, so join manually... | 774 # slash, so join manually... |
| 775 url = base_url.rstrip("/") + "/Packages" |
775 try: | 776 try: |
776 » » » » » f = urllib_request_urlopen(base_url.rstr
ip("/") + "/Packages") | 777 » » » » » f = urllib_request_urlopen(url) |
777 except IOError: | 778 except IOError: |
778 path = parsed_url.path.rstrip("/") + "/P
ackages" | 779 path = parsed_url.path.rstrip("/") + "/P
ackages" |
779 | 780 |
780 if parsed_url.scheme == 'sftp': | 781 if parsed_url.scheme == 'sftp': |
781 # The sftp command complains abo
ut 'Illegal seek' if | 782 # The sftp command complains abo
ut 'Illegal seek' if |
782 # we try to make it write to /de
v/stdout, so use a | 783 # we try to make it write to /de
v/stdout, so use a |
783 # temp file instead. | 784 # temp file instead. |
784 fd, tmp_filename = tempfile.mkst
emp() | 785 fd, tmp_filename = tempfile.mkst
emp() |
785 os.close(fd) | 786 os.close(fd) |
786 if port is not None: | 787 if port is not None: |
787 port_args = ['-P', "%s"
% (port,)] | 788 port_args = ['-P', "%s"
% (port,)] |
788 proc = subprocess.Popen(['sftp']
+ port_args + \ | 789 proc = subprocess.Popen(['sftp']
+ port_args + \ |
789 [user_passwd + host + ":
" + path, tmp_filename]) | 790 [user_passwd + host + ":
" + path, tmp_filename]) |
790 if proc.wait() != os.EX_OK: | 791 if proc.wait() != os.EX_OK: |
791 raise | 792 raise |
792 f = open(tmp_filename, 'rb') | 793 f = open(tmp_filename, 'rb') |
793 elif parsed_url.scheme == 'ssh': | 794 elif parsed_url.scheme == 'ssh': |
794 if port is not None: | 795 if port is not None: |
795 port_args = ['-p', "%s"
% (port,)] | 796 port_args = ['-p', "%s"
% (port,)] |
796 proc = subprocess.Popen(['ssh']
+ port_args + \ | 797 proc = subprocess.Popen(['ssh']
+ port_args + \ |
797 [user_passwd + host, '--
', 'cat', path], | 798 [user_passwd + host, '--
', 'cat', path], |
798 stdout=subprocess.PIPE) | 799 stdout=subprocess.PIPE) |
799 f = proc.stdout | 800 f = proc.stdout |
800 else: | 801 else: |
801 » » » » » » raise | 802 » » » » » » setting = 'FETCHCOMMAND_' + pars
ed_url.scheme.upper() |
| 803 » » » » » » fcmd = self.settings.get(setting
) |
| 804 » » » » » » if not fcmd: |
| 805 » » » » » » » raise |
| 806 » » » » » » fd, tmp_filename = tempfile.mkst
emp() |
| 807 » » » » » » tmp_dirname, tmp_basename = os.p
ath.split(tmp_filename) |
| 808 » » » » » » os.close(fd) |
| 809 » » » » » » success = portage.getbinpkg.file
_get(url, |
| 810 » » » » » » tmp_dirname, fcmd=fcmd, fil
ename=tmp_basename) |
| 811 » » » » » » if not success: |
| 812 » » » » » » » raise portage.exception.
FileNotFound(url) |
| 813 » » » » » » f = open(tmp_filename, 'rb') |
802 | 814 |
803 f_dec = codecs.iterdecode(f, | 815 f_dec = codecs.iterdecode(f, |
804 _encodings['repo.content'], errors='repl
ace') | 816 _encodings['repo.content'], errors='repl
ace') |
805 try: | 817 try: |
806 rmt_idx.readHeader(f_dec) | 818 rmt_idx.readHeader(f_dec) |
807 remote_timestamp = rmt_idx.header.get("T
IMESTAMP", None) | 819 remote_timestamp = rmt_idx.header.get("T
IMESTAMP", None) |
808 if not remote_timestamp: | 820 if not remote_timestamp: |
809 # no timestamp in the header, so
mething's wrong | 821 # no timestamp in the header, so
mething's wrong |
810 pkgindex = None | 822 pkgindex = None |
811 else: | 823 else: |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 def getslot(self, mycatpkg): | 1341 def getslot(self, mycatpkg): |
1330 "Get a slot for a catpkg; assume it exists." | 1342 "Get a slot for a catpkg; assume it exists." |
1331 myslot = "" | 1343 myslot = "" |
1332 try: | 1344 try: |
1333 myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0] | 1345 myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0] |
1334 except SystemExit as e: | 1346 except SystemExit as e: |
1335 raise | 1347 raise |
1336 except Exception as e: | 1348 except Exception as e: |
1337 pass | 1349 pass |
1338 return myslot | 1350 return myslot |
OLD | NEW |