#!/usr/bin/python # ================================================== # By David M. Andersen # University of North Carolina at Charlotte # http://www.dmatech.org/ # danderse@uncc.edu # ================================================== # http://www.python.org/doc/2.2.2/lib/typesmapping.html # http://www.python.org/doc/2.2.2/lib/types.html # http://www.dmatech.org/~dma/epy/portage/html/ # Fixed to work with package.use, and some other minor # fixes, by ferret . import os,sys,portage,string,re,commands,traceback,types from stat import * from output import * sys.path.insert(0, "/usr/lib/portage/pym") sys.path.insert(0, "/usr/lib/gentoolkit/pym") import gentoolkit def intersection(a, b): map_a = {} retlist = [] for item in a: map_a[item] = 1 for item in b: if map_a.has_key(item): retlist.append(item) return retlist def getcompuseflags(ebuild): path = vt.getebuildpath(ebuild) path = os.path.join(os.path.dirname(path),"USE") try: myfile = open(path,"r") except Exception, e: return ["NOT_FOUND"] line = string.rstrip(myfile.readline()) myfile.close() return string.split(line, " ") def diff_use(old, new): old.sort() new.sort() map_old = {} map_new = {} only_in_new = [] only_in_old = [] # Unadulterated evil ahead next 20 lines or so. for item in old: map_old[item] = 1 for item in new: map_new[item] = 1 if item not in map_old: only_in_new.append(item) for item in old: if item not in map_new: only_in_old.append(item) return len(only_in_old)+len(only_in_new) ############################################################## if (not sys.stdout.isatty()) or (portage.settings["NOCOLOR"] in ["yes","true"]): nocolor() # Current useflags: # portage.usesplit # # Relevant useflags for a package: # portage.portdb.aux_get(x, ["IUSE"]) #sys_use=portage.usesplit root="/" vt=portage.db[root]["vartree"] for node in vt.getallnodes(): x=vt.resolve_key(node) matches=vt.dbapi.match(x) for x in matches: try: iuse=string.split(portage.portdb.aux_get(x, ["IUSE"])[0]," ") except Exception, e: pass comp_use=getcompuseflags(x) sys_use=gentoolkit.find_packages("="+x)[0].get_settings("USE").split() ilc=intersection(iuse, comp_use) ils=intersection(iuse, sys_use) if (diff_use(ilc,ils)) > 0: print x