| OLD | NEW |
| 1 # Copyright 1998-2011 Gentoo Foundation | 1 # Copyright 1998-2011 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 self.dbapi = bindbapi(self, settings=settings) | 221 self.dbapi = bindbapi(self, settings=settings) |
| 222 self.update_ents = self.dbapi.update_ents | 222 self.update_ents = self.dbapi.update_ents |
| 223 self.move_slot_ent = self.dbapi.move_slot_ent | 223 self.move_slot_ent = self.dbapi.move_slot_ent |
| 224 self.populated = 0 | 224 self.populated = 0 |
| 225 self.tree = {} | 225 self.tree = {} |
| 226 self._remote_has_index = False | 226 self._remote_has_index = False |
| 227 self._remotepkgs = None # remote metadata indexed by cpv | 227 self._remotepkgs = None # remote metadata indexed by cpv |
| 228 self.invalids = [] | 228 self.invalids = [] |
| 229 self.settings = settings | 229 self.settings = settings |
| 230 self._pkg_paths = {} | 230 self._pkg_paths = {} |
| 231 self._pkgindex_uri = {} |
| 231 self._populating = False | 232 self._populating = False |
| 232 self._all_directory = os.path.isdir( | 233 self._all_directory = os.path.isdir( |
| 233 os.path.join(self.pkgdir, "All")) | 234 os.path.join(self.pkgdir, "All")) |
| 234 self._pkgindex_version = 0 | 235 self._pkgindex_version = 0 |
| 235 self._pkgindex_hashes = ["MD5","SHA1"] | 236 self._pkgindex_hashes = ["MD5","SHA1"] |
| 236 self._pkgindex_file = os.path.join(self.pkgdir, "Package
s") | 237 self._pkgindex_file = os.path.join(self.pkgdir, "Package
s") |
| 237 self._pkgindex_keys = self.dbapi._aux_cache_keys.copy() | 238 self._pkgindex_keys = self.dbapi._aux_cache_keys.copy() |
| 238 self._pkgindex_keys.update(["CPV", "MTIME", "SIZE"]) | 239 self._pkgindex_keys.update(["CPV", "MTIME", "SIZE"]) |
| 239 self._pkgindex_aux_keys = \ | 240 self._pkgindex_aux_keys = \ |
| 240 ["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION",
"EAPI", | 241 ["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION",
"EAPI", |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 f.close() | 868 f.close() |
| 868 except (IOError, PortageException): | 869 except (IOError, PortageException): |
| 869 if os.access(os.path.dirname(pkgindex_fi
le), os.W_OK): | 870 if os.access(os.path.dirname(pkgindex_fi
le), os.W_OK): |
| 870 raise | 871 raise |
| 871 # The current user doesn't have permissi
on to cache the | 872 # The current user doesn't have permissi
on to cache the |
| 872 # file, but that's alright. | 873 # file, but that's alright. |
| 873 if pkgindex: | 874 if pkgindex: |
| 874 # Organize remote package list as a cpv -> metad
ata map. | 875 # Organize remote package list as a cpv -> metad
ata map. |
| 875 remotepkgs = _pkgindex_cpv_map_latest_build(pkgi
ndex) | 876 remotepkgs = _pkgindex_cpv_map_latest_build(pkgi
ndex) |
| 876 remote_base_uri = pkgindex.header.get("URI", bas
e_url) | 877 remote_base_uri = pkgindex.header.get("URI", bas
e_url) |
| 877 » » » » for remote_metadata in remotepkgs.values(): | 878 » » » » for cpv, remote_metadata in remotepkgs.items(): |
| 878 remote_metadata["BASE_URI"] = remote_bas
e_uri | 879 remote_metadata["BASE_URI"] = remote_bas
e_uri |
| 880 self._pkgindex_uri[cpv] = url |
| 879 self._remotepkgs.update(remotepkgs) | 881 self._remotepkgs.update(remotepkgs) |
| 880 self._remote_has_index = True | 882 self._remote_has_index = True |
| 881 for cpv in remotepkgs: | 883 for cpv in remotepkgs: |
| 882 self.dbapi.cpv_inject(cpv) | 884 self.dbapi.cpv_inject(cpv) |
| 883 if True: | 885 if True: |
| 884 # Remote package instances override loca
l package | 886 # Remote package instances override loca
l package |
| 885 # if they are not identical. | 887 # if they are not identical. |
| 886 hash_names = ["SIZE"] + self._pkgindex_h
ashes | 888 hash_names = ["SIZE"] + self._pkgindex_h
ashes |
| 887 for cpv, local_metadata in metadata.item
s(): | 889 for cpv, local_metadata in metadata.item
s(): |
| 888 remote_metadata = self._remotepk
gs.get(cpv) | 890 remote_metadata = self._remotepk
gs.get(cpv) |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 | 1220 |
| 1219 def isremote(self, pkgname): | 1221 def isremote(self, pkgname): |
| 1220 """Returns true if the package is kept remotely and it has not b
een | 1222 """Returns true if the package is kept remotely and it has not b
een |
| 1221 downloaded (or it is only partially downloaded).""" | 1223 downloaded (or it is only partially downloaded).""" |
| 1222 if self._remotepkgs is None or pkgname not in self._remotepkgs: | 1224 if self._remotepkgs is None or pkgname not in self._remotepkgs: |
| 1223 return False | 1225 return False |
| 1224 # Presence in self._remotepkgs implies that it's remote. When a | 1226 # Presence in self._remotepkgs implies that it's remote. When a |
| 1225 # package is downloaded, state is updated by self.inject(). | 1227 # package is downloaded, state is updated by self.inject(). |
| 1226 return True | 1228 return True |
| 1227 | 1229 |
| 1230 def get_pkgindex_uri(self, pkgname): |
| 1231 """Returns the URI to the Packages file for a given package.""" |
| 1232 return self._pkgindex_uri.get(pkgname) |
| 1233 |
| 1228 def gettbz2(self, pkgname): | 1234 def gettbz2(self, pkgname): |
| 1229 """Fetches the package from a remote site, if necessary. Attemp
ts to | 1235 """Fetches the package from a remote site, if necessary. Attemp
ts to |
| 1230 resume if the file appears to be partially downloaded.""" | 1236 resume if the file appears to be partially downloaded.""" |
| 1231 tbz2_path = self.getname(pkgname) | 1237 tbz2_path = self.getname(pkgname) |
| 1232 tbz2name = os.path.basename(tbz2_path) | 1238 tbz2name = os.path.basename(tbz2_path) |
| 1233 resume = False | 1239 resume = False |
| 1234 if os.path.exists(tbz2_path): | 1240 if os.path.exists(tbz2_path): |
| 1235 if (tbz2name not in self.invalids): | 1241 if (tbz2name not in self.invalids): |
| 1236 return | 1242 return |
| 1237 else: | 1243 else: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 def getslot(self, mycatpkg): | 1343 def getslot(self, mycatpkg): |
| 1338 "Get a slot for a catpkg; assume it exists." | 1344 "Get a slot for a catpkg; assume it exists." |
| 1339 myslot = "" | 1345 myslot = "" |
| 1340 try: | 1346 try: |
| 1341 myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0] | 1347 myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0] |
| 1342 except SystemExit as e: | 1348 except SystemExit as e: |
| 1343 raise | 1349 raise |
| 1344 except Exception as e: | 1350 except Exception as e: |
| 1345 pass | 1351 pass |
| 1346 return myslot | 1352 return myslot |
| OLD | NEW |