public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Nirbheek Chauhan" <nirbheek@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gnome:master commit in: scripts/
Date: Fri,  4 Mar 2011 15:40:22 +0000 (UTC)	[thread overview]
Message-ID: <422cf4a4512baad41a5294f0e65dfd0e0112c99d.nirbheek@gentoo> (raw)

commit:     422cf4a4512baad41a5294f0e65dfd0e0112c99d
Author:     Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  4 15:40:00 2011 +0000
Commit:     Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org>
CommitDate: Fri Mar  4 15:40:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=commit;h=422cf4a4

Add scripts/slot_rindex.py

---
 scripts/slot_rindex.py |  121 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 121 insertions(+), 0 deletions(-)

diff --git a/scripts/slot_rindex.py b/scripts/slot_rindex.py
new file mode 100755
index 0000000..a8308ca
--- /dev/null
+++ b/scripts/slot_rindex.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python2
+# vim: set sts=4 sw=4 et :
+#
+# Author(s): Nirbheek Chauhan
+# License: MIT
+#
+# A small script which sorts the revdeps of a given library according to
+# which slot of the given library they depend on. Uses the tinderbox rindex for
+# speed, because of which results may be out of date.
+#
+# Currently prints out a list of revdeps which *don't* use a slot in the
+# dependency atom containing the given library
+#
+# TODO: Add a slower portage-only mode which calculates the required rindex
+#
+
+import sys
+import urllib2
+import os.path as osp
+
+import portage
+from portage.xml.metadata import MetaDataXML
+
+if len(sys.argv) < 2:
+    print "Usage: %s <cat/pkg>" % sys.argv[0]
+    sys.exit(1)
+
+portage.portdb.porttrees = [portage.settings['PORTDIR']]
+PORTDIR = portage.settings['PORTDIR']
+RINDEX = "http://tinderbox.dev.gentoo.org/misc/rindex"
+DEPSTR = ['RDEPEND', 'PDEPEND', 'DEPEND']
+KEY = sys.argv[1]
+
+def get_herds():
+    return osp.join(PORTDIR, 'metadata', 'herds.xml')
+
+def get_md_path(cpv):
+    """
+    x11-libs/gtk+-2.22.0-r1 -> <portdir>/x11-libs/gtk+/metadata.xml
+    """
+    path = osp.join(*portage.catpkgsplit(cpv)[0:2])
+    return osp.join(PORTDIR, path, 'metadata.xml')
+
+def rdeps_with_slot(slot_rdeps, slot=None):
+    """
+    Prints a list of rev-deps which depend on the specified package and slot
+    """
+    print "All packages:"
+    pkg_maints = {}
+    pkg_herds = {}
+    if not slot_rdeps.has_key(slot):
+        # No rdeps using the given slot
+        return
+    for pkg in slot_rdeps[slot]:
+        pkg_md = MetaDataXML(get_md_path(pkg), get_herds())
+        for herd in pkg_md.herds():
+            if not pkg_herds.has_key(herd):
+                pkg_herds[herd] = []
+            pkg_herds[herd].append(pkg)
+        for maint in pkg_md.maintainers():
+            if not pkg_maints.has_key(maint.email):
+                pkg_maints[maint.email] = []
+            pkg_maints[maint.email].append(pkg)
+        print '\t%s\therds: ' % pkg,
+        for i in pkg_md.herds():
+            print '%s' % i,
+        print '\tmaintainers: ',
+        for i in pkg_md.maintainers():
+            print '%s' % i.email,
+        print
+
+    print "Herd packages:"
+    for (herd, pkgs) in pkg_herds.iteritems():
+        print 'Herd: %s' % herd
+        for pkg in pkgs:
+            print '\t%s' % pkg
+
+    print "Maintainer packages:"
+    for (maint, pkgs) in pkg_maints.iteritems():
+        print 'Maintainer: %s' % maint
+        for pkg in pkgs:
+            print '\t%s' % pkg
+
+
+vrdeps = urllib2.urlopen('/'.join([RINDEX, KEY])).read().split()
+rdeps = []
+for i in vrdeps:
+    rdeps.append(i.split(':')[0])
+
+slot_rdeps = {}
+failed_rdeps = []
+for rdep in rdeps:
+    rdep = rdep.split(':')[0]
+    if not portage.isvalidatom('='+rdep):
+        print 'Invalid atom: ' + rdep
+        continue
+    try:
+        temp = portage.portdb.aux_get(rdep, DEPSTR)[0].split()
+    except KeyError:
+        failed_rdeps.append(rdep)
+    for dep in temp:
+        # Ignore ||, (, ), etc.
+        if not portage.isvalidatom(dep):
+            continue
+        # Categorize the dep into the slot it uses
+        if portage.dep.dep_getkey(dep) == KEY:
+            slot = portage.dep.dep_getslot(dep)
+            if not slot_rdeps.has_key(slot):
+                # We use a set here because atoms often get repeated
+                slot_rdeps[slot] = set()
+            slot_rdeps[slot].add(rdep)
+
+# Convert back to list, and sort the atoms
+for slot in slot_rdeps.keys():
+    slot_rdeps[slot] = list(slot_rdeps[slot])
+    slot_rdeps[slot].sort()
+
+if failed_rdeps:
+    print 'Failed: ' + str(failed_rdeps)
+
+rdeps_with_slot(slot_rdeps)



             reply	other threads:[~2011-03-04 15:40 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04 15:40 Nirbheek Chauhan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-04-03 19:42 [gentoo-commits] proj/gnome:master commit in: scripts/ Matt Turner
2020-04-03 19:42 Matt Turner
2020-03-28  8:31 Mart Raudsepp
2020-03-10 22:05 Matt Turner
2019-02-07 11:58 Mart Raudsepp
2018-04-25 10:32 Mart Raudsepp
2018-01-10  3:25 Mart Raudsepp
2012-04-01 21:14 Nirbheek Chauhan
2012-04-01 19:12 Nirbheek Chauhan
2011-08-18  6:23 Nirbheek Chauhan
2011-07-12 21:15 Nirbheek Chauhan
2011-05-21 18:38 Nirbheek Chauhan
2011-05-19 12:35 Gilles Dartiguelongue
2011-04-13  9:57 Nirbheek Chauhan
2011-04-09  6:29 Nirbheek Chauhan
2011-03-28 16:15 Nirbheek Chauhan
2011-03-28 15:04 Nirbheek Chauhan
2011-03-26  1:58 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 19:21 Gilles Dartiguelongue
2011-03-23 10:39 Gilles Dartiguelongue
2011-03-20  8:11 Nirbheek Chauhan
2011-03-18  9:59 Nirbheek Chauhan
2011-03-18  8:23 Nirbheek Chauhan
2011-03-17 17:12 Nirbheek Chauhan
2011-03-15 13:08 Nirbheek Chauhan
2011-03-14 18:41 Nirbheek Chauhan
2011-03-12 20:10 Nirbheek Chauhan
2011-02-18  4:40 Nirbheek Chauhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=422cf4a4512baad41a5294f0e65dfd0e0112c99d.nirbheek@gentoo \
    --to=nirbheek@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox