--- equery.orig 2008-01-04 13:37:17.467089917 -0600 +++ equery 2008-01-04 13:35:31.774214028 -0600 @@ -1569,6 +1569,73 @@ " " + pp.localoption("-p, --portage-tree") + " - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \ " " + pp.localoption("-o, --overlay-tree") + " - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n" +class CmdFindPkgsInOverlay(Command): + def __init__(self): + self.defaultOpts = {} + def parseArgs(self, args): + query = "" + need_help = 0 + opts = self.defaultOpts + skip = 0 + + for i in xrange(len(args)): + if skip: + skip -= 1 + continue + x = args[i] + + if x in ["-h","--help"]: + need_help = 1 + break + else: + query = x + + if need_help or query == "": + print_info(0, self.longHelp()) + sys.exit(-1) + + return (query, opts) + + + def perform(self, args): + (query, opts) = self.parseArgs(args) + self.overlay = query + packages = portage.db["/"]["vartree"].dbapi.cpv_all() + found = [] + count = 0 + count_unknown = 0 + # in the loop I'd like to use aux_get from the dbapi, but it isn't implemented yet + for i in xrange(len(packages)): + pkgpath = portage.root + portage.VDB_PATH + "/" + packages[i] + repofile = pkgpath + "/repository" + if os.path.exists(pkgpath): + count+=1 + if os.path.exists(repofile): + ofile=open(repofile,"r") + repo = ofile.readline().rstrip() + if repo == self.overlay: + found.append(packages[i]) + ofile.close() + else: + count_unknown+=1 + else: + print "Something went terrible wrong, your portage / python install is screwed" + print "Your system thinkgs it has files installed, but they aren't there" + die("dbapi.cpv_all() reporting items not in portage.VDB_PATH") + for i in xrange(len(found)): + print found[i] + print "\n-====-\n\nCouldn't identifiy " + str(count_unknown) + " packages out of " + str(count) + + def shortHelp(self): + return pp.pkgquery("overlay") + " - Finds packages installed from " + pp.pkgquery("overlay") + + def longHelp(self): + return "Find all packages that have been installed from the overlay" + \ + "\n" + \ + "Syntax:\n" + \ + " " + pp.command("inoverlay") + pp.pkgquery(" overlay") + + # # Command line tokens to commands mapping # @@ -1586,7 +1653,8 @@ "check" : CmdCheckIntegrity(), "stats" : CmdDisplayStatistics(), "glsa" : CmdListGLSAs(), - "which": CmdWhich() + "which": CmdWhich(), + "inoverlay": CmdFindPkgsInOverlay() } # Short command line tokens @@ -1604,7 +1672,8 @@ "s" : "size", "t" : "stats", "u" : "uses", - "w" : "which" + "w" : "which", + "o" : "inoverlay" } from gentoolkit import Config