Skip to content

Commit 68ea9c5

Browse files
authored
Make reuse conformant (ansible-collections#462)
* Add .license files. * Add reuse test. * Update README. * Add changelog fragment. * Normalize licenses extra sanity test. * Declare REUSE conformance. * Update README.
1 parent 8eabc7f commit 68ea9c5

17 files changed

+110
-40
lines changed

.github/workflows/reuse.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# Copyright (c) Ansible Project
3+
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4+
# SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
name: Verify REUSE
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
branches: [main]
13+
# Run CI once per day (at 04:30 UTC)
14+
schedule:
15+
- cron: '30 4 * * *'
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Install dependencies
25+
run: |
26+
pip install reuse
27+
28+
- name: Check REUSE compliance
29+
run: |
30+
reuse lint

.reuse/dep5

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
3+
Files: changelogs/fragments/*
4+
Copyright: Ansible Project
5+
License: GPL-3.0-or-later

CHANGELOG.rst.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ See [LICENSES/GPL-3.0-or-later.txt](https://github.com/ansible-collections/commu
121121

122122
Parts of the collection are licensed under the [Apache 2.0 license](https://github.com/ansible-collections/community.docker/blob/main/LICENSES/Apache-2.0.txt). This mostly applies to files vendored from the [Docker SDK for Python](https://github.com/docker/docker-py/).
123123

124-
Most files in the collection that are not automatically generated have a machine readable `SDPX-License-Identifier:` comment denoting its respective license(s).
124+
All files have a machine readable `SDPX-License-Identifier:` comment denoting its respective license(s) or an equivalent entry in an accompanying `.license` file. Only changelog fragments (which will not be part of a release) are covered by a blanket statement in `.reuse/dep5`. This conforms to the [REUSE specification](https://reuse.software/spec/).

changelogs/changelog.yaml.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

changelogs/fragments/licenses.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- "The collection repository conforms to the `REUSE specification <https://reuse.software/spec/>`__ except for the changelog fragments (https://github.com/ansible-collections/community.docker/pull/462)."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/extra/licenses.py

+36-39
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,35 @@ def find_licenses(filename, relax=False):
2121
spdx_license_identifiers = []
2222
other_license_identifiers = []
2323
has_copyright = False
24-
with open(filename, 'r', encoding='utf-8') as f:
25-
for line in f:
26-
line = line.rstrip()
27-
if 'Copyright ' in line:
28-
has_copyright = True
29-
if 'Copyright: ' in line:
30-
print('%s: found copyright line with "Copyright:". Please remove the colon.' % (filename, ))
31-
idx = line.find('SPDX-License-Identifier: ')
32-
if idx >= 0:
33-
spdx_license_identifiers.append(line[idx + len('SPDX-License-Identifier: '):])
34-
if 'GNU General Public License' in line:
35-
if 'v3.0+' in line:
36-
other_license_identifiers.append('GPL-3.0-or-later')
37-
if 'version 3 or later' in line:
38-
other_license_identifiers.append('GPL-3.0-or-later')
39-
if 'Simplified BSD License' in line:
40-
other_license_identifiers.append('BSD-2-Clause')
41-
if 'Apache License 2.0' in line:
42-
other_license_identifiers.append('Apache-2.0')
43-
if 'PSF License' in line or 'Python-2.0' in line:
44-
other_license_identifiers.append('PSF-2.0')
45-
if 'MIT License' in line:
46-
other_license_identifiers.append('MIT')
24+
try:
25+
with open(filename, 'r', encoding='utf-8') as f:
26+
for line in f:
27+
line = line.rstrip()
28+
if 'Copyright ' in line:
29+
has_copyright = True
30+
if 'Copyright: ' in line:
31+
print('%s: found copyright line with "Copyright:". Please remove the colon.' % (filename, ))
32+
if 'SPDX-FileCopyrightText: ' in line:
33+
has_copyright = True
34+
idx = line.find('SPDX-License-Identifier: ')
35+
if idx >= 0:
36+
lic_id = line[idx + len('SPDX-License-Identifier: '):]
37+
spdx_license_identifiers.extend(lic_id.split(' OR '))
38+
if 'GNU General Public License' in line:
39+
if 'v3.0+' in line:
40+
other_license_identifiers.append('GPL-3.0-or-later')
41+
if 'version 3 or later' in line:
42+
other_license_identifiers.append('GPL-3.0-or-later')
43+
if 'Simplified BSD License' in line:
44+
other_license_identifiers.append('BSD-2-Clause')
45+
if 'Apache License 2.0' in line:
46+
other_license_identifiers.append('Apache-2.0')
47+
if 'PSF License' in line or 'Python-2.0' in line:
48+
other_license_identifiers.append('PSF-2.0')
49+
if 'MIT License' in line:
50+
other_license_identifiers.append('MIT')
51+
except Exception as exc:
52+
print('%s: error while processing file: %s' % (filename, exc))
4753
if len(set(spdx_license_identifiers)) < len(spdx_license_identifiers):
4854
print('%s: found identical SPDX-License-Identifier values' % (filename, ))
4955
if other_license_identifiers and set(other_license_identifiers) != set(spdx_license_identifiers):
@@ -61,24 +67,14 @@ def main():
6167
# The following paths are allowed to have no license identifier
6268
no_comments_allowed = [
6369
'changelogs/fragments/*.yml',
64-
'tests/sanity/extra/*.json',
65-
'tests/sanity/ignore-2.*.txt',
66-
'LICENSES/*.txt',
67-
'COPYING',
68-
]
69-
70-
# Files of this name are allowed to be empty
71-
empty_allowed = [
72-
'.keep',
73-
'__init__.py',
7470
]
7571

7672
# These files are completely ignored
7773
ignore_paths = [
78-
'CHANGELOG.rst',
79-
'changelogs/changelog.yaml',
80-
'tests/sanity/extra/licenses.py', # The strings in find_licenses() confuse this code :-)
8174
'.ansible-test-timeout.json',
75+
'.reuse/dep5',
76+
'LICENSES/*.txt',
77+
'COPYING',
8278
]
8379

8480
no_comments_allowed = [fn for pattern in no_comments_allowed for fn in glob.glob(pattern)]
@@ -91,9 +87,10 @@ def main():
9187
path = path[2:]
9288
if path in ignore_paths or path.startswith('tests/output/'):
9389
continue
94-
if os.path.basename(path) in empty_allowed:
95-
if os.stat(path).st_size == 0:
96-
continue
90+
if os.stat(path).st_size == 0:
91+
continue
92+
if not path.endswith('.license') and os.path.exists(path + '.license'):
93+
path = path + '.license'
9794
valid_licenses_for_path = valid_licenses
9895
if path.startswith('plugins/') and not path.startswith(('plugins/modules/', 'plugins/module_utils/')):
9996
valid_licenses_for_path = [license for license in valid_licenses if license == 'GPL-3.0-or-later']
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: 2022, Felix Fontein <felix@fontein.de>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/ignore-2.10.txt.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/ignore-2.11.txt.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/ignore-2.12.txt.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/ignore-2.13.txt.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/ignore-2.14.txt.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

tests/sanity/ignore-2.9.txt.license

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
SPDX-License-Identifier: GPL-3.0-or-later
3+
SPDX-FileCopyrightText: Ansible Project

0 commit comments

Comments
 (0)