Skip to content

Commit 3c532f0

Browse files
Merge pull request #5233 from aboutcode-org/add-license-detection
Update following referenced licenses and rules
2 parents 50b1ba7 + a98d3ee commit 3c532f0

19 files changed

Lines changed: 479 additions & 21 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_tag: yes
4+
---
5+
6+
license: LGPL/MPL
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_notice: yes
4+
---
5+
6+
dual-licensed under the LGPL and the MPL.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_notice: yes
4+
---
5+
6+
Cairo is free software and is available to be redistributed and/or
7+
modified under the terms of either the GNU Lesser General Public
8+
License (LGPL) version 2.1 or the Mozilla Public License (MPL) version
9+
1.1.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_notice: yes
4+
referenced_filenames:
5+
- COPYING-LGPL-2.1
6+
- COPYING-MPL-1.1
7+
---
8+
9+
is free software.
10+
11+
Every source file in the implementation of is available to be
12+
redistributed and/or modified under the terms of either the GNU Lesser
13+
General Public License (LGPL) version 2.1 or the Mozilla Public
14+
License (MPL) version 1.1. Some files are available under more
15+
liberal terms, but we believe that in all cases, each file may be used
16+
under either the LGPL or the MPL.
17+
18+
See the following files in this directory for the precise terms and
19+
conditions of either license:
20+
21+
COPYING-LGPL-2.1
22+
COPYING-MPL-1.1
23+
24+
Please see each file in the implementation for copyright and licensing
25+
information, (in the opening comment of each file).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_reference: yes
4+
referenced_filenames:
5+
- COPYING
6+
---
7+
8+
* The code in the patch is copyright under the LGPL, but
9+
* has been relicensed under the LGPL/MPL dual license for inclusion
10+
* into (see COPYING).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_notice: yes
4+
referenced_filenames:
5+
- COPYING
6+
---
7+
8+
Cairo is released under the terms of either the {{GNU Lesser General Public
9+
License version 2.1}}, or the terms of the {{Mozilla Public License version 1.1}}.
10+
11+
See the [`COPYING`](./COPYING) document for more information.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_notice: yes
4+
---
5+
6+
Cairo is released under the terms of either the {{GNU Lesser General Public
7+
License version 2.1}}, or the terms of the {{Mozilla Public License version 1.1}}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
license_expression: lgpl-2.1 OR mpl-1.1
3+
is_license_reference: yes
4+
---
5+
6+
New license: LGPL/MPL
7+
8+
The most significant news with this release is that the license of
9+
cairo has changed. It is now dual-licensed under the LGPL and the
10+
MPL. For details see the COPYING file as well as COPYING-LGPL-2.1 and
11+
COPYING-MPL-1.1.

src/licensedcode/detection.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ def logger_debug(*args):
6060

6161
logger = logging.getLogger(__name__)
6262

63-
if TRACE:
63+
if (
64+
TRACE
65+
or TRACE_ANALYSIS
66+
or TRACE_REFERENCE
67+
or TRACE_IS_FUNCTIONS
68+
):
6469

65-
if (
66-
TRACE
67-
or TRACE_ANALYSIS
68-
or TRACE_IS_FUNCTIONS
69-
):
70+
logging.basicConfig(stream=sys.stdout)
71+
logger.setLevel(logging.DEBUG)
7072

71-
logging.basicConfig(stream=sys.stdout)
72-
logger.setLevel(logging.DEBUG)
73+
def logger_debug(*args):
74+
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))
7375

74-
def logger_debug(*args):
75-
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))
7676

7777
MATCHER_UNDETECTED = '5-undetected'
7878
MATCHER_UNDETECTED_ORDER = 4
@@ -1455,6 +1455,12 @@ def use_referenced_license_expression(referenced_license_expression, license_det
14551455
if same_license_keys and not same_expression:
14561456
return False
14571457

1458+
# If all the license keys of the referenced license expression already
1459+
# present in the actual license expression
1460+
# note that this preserves AND/OR expressions in the original license
1461+
if referenced_license_keys.issubset(license_keys):
1462+
return False
1463+
14581464
# when there are many license keys in an expression, and there are no
14591465
# unknown or other cases, we cannot safely conclude that we should
14601466
# follow the license in the referenced filenames. This is likely
@@ -2072,6 +2078,10 @@ def update_detection_from_referenced_files(
20722078
relation='AND',
20732079
licensing=get_cache().licensing,
20742080
))
2081+
if TRACE_REFERENCE:
2082+
logger_debug(
2083+
f'update_detection_from_referenced_files: referenced_license_expression: {referenced_license_expression}',
2084+
)
20752085

20762086
if not use_referenced_license_expression(
20772087
referenced_license_expression=referenced_license_expression,
@@ -2080,24 +2090,26 @@ def update_detection_from_referenced_files(
20802090
if TRACE_REFERENCE and referenced_resources:
20812091
paths = [
20822092
resource.path
2083-
for resource in referenced_resource
2093+
for resource in referenced_resources
20842094
]
20852095
logger_debug(
20862096
f'use_referenced_license_expression: False for '
20872097
f'resources: {paths} and '
2088-
f'license_expression: {referenced_license_expression}',
2098+
f'referenced_license_expression: {referenced_license_expression}',
2099+
f'license_detection.expression: {license_detection.license_expression}',
20892100
)
20902101
return False
20912102

20922103
if TRACE_REFERENCE and referenced_resources:
20932104
paths = [
20942105
resource.path
2095-
for resource in referenced_resource
2106+
for resource in referenced_resources
20962107
]
20972108
logger_debug(
20982109
f'use_referenced_license_expression: True for '
20992110
f'resources: {paths} and '
2100-
f'license_expression: {referenced_license_expression}',
2111+
f'referenced_license_expression: {referenced_license_expression}',
2112+
f'license_detection.expression: {license_detection.license_expression}',
21012113
)
21022114

21032115
matches_to_extend = get_matches_from_detection_mappings(

src/licensedcode/plugin_license.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ def process_codebase(self, codebase, license_text=False, license_diagnostics=Fal
210210
modified = False
211211
for resource in codebase.walk(topdown=False):
212212
# follow license references to other files
213-
if TRACE:
213+
if TRACE_REFERENCE:
214214
license_expressions_before = resource.detected_license_expression
215215

216216
try:
217217
modified = add_referenced_filenames_license_matches_for_detections(resource, codebase)
218218
except Exception as e:
219219
raise Exception(f"Failed to process resource: {resource!r}") from e
220220

221-
if TRACE and modified:
221+
if TRACE_REFERENCE and modified:
222222
license_expressions_after = resource.detected_license_expression
223223
logger_debug(
224224
f'add_referenced_filenames_license_matches: Modified:',
@@ -291,6 +291,11 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase):
291291
)
292292
continue
293293

294+
if TRACE_REFERENCE:
295+
logger_debug(
296+
f'add_referenced_license_matches: referenced_filenames: {referenced_filenames}',
297+
)
298+
294299
is_modified = update_detection_from_referenced_files(
295300
referenced_filenames=referenced_filenames,
296301
license_detection_mapping=license_detection_mapping,

0 commit comments

Comments
 (0)