Improve license check script (#4196)

This commit is contained in:
Huxing Zhang 2019-08-04 10:39:50 +08:00 committed by GitHub
parent f65816db6f
commit 9bf51e5ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

2
.gitignore vendored
View File

@ -34,4 +34,4 @@ Thumbs.db
.flattened-pom.xml
# license check result
license-list.txt
license-list

View File

@ -3,7 +3,7 @@
APPEND_ARG=""
FOLDER="./"
LINE_FLAG="=============================================="
TARGET_FILE="./license-list.txt"
TARGET_FILE="./license-list"
red=`tput setaf 1`
green=`tput setaf 2`
@ -57,9 +57,13 @@ missingLicense=(
for i in "${missingLicense[@]}"; do
search=`echo $i |awk -F: '{print $1}'`
replace=`echo $i |awk -F: '{print $2}'`
sed -i -e 's/'"$search"'/'"$replace"'/g' $TARGET_FILE
sed -i.bak 's/'"$search"'/'"$replace"'/g' $TARGET_FILE
done
if [ -f $TARGET_FILE.bak ]; then
rm -rf $TARGET_FILE.bak
fi
check_unknown_license=`cat $TARGET_FILE | grep "Unknown license"`
#checking unknown license
@ -78,6 +82,12 @@ allowLicense=(
"MIT"
"The 3-Clause BSD License"
"Public domain"
"JSR.*107"
"Common Public License Version 1.0"
"org.scijava:native-lib-loader"
"org.codehaus.woodstox:stax2-api"
"wsdl4j:wsdl4j"
"net.jcip:jcip-annotations"
)
#filter allow license
@ -87,10 +97,12 @@ for i in "${allowLicense[@]}"; do
license_need_check=`echo "$license_need_check"|grep -vi "$i"`
done
if test -z "$license_need_check"
then
# remove empty lines
echo $license_need_check | sed '/^[[:space:]]*$/d' > license-need-check
if [ ! -s license-need-check ]; then
echo "${green}All dependencies license looks good${reset}"
else
echo "${red}Please check below license${reset}"
echo "$license_need_check"
fi
cat license-need-check
fi