aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMichał Górny <gentoo@mgorny.alt.pl>2010-08-27 18:47:22 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-27 09:57:58 -0700
commite081b9cf09a13a420ebace67b89a0a72fe88641b (patch)
treec6ec80f7f54bc58c0aa044aede6075675a77d16e /bin
parentRemove unused imports. (diff)
downloadportage-e081b9cf09a13a420ebace67b89a0a72fe88641b.tar.gz
portage-e081b9cf09a13a420ebace67b89a0a72fe88641b.tar.bz2
portage-e081b9cf09a13a420ebace67b89a0a72fe88641b.zip
Support returning multiple flag descriptions when restrict is used.
Return a dict of dicts in parse_metadata_use(), with second-level keys being the restrict strings (or None when no restrict). When generating use.local.desc, use the description from the possibly-highest-matching atom.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/egencache29
1 files changed, 28 insertions, 1 deletions
diff --git a/bin/egencache b/bin/egencache
index 64e60925b..1b3f98f34 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -44,6 +44,8 @@ except ImportError:
else:
from repoman.utilities import parse_metadata_use
from xml.parsers.expat import ExpatError
+ from portage.dep import Atom
+ from portage.versions import pkgcmp, pkgsplit
if sys.hexversion >= 0x3000000:
long = int
@@ -356,7 +358,32 @@ class GenUseLocalDesc(object):
self.returncode |= 1
else:
for flag in sorted(usedict.keys()):
- output.write('%s:%s - %s\n' % (cp, flag, usedict[flag]))
+ def atomcmp(atoma, atomb):
+ # None is better than an atom, that's why we reverse the args
+ if atoma is None or atomb is None:
+ return cmp(atomb, atoma)
+ # Same for plain PNs (.operator is None then)
+ elif atoma.operator is None or atomb.operator is None:
+ return cmp(atomb.operator, atoma.operator)
+ # Version matching
+ elif atoma.cpv != atomb.cpv:
+ return pkgcmp(pkgsplit(atoma.cpv), pkgsplit(atomb.cpv))
+ # Versions match, let's fallback to operator matching
+ else:
+ ops = ('<', '<=', '=', '>=', '>')
+ return cmp(ops.index(atoma.operator), ops.index(atomb.operator))
+
+ def _Atom(key):
+ if key is not None:
+ return Atom(key)
+ return None
+
+ resdict = usedict[flag]
+ reskeys = {_Atom(k): k for k in resdict.keys()}
+ resatoms = sorted(reskeys.keys(), atomcmp)
+ resdesc = resdict[reskeys[resatoms[-1]]]
+
+ output.write('%s:%s - %s\n' % (cp, flag, resdesc))
output.close()