#!/usr/bin/python def x11_deprecation_check(depstr): if depstr.find("virtual/x11") == -1: return False depsplit = depstr.split() ok_stack = [] ok = False for token in depsplit: if token == "(": ok_stack.append(ok) ok = False elif token == ")": ok = ok_stack.pop() elif token == "||": ok = True else: ok = False if token.find("virtual/x11") != -1 and (not ok_stack or not ok_stack[-1]): return True return False import os,sys os.putenv("PORTDIR_OVERLAY", '') os.putenv("PORTAGE_CALLER", "repoman") import portage if __name__ == "__main__": ptree = portage.db["/"]["porttree"] pdb=ptree.dbapi if len(sys.argv) > 1: cp_list = sys.argv[1:] else: cp_list = pdb.cp_all() for cp in cp_list: cpv = ptree.dep_bestmatch(cp) if cpv: try: d = ' '.join(pdb.aux_get(cpv, ["DEPEND", "RDEPEND", "PDEPEND"])) except KeyError: print "cpv %s sucks, kthnx" % cpv continue if x11_deprecation_check(d): print cp