forked from docker-library/tomcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·51 lines (43 loc) · 1.48 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
#!/bin/bash
set -eo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
travisEnv=
for version in "${versions[@]}"; do
majorVersion="${version%%.*}"
fullVersion="$(curl -fsSL --compressed "https://www.apache.org/dist/tomcat/tomcat-$majorVersion/" | grep '<a href="v'"$version." | sed -r 's!.*<a href="v([^"/]+)/?".*!\1!' | sort -V | tail -1)"
for variant in "$version"/*/; do
variant="$(basename "$variant")"
javaVariant="${variant%%-*}"
subVariant="${variant#$javaVariant-}"
[ "$subVariant" != "$variant" ] || subVariant=
baseImage='java'
case "$javaVariant" in
jre*|jdk*)
baseImage+=":${javaVariant:3}-${javaVariant:0:3}${subVariant:+-$subVariant}" # ":7-jre" or ":7-jre-alpine"
;;
*)
echo >&2 "not sure what to do with $version/$variant re: baseImage; skipping"
continue
;;
esac
(
set -x
if [ "$majorVersion" != '6' ]; then
cp -v "Dockerfile${subVariant:+-$subVariant}.template" "$version/$variant/Dockerfile"
fi
sed -ri '
s/^(FROM) .*/\1 '"$baseImage"'/;
s/^(ENV TOMCAT_MAJOR) .*/\1 '"$majorVersion"'/;
s/^(ENV TOMCAT_VERSION) .*/\1 '"$fullVersion"'/;
' "$version/$variant/Dockerfile"
)
travisEnv='\n - '"VERSION=$version VARIANT=$variant$travisEnv"
done
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml