forked from docker-library/tomcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·206 lines (188 loc) · 8.39 KB
/
update.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env bash
set -Eeuo pipefail
shopt -s nullglob
# docker run -it --rm buildpack-deps:curl
# curl -fsSL 'https://www.apache.org/dist/tomcat/tomcat-8/KEYS' | gpg --import
# gpg --fingerprint | grep 'Key fingerprint =' | cut -d= -f2 | sed -r 's/ +//g' | sort
declare -A gpgKeys=(
# gpg: key F22C4FED: public key "Andy Armstrong <[email protected]>" imported
# gpg: key 86867BA6: public key "Jean-Frederic Clere (jfclere) <[email protected]>" imported
# gpg: key E86E29AC: public key "kevin seguin <[email protected]>" imported
# gpg: key 307A10A5: public key "Henri Gomez <[email protected]>" imported
# gpg: key 564C17A3: public key "Mladen Turk (*** DEFAULT SIGNING KEY ***) <[email protected]>" imported
# gpg: key 7C037D42: public key "Yoav Shapira <[email protected]>" imported
# gpg: key 33C60243: public key "Mark E D Thomas <[email protected]>" imported
# gpg: key 2F6059E7: public key "Mark E D Thomas <[email protected]>" imported
# gpg: key 288584E7: public key "R�my Maucherat <[email protected]>" imported
# gpg: key 0D811BBE: public key "Yoav Shapira <[email protected]>" imported
# gpg: key 731FABEE: public key "Tim Whittington (CODE SIGNING KEY) <[email protected]>" imported
# gpg: key 0D498E23: public key "Mladen Turk (Default signing key) <[email protected]>" imported
# gpg: Total number processed: 12
[9]='
05AB33110949707C93A279E3D3EFE6B686867BA6
07E48665A34DCAFAE522E5E6266191C37C037D42
47309207D818FFD8DCD3F83F1931D684307A10A5
541FBE7D8F78B25E055DDEE13C370389288584E7
61B832AC2F1C5A90F0F9B00A1C506407564C17A3
79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED
9BA44C2621385CB966EBA586F72C284D731FABEE
A27677289986DB50844682F8ACB77FC2E86E29AC
A9C5DF4D22E99998D9875A5110C01C5A2F6059E7
DCFD35E0BF8CA7344752DE8B6FB21E8933C60243
F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
'
# gpg: key F22C4FED: public key "Andy Armstrong <[email protected]>" imported
# gpg: key 86867BA6: public key "Jean-Frederic Clere (jfclere) <[email protected]>" imported
# gpg: key E86E29AC: public key "kevin seguin <[email protected]>" imported
# gpg: key 307A10A5: public key "Henri Gomez <[email protected]>" imported
# gpg: key 564C17A3: public key "Mladen Turk (*** DEFAULT SIGNING KEY ***) <[email protected]>" imported
# gpg: key 7C037D42: public key "Yoav Shapira <[email protected]>" imported
# gpg: key 33C60243: public key "Mark E D Thomas <[email protected]>" imported
# gpg: key 2F6059E7: public key "Mark E D Thomas <[email protected]>" imported
# gpg: key 288584E7: public key "R�my Maucherat <[email protected]>" imported
# gpg: key 0D811BBE: public key "Yoav Shapira <[email protected]>" imported
# gpg: key 731FABEE: public key "Tim Whittington (CODE SIGNING KEY) <[email protected]>" imported
# gpg: key 0D498E23: public key "Mladen Turk (Default signing key) <[email protected]>" imported
# gpg: key D63011C7: public key "Violeta Georgieva Georgieva (CODE SIGNING KEY) <[email protected]>" imported
# gpg: Total number processed: 13
[8]='
05AB33110949707C93A279E3D3EFE6B686867BA6
07E48665A34DCAFAE522E5E6266191C37C037D42
47309207D818FFD8DCD3F83F1931D684307A10A5
541FBE7D8F78B25E055DDEE13C370389288584E7
61B832AC2F1C5A90F0F9B00A1C506407564C17A3
713DA88BE50911535FE716F5208B0AB1D63011C7
79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED
9BA44C2621385CB966EBA586F72C284D731FABEE
A27677289986DB50844682F8ACB77FC2E86E29AC
A9C5DF4D22E99998D9875A5110C01C5A2F6059E7
DCFD35E0BF8CA7344752DE8B6FB21E8933C60243
F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
'
# gpg: key F22C4FED: public key "Andy Armstrong <[email protected]>" imported
# gpg: key 86867BA6: public key "Jean-Frederic Clere (jfclere) <[email protected]>" imported
# gpg: key E86E29AC: public key "kevin seguin <[email protected]>" imported
# gpg: key 307A10A5: public key "Henri Gomez <[email protected]>" imported
# gpg: key 564C17A3: public key "Mladen Turk (*** DEFAULT SIGNING KEY ***) <[email protected]>" imported
# gpg: key 7C037D42: public key "Yoav Shapira <[email protected]>" imported
# gpg: key 33C60243: public key "Mark E D Thomas <[email protected]>" imported
# gpg: key 2F6059E7: public key "Mark E D Thomas <[email protected]>" imported
# gpg: key 288584E7: public key "R�my Maucherat <[email protected]>" imported
# gpg: key 0D811BBE: public key "Yoav Shapira <[email protected]>" imported
# gpg: key 731FABEE: public key "Tim Whittington (CODE SIGNING KEY) <[email protected]>" imported
# gpg: key 0D498E23: public key "Mladen Turk (Default signing key) <[email protected]>" imported
# gpg: key D63011C7: public key "Violeta Georgieva Georgieva (CODE SIGNING KEY) <[email protected]>" imported
# gpg: Total number processed: 13
[7]='
05AB33110949707C93A279E3D3EFE6B686867BA6
07E48665A34DCAFAE522E5E6266191C37C037D42
47309207D818FFD8DCD3F83F1931D684307A10A5
541FBE7D8F78B25E055DDEE13C370389288584E7
61B832AC2F1C5A90F0F9B00A1C506407564C17A3
713DA88BE50911535FE716F5208B0AB1D63011C7
79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED
9BA44C2621385CB966EBA586F72C284D731FABEE
A27677289986DB50844682F8ACB77FC2E86E29AC
A9C5DF4D22E99998D9875A5110C01C5A2F6059E7
DCFD35E0BF8CA7344752DE8B6FB21E8933C60243
F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
'
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
travisEnv=
for version in "${versions[@]}"; do
majorVersion="${version%%.*}"
versionGpgKeys=( ${gpgKeys[$majorVersion]} )
if [ "${#versionGpgKeys[@]}" -eq 0 ]; then
echo >&2 "error: missing GPG fingerprints for $majorVersion"
exit 1
fi
possibleVersions="$(
curl -fsSL --compressed "https://www-us.apache.org/dist/tomcat/tomcat-$majorVersion/" \
| grep '<a href="v'"$version." \
| sed -r 's!.*<a href="v([^"/]+)/?".*!\1!' \
| sort -rV
)"
fullVersion=
sha512=
for possibleVersion in $possibleVersions; do
if possibleSha512="$(
curl -fsSL "https://www-us.apache.org/dist/tomcat/tomcat-$majorVersion/v$possibleVersion/bin/apache-tomcat-$possibleVersion.tar.gz.sha512" \
| cut -d' ' -f1
)" && [ -n "$possibleSha512" ]; then
fullVersion="$possibleVersion"
sha512="$possibleSha512"
break
fi
done
if [ -z "$fullVersion" ]; then
echo >&2 "error: failed to find latest release for $version"
exit 1
fi
echo "$version: $fullVersion ($sha512)"
for javaDir in "$version"/{jre,jdk}{8,11,12,13}/; do
javaDir="${javaDir%/}"
javaVariant="$(basename "$javaDir")"
javaVersion="${javaVariant#jdk}"
javaVersion="${javaVersion#jre}" # "11", "8"
javaVariant="${javaVariant%$javaVersion}" # "jdk", "jre"
# all variants in reverse alphabetical order followed by OpenJDK
for vendorDir in "$javaDir"/{corretto,adoptopenjdk-{openj9,hotspot},openjdk{-slim,-oracle,}}/; do
vendorDir="${vendorDir%/}"
vendor="$(basename "$vendorDir")"
[ -d "$vendorDir" ] || continue
template=
baseImage=
case "$vendor" in
openjdk | openjdk-slim)
template='apt'
baseImage="openjdk:$javaVersion-$javaVariant"
if [ "$vendor" = 'openjdk-slim' ]; then
baseImage+='-slim'
fi
;;
openjdk-oracle)
template='yum'
baseImage="openjdk:$javaVersion-$javaVariant-oracle"
;;
adoptopenjdk-hotspot | adoptopenjdk-openj9)
template='apt'
adoptVariant="${vendor#adoptopenjdk-}"
baseImage="adoptopenjdk:$javaVersion-$javaVariant-$adoptVariant"
;;
corretto)
template='yum'
baseImage="amazoncorretto:$javaVersion"
;;
esac
if [ -z "$template" ]; then
echo >&2 "error: cannot determine template for '$vendorDir'"
exit 1
fi
if [ -z "$baseImage" ]; then
echo >&2 "error: cannot determine base image for '$vendorDir'"
exit 1
fi
echo " - $vendorDir: $baseImage ($template)"
sed -r \
-e 's/^(ENV TOMCAT_VERSION) .*/\1 '"$fullVersion"'/' \
-e 's/^(FROM) .*/\1 '"$baseImage"'/' \
-e 's/^(ENV TOMCAT_MAJOR) .*/\1 '"$majorVersion"'/' \
-e 's/^(ENV TOMCAT_SHA512) .*/\1 '"$sha512"'/' \
-e 's/^(ENV GPG_KEYS) .*/\1 '"${versionGpgKeys[*]}"'/' \
"Dockerfile-$template.template" \
> "$vendorDir/Dockerfile"
travisEnv='\n - '"CONTEXT=$vendorDir$travisEnv"
done
done
done
travis="$(awk -v 'RS=\n\n' -v travisEnv="$travisEnv" '$1 == "env:" { $0 = "env:" travisEnv } { printf "%s%s", $0, RS }' .travis.yml)"
cat <<<"$travis" > .travis.yml