From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from <gentoo-commits+bounces-322152-garchives=archives.gentoo.org@lists.gentoo.org>) id 1PvX7H-0000SJ-SN for garchives@archives.gentoo.org; Fri, 04 Mar 2011 15:40:32 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 53D271C04D; Fri, 4 Mar 2011 15:40:24 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 155BD1C04D for <gentoo-commits@lists.gentoo.org>; Fri, 4 Mar 2011 15:40:24 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 875291B409E for <gentoo-commits@lists.gentoo.org>; Fri, 4 Mar 2011 15:40:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E4A728006A for <gentoo-commits@lists.gentoo.org>; Fri, 4 Mar 2011 15:40:22 +0000 (UTC) From: "Nirbheek Chauhan" <nirbheek@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Nirbheek Chauhan" <nirbheek@gentoo.org> Message-ID: <422cf4a4512baad41a5294f0e65dfd0e0112c99d.nirbheek@gentoo> Subject: [gentoo-commits] proj/gnome:master commit in: scripts/ X-VCS-Repository: proj/gnome X-VCS-Files: scripts/slot_rindex.py X-VCS-Directories: scripts/ X-VCS-Committer: nirbheek X-VCS-Committer-Name: Nirbheek Chauhan X-VCS-Revision: 422cf4a4512baad41a5294f0e65dfd0e0112c99d Date: Fri, 4 Mar 2011 15:40:22 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 37d1816835381f028748b30e11d30638 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=3Dproj/gnome.git;a=3D= commit;h=3D422cf4a4 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=3D4 sw=3D4 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 rin= dex 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 rin= dex +# + +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 =3D [portage.settings['PORTDIR']] +PORTDIR =3D portage.settings['PORTDIR'] +RINDEX =3D "http://tinderbox.dev.gentoo.org/misc/rindex" +DEPSTR =3D ['RDEPEND', 'PDEPEND', 'DEPEND'] +KEY =3D 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 =3D osp.join(*portage.catpkgsplit(cpv)[0:2]) + return osp.join(PORTDIR, path, 'metadata.xml') + +def rdeps_with_slot(slot_rdeps, slot=3DNone): + """ + Prints a list of rev-deps which depend on the specified package and = slot + """ + print "All packages:" + pkg_maints =3D {} + pkg_herds =3D {} + if not slot_rdeps.has_key(slot): + # No rdeps using the given slot + return + for pkg in slot_rdeps[slot]: + pkg_md =3D MetaDataXML(get_md_path(pkg), get_herds()) + for herd in pkg_md.herds(): + if not pkg_herds.has_key(herd): + pkg_herds[herd] =3D [] + pkg_herds[herd].append(pkg) + for maint in pkg_md.maintainers(): + if not pkg_maints.has_key(maint.email): + pkg_maints[maint.email] =3D [] + 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 =3D urllib2.urlopen('/'.join([RINDEX, KEY])).read().split() +rdeps =3D [] +for i in vrdeps: + rdeps.append(i.split(':')[0]) + +slot_rdeps =3D {} +failed_rdeps =3D [] +for rdep in rdeps: + rdep =3D rdep.split(':')[0] + if not portage.isvalidatom('=3D'+rdep): + print 'Invalid atom: ' + rdep + continue + try: + temp =3D 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) =3D=3D KEY: + slot =3D 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] =3D set() + slot_rdeps[slot].add(rdep) + +# Convert back to list, and sort the atoms +for slot in slot_rdeps.keys(): + slot_rdeps[slot] =3D list(slot_rdeps[slot]) + slot_rdeps[slot].sort() + +if failed_rdeps: + print 'Failed: ' + str(failed_rdeps) + +rdeps_with_slot(slot_rdeps)