github.com/ledgerwatch/erigon-lib@v1.0.0/tools/licenses_check.sh (about) 1 #!/bin/bash 2 3 scriptDir=$(dirname "${BASH_SOURCE[0]}") 4 scriptName=$(basename "${BASH_SOURCE[0]}") 5 projectDir="$scriptDir/.." 6 goLicensesVersion="v1.6.0" 7 8 if [[ "$1" == "--install-deps" ]] 9 then 10 go install "github.com/google/go-licenses@$goLicensesVersion" 11 exit 12 fi 13 14 if ! which go-licenses > /dev/null 15 then 16 echo "go-licenses tool is not found, install it with:" 17 echo " go install github.com/google/go-licenses@$goLicensesVersion" 18 exit 19 fi 20 21 # enable build tags to cover maximum .go files 22 export GOFLAGS="-tags=gorules,linux,tools" 23 24 output=$(find "$projectDir" -type 'd' -maxdepth 1 \ 25 -not -name ".*" \ 26 -not -name tools \ 27 -not -name build \ 28 | xargs go-licenses report 2>&1 \ 29 `# exceptions` \ 30 | grep -v "erigon-lib has empty version" `# self` \ 31 | grep -v "golang.org/x/" `# a part of Go` \ 32 | grep -v "crawshaw.io/sqlite" `# ISC` \ 33 | grep -v "erigon-lib/sais" `# MIT` \ 34 | grep -v "github.com/anacrolix/go-libutp" `# MIT` \ 35 | grep -v "github.com/anacrolix/mmsg" `# MPL-2.0` \ 36 | grep -v "github.com/anacrolix/multiless" `# MPL-2.0` \ 37 | grep -v "github.com/anacrolix/sync" `# MPL-2.0` \ 38 | grep -v "github.com/anacrolix/upnp" `# MPL-2.0` \ 39 | grep -v "github.com/go-llsqlite/adapter" `# MPL-2.0` \ 40 | grep -v "github.com/go-llsqlite/crawshaw" `# ISC` \ 41 | grep -v "github.com/consensys/gnark-crypto" `# Apache-2.0` \ 42 | grep -v "github.com/erigontech/mdbx-go" `# Apache-2.0` \ 43 | grep -v "github.com/ledgerwatch/secp256k1" `# BSD-3-Clause` \ 44 | grep -v "github.com/RoaringBitmap/roaring" `# Apache-2.0` \ 45 | grep -v "github.com/!roaring!bitmap/roaring" `# Apache-2.0` \ 46 | grep -v "pedersen_hash" `# Apache-2.0` \ 47 `# approved licenses` \ 48 | grep -Ev "Apache-2.0$" \ 49 | grep -Ev "BSD-2-Clause$" \ 50 | grep -Ev "BSD-3-Clause$" \ 51 | grep -Ev "ISC$" \ 52 | grep -Ev "MIT$" \ 53 | grep -Ev "MPL-2.0$" \ 54 ) 55 56 if [[ -n "$output" ]] 57 then 58 echo "ERROR: $scriptName has found issues!" 1>&2 59 echo "ERROR: If it is a false positive, add it to the exceptions list in the script:" 1>&2 60 echo "$output" 1>&2 61 exit 1 62 fi