2 # Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 # 1. Bug 722 : Jayant Madavi : JM00553988@techmahindra.com : Enhancement to use new fossology server. Had to change the variable name at # couple of places, while scanning the variable name was adding curl as a license.
20 # 2. Bug 542 : Jayant Madavi, Mrityunjay Yadav : JM00553988@techmahindra.com : 24-jul-2019 : Enhancement to raise exit in case files modified or added does # not contain license.
23 echo GERRIT BRANCH is
$GERRIT_BRANCH
24 dpkg
-l wget
&>/dev
/null ||sudo apt-get
install -y wget
25 dpkg
-l curl
&>/dev
/null ||sudo apt-get
install -y curl
26 #Curl can be used instead of wget:
27 #curl -s -X POST -d @$file https://osm.etsi.org/fossology/?mod=agent_nomos_once
35 RE
="FATAL: your file did not get passed through"
37 for file in $
(git
diff --name-only origin
/$GERRIT_BRANCH -- .
':!*.png' ':!*.jp*g' ':!*.gif' ':!*.json'); do
40 licnse
=$
(curl
-s -X POST
-H 'Accept: text' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: multipart/form-data' -H 'cache-control: no-cache' -F "file_input=@\"$file\"" -F 'showheader=1' https
://fossology-osm.etsi.org
/?mod
=agent_nomos_once |
grep "A one shot license analysis shows the following license(s) in file"|
sed -n 's:.*<strong>\(.*\)</strong>.*:\1:p' |
xargs)
41 result
=$
(echo $licnse |
grep "$RE")
42 if [ -n "$result" ]; then
43 # possibly we have exceeded the post rate
45 licnse
=$
(curl
-s -X POST
-H 'Accept: text' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: multipart/form-data' -H 'cache-control: no-cache' -F "file_input=@\"$file\"" -F 'showheader=1' https
://fossology-osm.etsi.org
/?mod
=agent_nomos_once |
grep "A one shot license analysis shows the following license(s) in file"|
sed -n 's:.*<strong>\(.*\)</strong>.*:\1:p' |
xargs)
48 licnse
="No_license_found"
56 apache
=$
((apache
+ 1))
59 nolicense
=$
((nolicense
+ 1))
66 echo "BAD LICENSE ON FILE $file"
72 if [ $other -gt 0 ]; then
73 echo "FATAL: Non-apache licenses detected"
77 if [ $nolicense -gt 0 ]; then
78 echo "FATAL: Unlicensed files found"