#!/usr/bin/python # Script to check a Gentoo system for licenses a user does not agree to # Author: Marius Mauch # This script is licensed under the GNU Public License version 2 or later import sys sys.path.insert(0, "/usr/lib/portage/pym") import string import portage if len(sys.argv) != 2: print "Syntax: license-check " print " where is a file containing the names of all licenses" print " you agree with (names as in %s/licenses)." % portage.settings["PORTDIR"] print sys.exit(1) print "Warning: the syntax for the LICENSE field is not completely clear, so" print " results generated by this script might be wrong or it might " print " not work at all." print # get all installed packages and our license list allpkg = portage.vardbapi("/").cpv_all() license_ok = portage.grabfile(sys.argv[1]) for p in allpkg: # get license list for current package l_str = portage.vardbapi("/").aux_get(p, ["LICENSE"])[0] # split OR lists ("is licensed under L1 or L2", qt for example) l_or_list = l_str.split("|") # package isn't tainted yet tainted_list = [] for cur_list in l_or_list: my_lic_list = cur_list.split() # new OR part, maybe this part isn't tainted tainted = False for mylic in my_lic_list: if not mylic in license_ok: tainted = True tainted_list.append(mylic) if tainted: print p+": "+string.join(tainted_list, ", ")