From: Zac Medico Date: Thu, 11 Oct 2007 18:14:18 +0000 (-0000) Subject: Split USE evaluation code out of binarytree.inject() so X-Git-Tag: v2.2_pre1~645 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=053bc17627b159a16a4d38356f3701dd3250a318;p=portage.git Split USE evaluation code out of binarytree.inject() so that it can be reused in populate(). svn path=/main/trunk/; revision=8052 --- diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 253ab507b..b2cc1904d 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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() diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index fe2892d2d..a248e378b 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -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]])