From: Zac Medico Date: Thu, 31 May 2007 21:07:11 +0000 (-0000) Subject: Replace deprecated binarytree.remotepkgs usage with binarytree._remotepkgs since... X-Git-Tag: v2.2_pre1~1320 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d9a9f08fc3a80bba3332267e13ed9409530c50ec;p=portage.git Replace deprecated binarytree.remotepkgs usage with binarytree._remotepkgs since the former is vulnerable to collisions in the tbz2 filename. svn path=/main/trunk/; revision=6697 --- diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 51d565489..d6c4b1418 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -43,11 +43,12 @@ class bindbapi(fakedbapi): mysplit = mycpv.split("/") mylist = [] tbz2name = mysplit[1]+".tbz2" - if self.bintree and not self.bintree.isremote(mycpv): - tbz2 = portage.xpak.tbz2(self.bintree.getname(mycpv)) - getitem = tbz2.getfile + if not self.bintree._remotepkgs or \ + not self.bintree.isremote(mycpv): + tbz2_path = self.bintree.getname(mycpv) + getitem = portage.xpak.tbz2(tbz2_path).getfile else: - getitem = self.bintree.remotepkgs[tbz2name].get + getitem = self.bintree._remotepkgs[mycpv].get mydata = {} mykeys = wants if cache_me: @@ -535,12 +536,8 @@ class binarytree(object): self._remotepkgs = pkgindex.packages self._remote_has_index = True self.remotepkgs = {} - for cpv, metadata in self._remotepkgs.iteritems(): + for cpv in self._remotepkgs: self.dbapi.cpv_inject(cpv) - cat, pf = catsplit(cpv) - # backward compat - self.remotepkgs[pf+".tbz2"] = metadata - metadata["CATEGORY"] = cat self.populated = 1 return self._remotepkgs = {} @@ -739,16 +736,14 @@ class binarytree(object): def isremote(self, pkgname): "Returns true if the package is kept remotely." - mysplit = pkgname.split("/") - remote = (not os.path.exists(self.getname(pkgname))) and self.remotepkgs.has_key(mysplit[1]+".tbz2") + remote = pkgname in self._remotepkgs and \ + not os.path.exists(self.getname(pkgname)) return remote def get_use(self, pkgname): - mysplit=pkgname.split("/") - if self.isremote(pkgname): - return self.remotepkgs[mysplit[1]+".tbz2"]["USE"][:].split() - tbz2=portage.xpak.tbz2(self.getname(pkgname)) - return tbz2.getfile("USE").split() + writemsg("deprecated use of binarytree.get_use()," + \ + " use dbapi.aux_get() instead", noiselevel=-1) + return self.dbapi.aux_get(pkgname, ["USE"])[0].split() def gettbz2(self, pkgname): "fetches the package from a remote site, if necessary."