-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
genDeps.sh
79 lines (71 loc) · 1.99 KB
/
genDeps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#./gradlew showAll>alllibs.txt
sort alllibs.txt |grep .jar|uniq >DEPENDENCIES_shallow.md
echo "" > DEPENDENCIES.md
echo "" > DEPENDENCIES_unknown.md
for VARIABLE in $(cat DEPENDENCIES_shallow.md)
do
LOCATION=$(locate -l 1 $VARIABLE)
FILE=$(unzip -l $LOCATION | grep LICENSE|grep -v "LICENSE.")
stringarray=($FILE)
LOCENSELOC=$(echo ${stringarray[3]})
if [ -z "$LOCENSELOC" ]
then
FILE=$(unzip -l $LOCATION | grep LICENSE|grep ".txt"|grep -v "documentation")
stringarray=($FILE)
LOCENSELOC=$(echo ${stringarray[3]})
fi
if [ -z "$LOCENSELOC" ]
then
FILE=$(unzip -l $LOCATION | grep license|grep ".txt"|grep -v "documentation")
stringarray=($FILE)
LOCENSELOC=$(echo ${stringarray[3]})
fi
if [ -z "$LOCENSELOC" ]
then
FILE=$(unzip -l $LOCATION | grep LICENSE.md)
stringarray=($FILE)
LOCENSELOC=$(echo ${stringarray[3]})
fi
if [ -z "$LOCENSELOC" ]
then
FILE=$(unzip -l $LOCATION | grep license.html)
stringarray=($FILE)
LOCENSELOC=$(echo ${stringarray[3]})
fi
if [ -z "$LOCENSELOC" ]
then
echo "$VARIABLE No license file"
TYPE="No License "
echo "$VARIABLE">> DEPENDENCIES_unknown.md
else
echo "Licance file to be used: $VARIABLE $LOCENSELOC"
#echo "Searching $VARIABLE for $LOCENSELOC"
LICENSE=$(unzip -p $LOCATION $LOCENSELOC)
TYPE=$LICENSE
if [ -z "$TYPE" ]
then
echo "$VARIABLE No license file"
TYPE="No License $LOCATION"
else
shopt -s nocasematch;
if [[ "$LICENSE" =~ "apache" ]]; then
TYPE="Apache"
#echo "Apache license found"
elif [[ "$LICENSE" =~ "MIT License" ]]; then
TYPE="MIT License"
elif [[ "$LICENSE" =~ "BSD" ]]; then
TYPE="BSD"
elif [[ "$LICENSE" =~ "W3C" ]]; then
TYPE="W3C"
elif [[ "$LICENSE" =~ "CDDL" ]]; then
TYPE="CDDL"
else
echo " $LOCATION Unknown $LICENSE"
TYPE="Unknown"
#exit 1
fi
fi
echo "$VARIABLE , $TYPE">> DEPENDENCIES.md
fi
done