diff options
Diffstat (limited to 'scripts/check-licenses2.py~')
| -rwxr-xr-x | scripts/check-licenses2.py~ | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/scripts/check-licenses2.py~ b/scripts/check-licenses2.py~ new file mode 100755 index 0000000..f1973f4 --- /dev/null +++ b/scripts/check-licenses2.py~ @@ -0,0 +1,165 @@ +#!/usr/bin/env python3 +# Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +_data = {} + +def has_android_free_license_filename(data, repository_path): + pass + +_license_filenames = { + 'license-filename': { + 'func' : has_android_free_license_filename, + 'files' : [ + 'MODULE_LICENSE_BSD_LIKE', + 'MODULE_LICENSE_APACHE2', + 'MODULE_LICENSE_BSD', + 'MODULE_LICENSE_MIT', + 'MODULE_LICENSE_BSD_APL2', + 'MODULE_LICENSE_GPL', + 'MODULE_LICENSE_PUBLIC_DOMAIN', + ], + 'sha1sums' : None, + }, +} +_data.update(_license_filenames) + +################# +# License files # +################# +license_files = [ + 'COPYING', + 'LICENSE', + 'LICENCE', + 'NIST-CONDITIONS-OF-USE', +] + +stock_license_files_checksums = [ + ############## + # Apache 2.0 # + ############## + '11d8a409876496183c8fba90eb70f25301875b67', + '5a7d7df655ba40478fae80a6abafc6afc36f9b6a', + '82f88802986ad28deac953dc06bd0bb52f3d012c', + '04f15afbbe53b69d0e4870e9308efae75efa773a', + '58853eb8199b5afe72a73a25fd8cf8c94285174b', + ####### + # BSD # + ####### + # external/openssh/LICENCE, also contains + # various other permissive licenses + '0ea904438c8997ec028278e2d51a0af60ef7e698', + ############### + # Expat / MIT # + ############### + # external/libepoxy/COPYING + '00f34512740377ad1f155eaa15936e472661c5e3', + ########### + # OFL-1.1 # + ########### + # external/google-fonts/source-sans-pro/LICENSE + 'a55d8584dd1af1bd63bf607a6195d56beb8ee564', + # external/google-fonts/lato/LICENSE + '76897b37e127e2332a1a79aab2e0d6f30ccdc47a', + # external/google-fonts/arvo/LICENSE + '2ef38678dab952ed745c71e59e9a2f595cddb0f4', + # external/google-fonts/big-shoulders-text/LICENSE + '35765f09b7708df97741f83ca94978a8a742adfa', + # external/google-fonts/fraunces/LICENSE + '587180e421d550a5e4bf6a6e76275c21d486e8ef', + ############## + # Python 2.1 # + ############## + '0c492b235e749a739628cdd18d8c860c6f70396b', +] + +modified_license_files_checksums = [ + # Apache 2.0 + '11d8a409876496183c8fba90eb70f25301875b67', +] + +def has_stock_free_license_file(path): + pass + +stock_license_files = { + 'stock-license-file': { + 'func' : has_stock_free_license_file, + 'files': license_files, + 'sha1sums': stock_license_files_checksums, + }, +} +_data.update(stock_license_files) + +def has_modified_free_license_file(path): + pass + +modified_license_files = { + 'modified-license-file': { + 'func' : has_modified_free_license_file, + 'files': license_files, + 'sha1sums': modified_license_files_checksums, + }, +} + +_data.update(modified_license_files) + + +if __name__ == '__main__': + verbose = True + if len(sys.argv) != 2: + usage(sys.argv[0]) + + manifest_xml_path = sys.argv[1] + + m = manifest.Manifest(manifest_xml_path) + paths = m.list_repositories_paths() + + nr_unknown_repositories = 0 + nr_unknown_licenses = 0 + for path in paths: + l = RepositoryLicense(path) + found, details = l.has_free_license() + if not found and verbose: + nr_unknown_repositories += 1 + if len(details) > 0: + for k, v in details.items(): + printed_header = False + if v['type'] in ['stock-license-file', + 'modified-license-file']: + if not printed_header: + print("{}:".format(path)) + printed_header = True + print("- {} {}".format(k, v['sha1sum'])) + nr_unknown_licenses += 1 + # We'll handle repositories with READMEs when we + # will have handled all the licenses files + # else: + # print("- TODO: look at the READMEs") + # We'll handle these repositories when we + # will have handled all the licenses files + # else: + # print("{}".format(path)) + + if verbose: + if nr_unknown_repositories > 0 or nr_unknown_licenses > 0: + print() + print("Total:") + print("------") + if nr_unknown_repositories > 0: + print("- {} repositories to check".format(nr_unknown_repositories)) + if nr_unknown_licenses > 0: + print("- {} licenses to check".format(nr_unknown_licenses)) + + |
