forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
licenses.sh
executable file
·81 lines (71 loc) · 3.53 KB
/
licenses.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -e
shopt -s nullglob
echo "Verifying license script is still happy..."
echo "Using pub from `which pub`, dart from `which dart`"
exitStatus=0
dart --version
# These files trip up the script on Mac OS X.
find . -name ".DS_Store" -exec rm {} \;
(cd flutter/tools/licenses; pub get; dart --enable-asserts lib/main.dart --src ../../.. --out ../../../out/license_script_output --golden ../../ci/licenses_golden)
for f in out/license_script_output/licenses_*; do
if ! cmp -s flutter/ci/licenses_golden/$(basename $f) $f
then
echo "============================= ERROR ============================="
echo "License script got different results than expected for $f."
echo "Please rerun the licenses script locally to verify that it is"
echo "correctly catching any new licenses for anything you may have"
echo "changed, and then update this file:"
echo " flutter/sky/packages/sky_engine/LICENSE"
echo "For more information, see the script in:"
echo " https://github.com/flutter/engine/tree/master/tools/licenses"
echo ""
diff -U 6 flutter/ci/licenses_golden/$(basename $f) $f
echo "================================================================="
echo ""
exitStatus=1
fi
done
echo "Verifying license tool signature..."
if ! cmp -s flutter/ci/licenses_golden/tool_signature out/license_script_output/tool_signature
then
echo "============================= ERROR ============================="
echo "The license tool signature has changed. This is expected when"
echo "there have been changes to the license tool itself. Licenses have"
echo "been re-computed for all components. If only the license script has"
echo "changed, no diffs are typically expected in the output of the"
echo "script. Verify the output, and if it looks correct, update the"
echo "license tool signature golden file:"
echo " ci/licenses_golden/tool_signature"
echo "For more information, see the script in:"
echo " https://github.com/flutter/engine/tree/master/tools/licenses"
echo ""
diff -U 6 flutter/ci/licenses_golden/tool_signature out/license_script_output/tool_signature
echo "================================================================="
echo ""
exitStatus=1
fi
echo "Checking license count in licenses_flutter..."
actualLicenseCount=`tail -n 1 flutter/ci/licenses_golden/licenses_flutter | tr -dc '0-9'`
expectedLicenseCount=2 # When changing this number: Update the error message below as well describing all expected license types.
if [ "$actualLicenseCount" -ne "$expectedLicenseCount" ]
then
echo "=============================== ERROR ==============================="
echo "The total license count in flutter/ci/licenses_golden/licenses_flutter"
echo "changed from $expectedLicenseCount to $actualLicenseCount."
echo "It's very likely that this is an unintentional change. Please"
echo "double-check that all newly added files have a BSD-style license"
echo "header with the following copyright:"
echo " Copyright 2013 The Flutter Authors. All rights reserved."
echo "Files in 'third_party/txt' may have an Apache license header instead."
echo "If you're absolutely sure that the change in license count is"
echo "intentional, update 'flutter/ci/licenses.sh' with the new count."
echo "================================================================="
echo ""
exitStatus=1
fi
if [ "$exitStatus" -eq "0" ]
then
echo "Licenses are as expected."
fi
exit $exitStatus