licenses.sh 3.5 KB
Newer Older
1
#!/bin/bash
2
set -e
3 4
shopt -s nullglob

5
echo "Verifying license script is still happy..."
D
Dan Field 已提交
6 7
echo "Using pub from `which pub`, dart from `which dart`"

S
stuartmorgan 已提交
8 9
exitStatus=0

D
Dan Field 已提交
10 11
dart --version

12 13 14
# These files trip up the script on Mac OS X.
find . -name ".DS_Store" -exec rm {} \;

15
(cd flutter/tools/licenses; pub get; dart --enable-asserts lib/main.dart --src ../../.. --out ../../../out/license_script_output --golden ../../ci/licenses_golden)
16 17

for f in out/license_script_output/licenses_*; do
L
liyuqian 已提交
18
    if ! cmp -s flutter/ci/licenses_golden/$(basename $f) $f
19
    then
20
        echo "============================= ERROR ============================="
21 22 23 24 25 26 27 28
        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 ""
L
liyuqian 已提交
29
        diff -U 6 flutter/ci/licenses_golden/$(basename $f) $f
S
stuartmorgan 已提交
30 31 32
        echo "================================================================="
        echo ""
        exitStatus=1
33 34
    fi
done
35

36 37 38 39 40 41 42 43 44 45
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:"
46
    echo "  ci/licenses_golden/tool_signature"
47 48 49 50
    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
S
stuartmorgan 已提交
51 52 53
    echo "================================================================="
    echo ""
    exitStatus=1
54 55
fi

56 57
echo "Checking license count in licenses_flutter..."
actualLicenseCount=`tail -n 1 flutter/ci/licenses_golden/licenses_flutter | tr -dc '0-9'`
C
Chris Bracken 已提交
58
expectedLicenseCount=2 # When changing this number: Update the error message below as well describing all expected license types.
59 60 61 62 63 64 65 66 67 68 69 70 71

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."
S
stuartmorgan 已提交
72 73 74
    echo "================================================================="
    echo ""
    exitStatus=1
75 76
fi

S
stuartmorgan 已提交
77 78 79 80 81
if [ "$exitStatus" -eq "0" ]
then
  echo "Licenses are as expected."
fi
exit $exitStatus