summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Dartiguelongue <eva@gentoo.org>2011-03-23 11:38:12 +0100
committerGilles Dartiguelongue <eva@gentoo.org>2011-03-23 11:38:48 +0100
commit8bb3e59a8c562be082a926bc3bdb7deddd183f3f (patch)
treed82dc315e4ed59a203a7f59ee53ca650e00a2ed7 /scripts
parentsys-apps/accountsservice: 0.6.6 → 0.6.6-r1 (diff)
downloadgnome-8bb3e59a8c562be082a926bc3bdb7deddd183f3f.tar.gz
gnome-8bb3e59a8c562be082a926bc3bdb7deddd183f3f.tar.bz2
gnome-8bb3e59a8c562be082a926bc3bdb7deddd183f3f.zip
scripts: add slot_rindex2.py
Diffstat (limited to 'scripts')
-rw-r--r--scripts/slot_rindex2.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/scripts/slot_rindex2.py b/scripts/slot_rindex2.py
new file mode 100644
index 00000000..e3db2fcc
--- /dev/null
+++ b/scripts/slot_rindex2.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+""" Checks what slots are used for a package in its reverse dependencies. """
+
+import portage
+
+import sys
+#from pprint import pprint
+
+def main():
+ trees = portage.create_trees()
+ trees["/"]["porttree"].settings = portage.settings
+ portdb = trees["/"]["porttree"]
+ portdb.dbapi.settings = portage.settings
+ portdb.dbapi.porttrees = [portage.portdb.porttree_root]
+
+ # does it make sense to remove _all_ useless stuff or just leave it as it is?
+ #portdb.dbapi._aux_cache_keys.clear()
+ #portdb.dbapi._aux_cache_keys.update(["EAPI", "KEYWORDS", "SLOT"])
+
+ res_slots = {}
+
+ # Loop through all package names
+ for cp in portdb.dbapi.cp_all():
+ #print(cp)
+
+ # Get versions
+ cpvrs = portdb.dbapi.match(cp)
+
+ # Group by slots
+ slots = {}
+ for cpvr in cpvrs:
+ slot = portdb.dbapi.aux_get(cpvr, ["SLOT"])[0]
+ if slot is None:
+ slot = 0
+ if not slot in slots:
+ slots[slot] = []
+ slots[slot].append(cpvr)
+
+ # XXX: Walk through slots (walk twice for ~arch and arch)
+ for slot in sorted(slots):
+ cpvr = portage.versions.best(slots[slot])
+ depends = portdb.dbapi.aux_get(cpvr, ['DEPEND', 'RDEPEND', 'PDEPEND'])
+ depends = set(portage.dep.use_reduce(' '.join(depends), matchall=True, flat=True))
+ depends = [dep for dep in depends if portage.dep.isvalidatom(dep)]
+
+ #print('DEPEND:')
+ #pprint(depends)
+
+ for depend in depends:
+ if portage.dep.dep_getkey(depend) == sys.argv[1]:
+ mypkg_slot = portage.dep.dep_getslot(depend)
+ if mypkg_slot is None:
+ mypkg_slot = "unset"
+
+ if mypkg_slot not in res_slots:
+ res_slots[mypkg_slot] = [cpvr]
+ else:
+ res_slots[mypkg_slot].append(cpvr)
+ #print(portage.dep.dep_getkey(depend) + ' uses ' + sys.argv[1] + ' slot ' + portage.dep.dep_getslot(depend))
+
+ for slot in sorted(res_slots):
+ print('%s:%s' % (sys.argv[1], slot))
+ for rescpv in res_slots[slot]:
+ print(' ' + rescpv)
+
+
+if __name__ == "__main__":
+ main()
+
+## vim:set sts=4 ts=4 sw=4 expandtab: