Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 2cd9b41

Browse files
Hixiechinmaygarde
authored andcommitted
Select MPL instead of LGPL (#7991)
1 parent 629c0d8 commit 2cd9b41

File tree

8 files changed

+1486
-1030
lines changed

8 files changed

+1486
-1030
lines changed

ci/licenses_golden/licenses_skia

Lines changed: 468 additions & 503 deletions
Large diffs are not rendered by default.

ci/licenses_golden/tool_signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: 293c762c71d027f77cf88deb80f9e78e
1+
Signature: 91b3b5b8c1ef9e911fd65b636d009be8
22

sky/packages/sky_engine/LICENSE

Lines changed: 467 additions & 502 deletions
Large diffs are not rendered by default.

tools/licenses/README.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ cd flutter/ci/licenses_golden
1010
patch -p2 < my/patch/file
1111
```
1212

13-
## Regenerate License Files (Only works on Linux)
14-
To update the golden license files, make sure you've rebased your branch to the latest upstream master and then run the following in this directory:
13+
## Check for license changes (Only works on Linux)
14+
15+
This script has two sets of output files: "goldens", which describe
16+
the current license state of the repository, and the actual real
17+
LICENSE file, which is what matters.
18+
19+
We look at changes to the goldens to determine if there are any actual
20+
changes to the licenses.
21+
22+
To update the goldens, make sure you've rebased your branch to the
23+
latest upstream master and then run the following in this directory:
1524

1625
```
1726
pub get
@@ -20,14 +29,37 @@ rm -rf ../../../out/licenses
2029
dart lib/main.dart --src ../../.. --out ../../../out/licenses --golden ../../ci/licenses_golden
2130
```
2231

23-
Then copy any affected files from `../../../out/licenses` to `../../ci/licenses_golden` and add them to your change.
32+
In order for the license script to work correctly, you need to remove
33+
any untracked files inside `engine/src` (the buildroot), not just
34+
`engine/src/flutter`.
35+
36+
Once the script has finished, copy any affected files from
37+
`../../../out/licenses` to `../../ci/licenses_golden` and add them to
38+
your change, and examine the diffs to see what changed.
39+
40+
```
41+
cp ../../../out/licenses/* ../../ci/licenses_golden
42+
git diff
43+
```
44+
45+
If the only changes are to what files are included, then you're good
46+
to go. However, if any of the _licenses_ changed, whether new licenses
47+
are added, old ones removed, or any have their content changed in
48+
_any_ way (including, e.g., whitespace changes), or if the affected
49+
libraries change, **you must update the actual license file**.
2450

25-
The `sky/packages/sky_engine/LICENSE` file is included in product releases and should be updated any time the golden file changes in a way that involves changes to anything other than the FILE lines. To update this file, run:
51+
The `sky/packages/sky_engine/LICENSE` file is the one actually
52+
included in product releases and the one that should be updated any
53+
time the golden file changes in a way that involves changes to
54+
anything other than the `FILE` lines. To update this file, run:
2655

2756
```
2857
pub get
2958
gclient sync
3059
dart lib/main.dart --release --src ../../.. --out ../../../out/licenses > ../../sky/packages/sky_engine/LICENSE
3160
```
3261

33-
**In order for the license script to work, please remove all untracked files inside `engine/src` (not just `engine/src/flutter`)**
62+
The bots do not verify that you did this step, it's important that you
63+
do it! When reviewing patches, if you see a change to the golden
64+
files, check to see if there's a corresponding change to the LICENSE
65+
file!

tools/licenses/data/mozilla-1.1

Lines changed: 469 additions & 0 deletions
Large diffs are not rendered by default.

tools/licenses/lib/licenses.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ abstract class License implements Comparable<License> {
269269
body = system.File('data/academic-3.0').readAsStringSync();
270270
type = LicenseType.afl;
271271
break;
272+
case 'Mozilla Public License:1.1':
273+
body = system.File('data/mozilla-1.1').readAsStringSync();
274+
type = LicenseType.mpl;
275+
break;
272276
case 'http://mozilla.org/MPL/2.0/:2.0':
273277
body = system.File('data/mozilla-2.0').readAsStringSync();
274278
type = LicenseType.mpl;

tools/licenses/lib/main.dart

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
11841184
result.addAll(licenses);
11851185
progress.advance(success: true);
11861186
} catch (e, stack) {
1187-
system.stderr.writeln('error searching for copyright in: ${file.io}\n$e');
1187+
system.stderr.writeln('\nerror searching for copyright in: ${file.io}\n$e');
11881188
if (e is! String)
11891189
system.stderr.writeln(stack);
11901190
system.stderr.writeln('\n');
@@ -2256,6 +2256,9 @@ Future<void> _collectLicensesForComponent(_RepositoryDirectory componentRoot, {
22562256

22572257
final List<License> licenses = Set<License>.from(componentRoot.getLicenses(progress).toList()).toList();
22582258

2259+
if (progress.hadErrors)
2260+
throw 'Had failures while collecting licenses.';
2261+
22592262
sink.writeln('UNUSED LICENSES:\n');
22602263
final List<String> unusedLicenses = licenses
22612264
.where((License license) => !license.isUsed)
@@ -2268,6 +2271,38 @@ Future<void> _collectLicensesForComponent(_RepositoryDirectory componentRoot, {
22682271
sink.writeln('USED LICENSES:\n');
22692272
final List<License> usedLicenses = licenses.where((License license) => license.isUsed).toList();
22702273
final List<String> output = usedLicenses.map((License license) => license.toString()).toList();
2274+
for (int index = 0; index < output.length; index += 1) {
2275+
// The strings we look for here are strings which we do not expect to see in
2276+
// any of the licenses we use. They either represent examples of misparsing
2277+
// licenses (issues we've previously run into and fixed), or licenses we
2278+
// know we are trying to avoid (e.g. the GPL, or licenses that only apply to
2279+
// test content which shouldn't get built at all).
2280+
// If you find that one of these tests is getting hit, and it's not obvious
2281+
// to you why the relevant license is a problem, please ask around (e.g. try
2282+
// asking Hixie). Do not merely remove one of these checks, sometimes the
2283+
// issues involved are relatively subtle.
2284+
if (output[index].contains('Version: MPL 1.1/GPL 2.0/LGPL 2.1'))
2285+
throw 'Unexpected trilicense block found in: ${usedLicenses[index].origin}';
2286+
if (output[index].contains('The contents of this file are subject to the Mozilla Public License Version'))
2287+
throw 'Unexpected MPL block found in: ${usedLicenses[index].origin}';
2288+
if (output[index].contains('You should have received a copy of the GNU'))
2289+
throw 'Unexpected GPL block found in: ${usedLicenses[index].origin}';
2290+
if (output[index].contains('BoringSSL is a fork of OpenSSL'))
2291+
throw 'Unexpected legacy BoringSSL block found in: ${usedLicenses[index].origin}';
2292+
if (output[index].contains('Contents of this folder are ported from'))
2293+
throw 'Unexpected block found in: ${usedLicenses[index].origin}';
2294+
if (output[index].contains('https://github.com/w3c/web-platform-tests/tree/master/selectors-api'))
2295+
throw 'Unexpected W3C content found in: ${usedLicenses[index].origin}';
2296+
if (output[index].contains('http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html'))
2297+
throw 'Unexpected W3C copyright found in: ${usedLicenses[index].origin}';
2298+
if (output[index].contains('It is based on commit'))
2299+
throw 'Unexpected content found in: ${usedLicenses[index].origin}';
2300+
if (output[index].contains('The original code is covered by the dual-licensing approach described in:'))
2301+
throw 'Unexpected old license reference found in: ${usedLicenses[index].origin}';
2302+
if (output[index].contains('must choose'))
2303+
throw 'Unexpected indecisiveness found in: ${usedLicenses[index].origin}';
2304+
}
2305+
22712306
output.sort();
22722307
sink.writeln(output.join('\n\n'));
22732308
sink.writeln('Total license count: ${licenses.length}');
@@ -2396,17 +2431,3 @@ Future<void> main(List<String> arguments) async {
23962431
system.exit(1);
23972432
}
23982433
}
2399-
2400-
// Sanity checks:
2401-
//
2402-
// The following substrings shouldn't be in the output:
2403-
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
2404-
// The contents of this file are subject to the Mozilla Public License Version
2405-
// You should have received a copy of the GNU
2406-
// BoringSSL is a fork of OpenSSL
2407-
// Contents of this folder are ported from
2408-
// https://github.com/w3c/web-platform-tests/tree/master/selectors-api
2409-
// It is based on commit
2410-
// The original code is covered by the dual-licensing approach described in:
2411-
// http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
2412-
// must choose

tools/licenses/lib/patterns.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,14 +980,14 @@ final List<MultipleVersionedLicenseReferencePattern> csReferencesByUrl = <Multip
980980
MultipleVersionedLicenseReferencePattern(
981981
firstPrefixIndex: 1,
982982
indentPrefixIndex: 2,
983-
licenseIndices: const <int>[3],
984-
versionIndicies: const <int, int>{ 3:4 },
983+
licenseIndices: const <int>[3], // 5 is lgpl, which we're actively not selecting
984+
versionIndicies: const <int, int>{ 3:4 }, // 5:6 for lgpl
985985
pattern: RegExp(
986986
kIndent +
987987
r'(?:Version: [GMPL/012. ]+ *\n'
988988
r'^(?:(?:\1\2? *)? *\n)*'
989-
r'^\1\2)?The contents of this file are subject to the Mozilla Public License Version *\n'
990-
r'^\1\2(?:1\.1) \(the "License"\); you may not use this file except in compliance with *\n'
989+
r'^\1\2)?The contents of this file are subject to the (Mozilla Public License) Version *\n'
990+
r'^\1\2(1\.1) \(the "License"\); you may not use this file except in compliance with *\n'
991991
r'^\1\2the License\. +You may obtain a copy of the License at *\n'
992992
r'^\1\2http://www\.mozilla\.org/MPL/ *\n'
993993
r'^(?:(?:\1\2? *)? *\n)*'

0 commit comments

Comments
 (0)