forked from docker-library/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·102 lines (85 loc) · 2.94 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
#!/bin/bash
set -eo pipefail
defaultAlpineVersion='3.6'
declare -A alpineVersion=(
[17.03]='3.5'
[17.03-rc]='3.5'
[17.05]='3.5'
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
source '.architectures-lib'
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
# see http://stackoverflow.com/a/2705678/433558
sed_escape_lhs() {
echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
}
sed_escape_rhs() {
echo "$@" | sed -e 's/[\/&]/\\&/g' | sed -e ':a;N;$!ba;s/\n/\\n/g'
}
# "tac|tac" for http://stackoverflow.com/a/28879552/433558
dindLatest="$(curl -fsSL 'https://github.com/docker/docker/commits/master/hack/dind.atom' | tac|tac | awk -F '[[:space:]]*[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')"
# TODO once "Supported Docker versions" minimums at Docker 1.8+ (1.6 at time of this writing), bring this back again
#sed -r -e 's/^(ENV DIND_COMMIT) .*/\1 '"$dindLatest"'/' Dockerfile-dind.template
dockerVersions="$(
{
git ls-remote --tags https://github.com/docker/docker-ce.git
# TODO remove-me (17.06+ live exclusively in docker-ce)
git ls-remote --tags https://github.com/docker/docker.git
} \
| cut -d$'\t' -f2 \
| grep '^refs/tags/v[0-9].*$' \
| sed 's!^refs/tags/v!!; s!\^{}$!!' \
| sort -ruV
)"
travisEnv=
for version in "${versions[@]}"; do
rcGrepV='-v'
rcVersion="${version%-rc}"
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
fullVersion="$(echo "$dockerVersions" | grep $rcGrepV -- '-rc' | grep "^$rcVersion[.]" | head -n1)"
if [ -z "$fullVersion" ]; then
echo >&2 "warning: cannot find full version for $version"
continue
fi
channel='edge'
if [ "$rcVersion" != "$version" ]; then
channel='test'
elif \
minorVersion="${rcVersion##*.}" \
&& minorVersion="${minorVersion#0}" \
&& [ "$(( minorVersion % 3 ))" = '0' ] \
; then
channel='stable'
fi
archCase='apkArch="$(apk --print-arch)"; '$'\\\n'
archCase+=$'\t''case "$apkArch" in '$'\\\n'
for apkArch in $(apkArches "$version"); do
dockerArch="$(apkToDockerArch "$version" "$apkArch")"
archCase+=$'\t\t'"$apkArch) dockerArch='$dockerArch' ;; "$'\\\n'
done
archCase+=$'\t\t''*) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;'$'\\\n'
archCase+=$'\t''esac'
alpine="${alpineVersion[$version]:-$defaultAlpineVersion}"
sed -r \
-e 's!%%DOCKER-CHANNEL%%!'"$channel"'!g' \
-e 's!%%DOCKER-VERSION%%!'"$fullVersion"'!g' \
-e 's!%%ALPINE-VERSION%%!'"$alpine"'!g' \
-e 's!%%ARCH-CASE%%!'"$(sed_escape_rhs "$archCase")"'!g' \
Dockerfile.template > "$version/Dockerfile"
cp -a docker-entrypoint.sh "$version/"
cp -a dockerd-entrypoint.sh "$version/dind/"
for variant in git dind; do
sed -r \
-e 's!%%VERSION%%!'"$version"'!g' \
"Dockerfile-$variant.template" > "$version/$variant/Dockerfile"
done
travisEnv='\n - VERSION='"$version$travisEnv"
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml