From 447e23b4a2cc61f81d9ca26eb40e45573c8d33e7 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Wed, 26 Sep 2018 14:55:04 -0400 Subject: [PATCH] Correctly report double licensed project and allow to skip file (#8443) When a project had two licenses, the script was creating two entries in the NOTICE.txt but both entries would share the same license. This commit also add the possibility to skip file that start with LICENSE but doesn't contains any license information. It also add MIT-0 license wording see https://github.com/aws/mit-0 --- NOTICE.txt | 35 +++-------------------------------- dev-tools/generate_notice.py | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 57ab665f1480..d84c831b6514 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2974,40 +2974,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- Dependency: gopkg.in/yaml.v2 Revision: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b -License type (autodetected): MIT -./vendor/gopkg.in/yaml.v2/LICENSE.libyaml: +License type (autodetected): Apache-2.0 +./vendor/gopkg.in/yaml.v2/LICENSE: -------------------------------------------------------------------- -The following files were ported to Go from C files of libyaml, and thus -are still covered by their original copyright and license: - - apic.go - emitterc.go - parserc.go - readerc.go - scannerc.go - writerc.go - yamlh.go - yamlprivateh.go - -Copyright (c) 2006 Kirill Simonov - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +Apache License 2.0 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -------------------------------------------------------------------- Dependency: gopkg.in/yaml.v2 diff --git a/dev-tools/generate_notice.py b/dev-tools/generate_notice.py index 12e2b58e3ad0..b8a24feb1911 100644 --- a/dev-tools/generate_notice.py +++ b/dev-tools/generate_notice.py @@ -7,6 +7,7 @@ import json import csv import re +import copy def read_file(filename): @@ -59,7 +60,8 @@ def gather_dependencies(vendor_dirs, overrides=None): print("WARNING: No version information found for: {}".format(lib_path)) lib = {"path": lib_path} else: - lib = lib_search[0] + lib = copy.deepcopy(lib_search[0]) + lib["license_file"] = os.path.join(root, filename) lib["license_contents"] = read_file(lib["license_file"]) @@ -79,16 +81,22 @@ def gather_dependencies(vendor_dirs, overrides=None): # don't walk down into another vendor dir if "vendor" in dirs: dirs.remove("vendor") + return dependencies +# Allow to skip files that could match the `LICENSE` pattern but does not have any license information. +SKIP_FILES = [ +] + + def get_licenses(folder): """ Get a list of license files from a given directory. """ licenses = [] for filename in sorted(os.listdir(folder)): - if filename.startswith("LICENSE") and "docs" not in filename: + if filename.startswith("LICENSE") and "docs" not in filename and os.path.join(folder, filename) not in SKIP_FILES: licenses.append(filename) elif filename.startswith("APLv2"): # gorhill/cronexpr licenses.append(filename) @@ -241,6 +249,19 @@ def create_notice(filename, beat, copyright, vendor_dirs, csvfile, overrides=Non permit persons to whom the Software is furnished to do so, subject to the following conditions: """), + re.sub(r"\s+", " ", """Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + """), ] BSD_LICENSE_CONTENTS = [