From: W. Trevor King Date: Sun, 10 Mar 2013 01:06:32 +0000 (-0500) Subject: overlays/default: Add README and equery-licenses X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cd730ae;p=catalyst-swc.git overlays/default: Add README and equery-licenses The packages distributed in the release ISOs are distributed under a range of licenses, but in the ISO we distribute them without their source. Since many licenses (e.g. the GPLv2, section 3) require you to also distribute or provide access to the corresponding source code, it's good to be clear about the licensing of the bundled binaries. The large list of installed packages and licenses can also serve as a teaching tool for explaining how open source development works, and emphasizing why using a standard license is a good idea ;). --- diff --git a/overlays/default/README b/overlays/default/README new file mode 100644 index 0000000..0199436 --- /dev/null +++ b/overlays/default/README @@ -0,0 +1,36 @@ +This distribution was build using open source software and the +catalyst [1] release-building tool. For details on the catalyst +configuration used for this release, see [2]. + +The packaged projects are distributed under a variety of licenses, and +were installed using metadata from Gentoo's Portage tree [3] and +source from Gentoo's mirrors [4]. The full Portage tree is not +distributed with this release due to size constraints on the release +media, but you can download a snapshot from the Gentoo mirrors +directly or by using [5]: + + $ emerge-webrsync + +To find the license of a particular installed package, use: + + $ portageq metadata / installed LICENSE + +For example: + + $ portageq metadata / installed dev-lang/python-3.2.3 LICENSE + PSF-2 + +The license test is listed in the Portage tree [6], for example [7]. + +For a listing of all the licenses used by all packages, run: + + $ equery-licenses.py + + +[1]: http://www.gentoo.org/proj/en/releng/catalyst/ +[2]: http://blog.tremily.us/posts/catalyst/ +[3]: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/ +[4]: http://www.gentoo.org/main/en/mirrors.xml +[5]: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=6#doc_chap2 +[7]: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/licenses/ +[8]: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/licenses/PSF-2?view=markup diff --git a/overlays/default/usr/bin/equery-licenses b/overlays/default/usr/bin/equery-licenses new file mode 100755 index 0000000..a7c7401 --- /dev/null +++ b/overlays/default/usr/bin/equery-licenses @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# +# Copyright (C) 2013 W. Trevor King +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# . + +import glob as _glob +import logging as _logging + +import portage as _portage +import portage.dep as _portage_dep +import portage.versions as _portage_versions + + +def get_db(): + """Get a database of installed packages + """ + db = _portage.db + for key in ['/', 'vartree']: + if key not in db: + raise KeyError('{0} not found (choices: {1})'.format( + key, list(db.keys()))) + db = db[key] + return db + +def get_license_lists(): + """Iterate through installed packages with licenses + + Yields (category-package-version, license-list) tuples + """ + db = get_db() + for cpv in db.dbapi.cpv_all(): + licenses,use = db.dbapi.aux_get(cpv, ['LICENSE', 'USE']) + category = _portage_versions.catsplit(cpv)[0] + if category == 'virtual': + if licenses: + _logging.warn('license for {0}: {1}'.format(cpv, licenses)) + continue + elif not licenses: + _logging.warn('no license for {0}'.format(cpv)) + continue + license_list = _portage_dep.use_reduce( + licenses, uselist=use, opconvert=True) + yield (cpv, license_list) + +def incorperate_or_dependencies(license_set, or_dependencies): + while or_dependencies: + or_dependencies = set( + or_set for or_set in or_dependencies + if not license_set.union(or_set)) + if or_dependencies: + raise NotImplementedError('select best subset of or_dependencies') + return license_set + +def get_all_licenses(): + license_set = set() + or_dependencies = set() + for cpv,license_list in get_license_lists(): + for token in license_list: + if isinstance(token, str): + license_set.add(token) + elif token[0] == '||': + or_dependencies.add(tuple(token[1:])) + else: + raise NotImplementedError((licenses, token)) + license_set = incorperate_or_dependencies(license_set, or_dependencies) + return license_set + + +if __name__ == '__main__': + licenses = get_all_licenses() + print('\n'.join(sorted(licenses)))