Split USE evaluation code out of binarytree.inject() so
authorZac Medico <zmedico@gentoo.org>
Thu, 11 Oct 2007 18:14:18 +0000 (18:14 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 11 Oct 2007 18:14:18 +0000 (18:14 -0000)
that it can be reused in populate().

svn path=/main/trunk/; revision=8052

pym/portage/dbapi/bintree.py
pym/portage/getbinpkg.py

index 253ab507b51e94b7e40d0a0ede3d7ea40c174192..b2cc1904d76394f9a8fc49b5253e7df61d505707 100644 (file)
@@ -732,35 +732,15 @@ class binarytree(object):
                                "RDEPEND", "DEPEND", "PDEPEND"]
                        from itertools import izip
                        d.update(izip(keys, self.dbapi.aux_get(cpv, keys)))
-                       use = d["USE"].split()
-                       iuse = set(d["IUSE"].split())
-                       use = [f for f in use if f in iuse]
-                       if not iuse:
-                               del d["IUSE"]
-                       use.sort()
-                       d["USE"] = " ".join(use)
                        d["DESC"] = d["DESCRIPTION"]
                        del d["DESCRIPTION"]
-                       from portage.dep import paren_reduce, use_reduce, \
-                               paren_normalize, paren_enclose
-                       for k in "LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROVIDE":
-                               try:
-                                       deps = paren_reduce(d[k])
-                                       deps = use_reduce(deps, uselist=use)
-                                       deps = paren_normalize(deps)
-                                       deps = paren_enclose(deps)
-                               except portage.exception.InvalidDependString, e:
-                                       writemsg("%s: %s\n" % (k, str(e)),
-                                               noiselevel=-1)
-                                       del e
-                                       writemsg("!!! Invalid binary package: '%s'\n" % \
-                                               self.getname(cpv), noiselevel=-1)
-                                       self.dbapi.cpv_remove(cpv)
-                                       return
-                               if deps:
-                                       d[k] = deps
-                               else:
-                                       del d[k]
+                       try:
+                               self._eval_use_flags(cpv, d)
+                       except portage.exception.InvalidDependString, e:
+                               writemsg("!!! Invalid binary package: '%s'\n" % \
+                                       self.getname(cpv), noiselevel=-1)
+                               self.dbapi.cpv_remove(cpv)
+                               return
                        pkgindex.packages[cpv] = d
                        self._update_pkgindex_header(pkgindex.header)
                        from portage.util import atomic_ofstream
@@ -803,6 +783,26 @@ class binarytree(object):
                                pass
                return False
 
+       def _eval_use_flags(self, cpv, metadata):
+               use = metadata["USE"].split()
+               iuse = set(metadata["IUSE"].split())
+               use = [f for f in use if f in iuse]
+               use.sort()
+               metadata["USE"] = " ".join(use)
+               from portage.dep import paren_reduce, use_reduce, \
+                       paren_normalize, paren_enclose
+               for k in "LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROVIDE":
+                       try:
+                               deps = paren_reduce(metadata[k])
+                               deps = use_reduce(deps, uselist=use)
+                               deps = paren_normalize(deps)
+                               deps = paren_enclose(deps)
+                       except portage.exception.InvalidDependString, e:
+                               writemsg("%s: %s\n" % (k, str(e)),
+                                       noiselevel=-1)
+                               raise
+                       metadata[k] = deps
+
        def exists_specific(self, cpv):
                if not self.populated:
                        self.populate()
index fe2892d2d848e8f226728793fd32179f389e862b..a248e378b7159b5b6608c32264664239a989d7ef 100644 (file)
@@ -710,14 +710,9 @@ class PackageIndex(object):
                                del metadata["CHOST"]
                        if metadata.get("EAPI") == "0":
                                del metadata["EAPI"]
-                       if metadata.get("IUSE") == "":
-                               del metadata["IUSE"]
-                       if metadata.get("PROVIDE") == "":
-                               del metadata["PROVIDE"]
                        if metadata.get("SLOT") == "0":
                                del metadata["SLOT"]
-                       if metadata.get("USE") == "":
-                               del metadata["USE"]
                        keys = metadata.keys()
                        keys.sort()
-                       writepkgindex(pkgfile, [(k, metadata[k]) for k in keys])
+                       writepkgindex(pkgfile,
+                               [(k, metadata[k]) for k in keys if metadata[k]])