summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-05-24 03:09:01 +0000
committerZac Medico <zmedico@gentoo.org>2007-05-24 03:09:01 +0000
commit39f7fae846ccc5883870a989a7c9951233a0c22d (patch)
treece43bfb2f72eb7b42360a258b192f5b66d7253de
parent485fd9f277fa2d9c0011e9bee8bab92ddbcbefbc (diff)
downloadportage-39f7fae846ccc5883870a989a7c9951233a0c22d.tar.gz
portage-39f7fae846ccc5883870a989a7c9951233a0c22d.tar.bz2
portage-39f7fae846ccc5883870a989a7c9951233a0c22d.zip
Add more relevant package metadata to the Packages index, including dependencies with USE conditionals collapsed.
svn path=/main/trunk/; revision=6609
-rw-r--r--pym/portage/dbapi/bintree.py23
-rw-r--r--pym/portage/dep.py38
2 files changed, 61 insertions, 0 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index fcceb5e0d..6976d4de5 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -636,6 +636,29 @@ class binarytree(object):
d["MTIME"] = str(long(s.st_mtime))
d["SIZE"] = str(s.st_size)
d["MD5"] = str(md5)
+ keys = ["USE", "IUSE", "DESCRIPTION", "LICENSE", "PROVIDE", \
+ "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]
+ del iuse, 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":
+ deps = paren_reduce(d[k])
+ deps = use_reduce(deps, uselist=use)
+ deps = paren_normalize(deps)
+ deps = paren_enclose(deps)
+ if deps:
+ d[k] = deps
+ else:
+ del d[k]
pkgindex.packages[cpv] = d
from portage.util import atomic_ofstream
f = atomic_ofstream(os.path.join(self.pkgdir, "Packages"))
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index 468b997be..d1e22376e 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -114,6 +114,44 @@ def paren_reduce(mystr,tokenize=1):
mylist = mylist + [subsec]
return mylist
+class paren_normalize(list):
+ """Take a dependency structure as returned by paren_reduce or use_reduce
+ and generate an equivalent structure that has no redundant lists."""
+ def __init__(self, src):
+ self._zap_parens(src, self)
+
+ def _zap_parens(self, src, dest, disjunction=False):
+ if not src:
+ return dest
+ i = iter(src)
+ for x in i:
+ if isinstance(x, basestring):
+ if x == '||':
+ x = i.next()
+ if len(x) == 1:
+ if isinstance(x[0], basestring):
+ dest.append(x[0])
+ else:
+ self._zap_parens(x, dest, disjunction=disjunction)
+ else:
+ dest.append("||")
+ dest.append(self._zap_parens(x, [], disjunction=True))
+ elif x.endswith("?"):
+ dest.append(x)
+ dest.append(self._zap_parens(i.next(), []))
+ else:
+ dest.append(x)
+ else:
+ if disjunction:
+ x = self._zap_parens(x, [])
+ if len(x) == 1:
+ dest.append(x[0])
+ else:
+ dest.append(x)
+ else:
+ self._zap_parens(x, dest)
+ return dest
+
def paren_enclose(mylist):
"""
Convert a list to a string with sublists enclosed with parens.