X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=tools%2Flicense_scan.sh;h=b20bb0afb9002c8c8e5706a70ebf520f742de5f4;hb=3c3ea19446f994a4b1e97b3ef10a1062a2e3ad21;hp=47106e0e001cd98a2bbb55cf63d2bac09d031394;hpb=c7f35240b0fddd27e15e4acb0e79ac74cba090eb;p=osm%2Fdevops.git diff --git a/tools/license_scan.sh b/tools/license_scan.sh index 47106e0e..b20bb0af 100755 --- a/tools/license_scan.sh +++ b/tools/license_scan.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U. # @@ -13,34 +14,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -#!/bin/sh - -echo GERRIT BRANCH is $GERRIT_BRANCH -dpkg -l wget &>/dev/null ||sudo apt-get install -y wget -dpkg -l curl &>/dev/null ||sudo apt-get install -y curl -#Curl can be used instead of wget: -#curl -s -X POST -d @$file https://osm.etsi.org/fossology/?mod=agent_nomos_once apache=0 nolicense=0 other=0 - +exception_list="':(exclude)*.pdf' ':(exclude)*.png' ':(exclude)*.jpeg' ':(exclude)*.jpg' ':(exclude)*.gif' ':(exclude)*.json' ':(exclude)*.ico' ':(exclude)*.svg' ':(exclude)*.tiff'" git fetch -RE="FATAL: your file did not get passed through" - -for file in $(git diff --name-only origin/$GERRIT_BRANCH); do +for file in $(echo ${exception_list} | xargs git diff --name-only origin/$GERRIT_BRANCH -- . ); do + license="No Apache license found" if [ -f $file ]; then if [ -s $file ]; then - license=$(wget -qO - --post-file $file https://osm.etsi.org/fossology/?mod=agent_nomos_once |sed "s/^[ \t]*//;s/[ \t]*$//") - result=$(echo $license | grep "$RE") - if [ -n "$result" ]; then - # possibly we have exceeded the post rate - sleep 10 - license=$(wget -qO - --post-file $file https://osm.etsi.org/fossology/?mod=agent_nomos_once |sed "s/^[ \t]*//;s/[ \t]*$//") + if [ $(grep -c "http://www.apache.org/licenses/LICENSE-2.0" $file) -ge 1 ] ; then + license="Apache-2.0" fi - else - license="No_license_found" fi else license="DELETED" @@ -50,13 +37,11 @@ for file in $(git diff --name-only origin/$GERRIT_BRANCH); do "Apache-2.0") apache=$((apache + 1)) ;; - "No_license_found") + No*) nolicense=$((nolicense + 1)) ;; "DELETED") ;; - "FATAL:*") - ;; *) echo "BAD LICENSE ON FILE $file" other=$((other + 1)) @@ -64,13 +49,10 @@ for file in $(git diff --name-only origin/$GERRIT_BRANCH); do esac done -if [ $other -gt 0 ]; then - echo "FATAL: Non-apache licenses detected" - exit 2 -fi if [ $nolicense -gt 0 ]; then - echo "WARNING: Unlicensed files found" + echo "FATAL: Files without apache license found" + exit 2 fi exit 0