#!/usr/bin/env python2 import glob import portage import os, os.path import sys import pprint def get_not_owned(files): if not files: return [] files = [(fname, os.path.realpath(fname)) for fname in files] sfiles = set(files) #pprint.pprint(sfiles) found = set() vtree = portage.db["/"]["vartree"] for package in vtree.getallcpv(): link = portage.dblink(myroot="/", settings=vtree.settings, *portage.catsplit(package)) contents = link.getcontents() for fname in sfiles - found: if contents and ((fname[0] in contents) or (fname[1] in contents)): #print fname found.add(fname) if not sfiles - found: break return [x for x in files if x not in found] not_owned = get_not_owned(sys.argv[1:]) for fname in not_owned: print fname