-
Notifications
You must be signed in to change notification settings - Fork 1
/
licenses.sh
executable file
·63 lines (50 loc) · 1.19 KB
/
licenses.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
#!/bin/bash
#
# Gather licenses for binary releases
#
devdeps="
"
manualdeps="
github.com/snowballstem/snowball:internal/snowball/snowball/COPYING
github.com/jenil/chota:cmd/lrmon/static/LICENSE.chota.txt
"
TARGET=licenses
mkdir -p $TARGET
NOTICE=$TARGET/NOTICE
cp LICENSE $TARGET
echo "
Letarette is licensed under the Apache v2.0 License.
Letarette uses the following fine packages:
---
" > $NOTICE
while read -r dep; do
if [ "$dep" == "" ]; then
continue
fi
IFS=':' read -r -a split <<< "$dep"
pkg="${split[0]}"
lic="${split[1]}"
echo $pkg >> $NOTICE
mkdir -p "$TARGET/$pkg"
cp "$lic" "$TARGET/$pkg"
done <<< "$manualdeps"
go mod vendor
licenses=`find vendor -name LICENSE | sed -e 's/vendor\///'`
for lic in $licenses; do
pkg=`echo $lic | sed -e 's/\/LICENSE//'`
for devdep in $devdeps; do
if grep -q "^$devdep" <<< "$pkg"; then
continue 2
fi
done
if go mod why -m $pkg | grep -q "does not need"; then
continue
fi
echo $pkg >> $NOTICE
mkdir -p "$TARGET/$pkg"
cp "vendor/$lic" "$TARGET/$pkg"
done
echo "
---
Find the license for each package in the corresponding subdirectory.
" >> $NOTICE