Skip to content

Commit

Permalink
Correctly report double licensed project and allow to skip file (#8443)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ph authored Sep 26, 2018
1 parent 99c4db2 commit 447e23b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
35 changes: 3 additions & 32 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 23 additions & 2 deletions dev-tools/generate_notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import csv
import re
import copy


def read_file(filename):
Expand Down Expand Up @@ -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"])
Expand All @@ -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)
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 447e23b

Please sign in to comment.