-
Notifications
You must be signed in to change notification settings - Fork 29.7k
/
license-builder.sh
executable file
Β·96 lines (78 loc) Β· 3.92 KB
/
license-builder.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -e
rootdir="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
licensefile="${rootdir}/LICENSE"
licensehead="$(sed '/^- /,$d' ${licensefile})"
tmplicense="${rootdir}/~LICENSE.$$"
echo -e "$licensehead" > $tmplicense
# addlicense <library> <location> <license text>
function addlicense {
echo "
- ${1}, located at ${2}, is licensed as follows:
\"\"\"
$(echo -e "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D')
\"\"\"\
" >> $tmplicense
}
if ! [ -d "${rootdir}/deps/icu/" ] && ! [ -d "${rootdir}/deps/icu-small/" ]; then
echo "ICU not installed, run configure to download it, e.g. ./configure --with-intl=small-icu --download=icu"
exit 1
fi
# Dependencies bundled in distributions
addlicense "c-ares" "deps/cares" \
"$(sed -e '/^ \*\/$/,$d' -e '/^$/d' -e 's/^[/ ]\* *//' ${rootdir}/deps/cares/src/ares_init.c)"
addlicense "HTTP Parser" "deps/http_parser" "$(cat deps/http_parser/LICENSE-MIT)"
if [ -f "${rootdir}/deps/icu/LICENSE" ]; then
# ICU 57 and following. Drop the BOM
addlicense "ICU" "deps/icu" \
"$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a \
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu/LICENSE)"
elif [ -f "${rootdir}/deps/icu/license.html" ]; then
# ICU 56 and prior
addlicense "ICU" "deps/icu" \
"$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a \
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu/license.html)"
elif [ -f "${rootdir}/deps/icu-small/LICENSE" ]; then
# ICU 57 and following. Drop the BOM
addlicense "ICU" "deps/icu-small" \
"$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a \
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu-small/LICENSE)"
elif [ -f "${rootdir}/deps/icu-small/license.html" ]; then
# ICU 56 and prior
addlicense "ICU" "deps/icu-small" \
"$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a \
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu-small/license.html)"
else
echo "Could not find an ICU license file."
exit 1
fi
addlicense "libuv" "deps/uv" "$(cat ${rootdir}/deps/uv/LICENSE)"
addlicense "OpenSSL" "deps/openssl" \
"$(sed -e '/^ \*\/$/,$d' -e '/^ [^*].*$/d' -e '/\/\*.*$/d' -e '/^$/d' -e 's/^[/ ]\* *//' ${rootdir}/deps/openssl/openssl/LICENSE)"
addlicense "Punycode.js" "lib/punycode.js" \
"$(curl -sL https://raw.githubusercontent.com/bestiejs/punycode.js/master/LICENSE-MIT.txt)"
addlicense "V8" "deps/v8" "$(cat ${rootdir}/deps/v8/LICENSE)"
addlicense "zlib" "deps/zlib" \
"$(sed -e '/The data format used by the zlib library/,$d' -e 's/^\/\* *//' -e 's/^ *//' ${rootdir}/deps/zlib/zlib.h)"
# npm
addlicense "npm" "deps/npm" "$(cat ${rootdir}/deps/npm/LICENSE)"
# Build tools
addlicense "GYP" "tools/gyp" "$(cat ${rootdir}/tools/gyp/LICENSE)"
addlicense "marked" "tools/doc/node_modules/marked" \
"$(cat ${rootdir}/tools/doc/node_modules/marked/LICENSE)"
# Testing tools
addlicense "cpplint.py" "tools/cpplint.py" \
"$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' ${rootdir}/tools/cpplint.py | tail -n +3)"
addlicense "ESLint" "tools/eslint" "$(cat ${rootdir}/tools/eslint/LICENSE)"
addlicense "gtest" "deps/gtest" "$(cat ${rootdir}/deps/gtest/LICENSE)"
addlicense "node-weak" "test/gc/node_modules/weak" \
"$(cat ${rootdir}/test/gc/node_modules/weak/LICENSE)"
# v8_inspector
addlicense "v8_inspector" "deps/v8_inspector/third_party/v8_inspector" \
"$(cat ${rootdir}/deps/v8_inspector/third_party/v8_inspector/LICENSE)"
# Build tooling for v8_inspector
addlicense "jinja2" "deps/v8_inspector/third_party/jinja2" \
"$(cat ${rootdir}/deps/v8_inspector/third_party/jinja2/LICENSE)"
addlicense "markupsafe" "deps/v8_inspector/third_party/markupsafe" \
"$(cat ${rootdir}/deps/v8_inspector/third_party/markupsafe/LICENSE)"
mv $tmplicense $licensefile