forked from docker-library/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versions.sh
executable file
·158 lines (138 loc) · 4.15 KB
/
versions.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
#!/usr/bin/env bash
set -Eeuo pipefail
defaultAlpineVersion='3.13'
declare -A alpineVersion=(
#[17.09]='3.6'
)
# bashbrew arch to docker-release-arch
declare -A dockerArches=(
['amd64']='x86_64'
['arm32v6']='armel'
['arm32v7']='armhf'
['arm64v8']='aarch64'
['ppc64le']='ppc64le'
['s390x']='s390x'
['windows-amd64']='x86_64'
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
json='{}'
else
json="$(< versions.json)"
fi
versions=( "${versions[@]%/}" )
# "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 }')"
dockerVersions="$(
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 -u \
| gawk '
{ data[lines++] = $0 }
# "beta" sorts lower than "tp" even though "beta" is a more preferred release, so we need to explicitly adjust the sorting order for RCs
# also, "18.09.0-ce-beta1" vs "18.09.0-beta3"
function docker_version_compare(i1, v1, i2, v2, l, r) {
l = v1; gsub(/-ce/, "", l); gsub(/-tp/, "-alpha", l)
r = v2; gsub(/-ce/, "", r); gsub(/-tp/, "-alpha", r)
patsplit(l, ltemp, /[^.-]+/)
patsplit(r, rtemp, /[^.-]+/)
for (i = 0; i < length(ltemp) && i < length(rtemp); ++i) {
if (ltemp[i] < rtemp[i]) {
return -1
}
if (ltemp[i] > rtemp[i]) {
return 1
}
}
return 0
}
END {
asort(data, result, "docker_version_compare")
for (i in result) {
print result[i]
}
}
'
)"
for version in "${versions[@]}"; do
rcVersion="${version%-rc}"
channel='stable'
alpine="${alpineVersion[$version]:-$defaultAlpineVersion}"
versionOptions="$(grep "^$rcVersion[.]" <<<"$dockerVersions")"
rcGrepV='-v'
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
channel='test'
fi
fullVersion="$(grep $rcGrepV -E -- '-(rc|tp|beta)' <<<"$versionOptions" | tail -1)"
if [ -z "$fullVersion" ]; then
echo >&2 "warning: cannot find full version for $version"
continue
fi
echo "$version: $fullVersion"
export fullVersion alpine dindLatest
doc="$(
jq -nc '{
version: env.fullVersion,
arches: {},
alpine: env.alpine,
dindCommit: env.dindLatest,
}'
)"
hasWindows=
for bashbrewArch in "${!dockerArches[@]}"; do
arch="${dockerArches[$bashbrewArch]}"
# check whether the given architecture is supported for this release
case "$bashbrewArch" in
windows-*) url="https://download.docker.com/win/static/$channel/$arch/docker-$fullVersion.zip"; windows=1 ;;
*) url="https://download.docker.com/linux/static/$channel/$arch/docker-$fullVersion.tgz"; windows= ;;
esac
if wget --quiet --spider "$url" &> /dev/null; then
export bashbrewArch url
doc="$(
jq <<<"$doc" -c '.arches[env.bashbrewArch] = {
dockerUrl: env.url,
}'
)"
else
continue
fi
if [ -n "$windows" ]; then
hasWindows=1
continue # Windows doesn't have rootless extras :)
fi
rootlessExtrasUrl="https://download.docker.com/linux/static/$channel/$arch/docker-rootless-extras-$fullVersion.tgz"
# https://github.com/docker/docker-ce/blob/8fb3bb7b2210789a4471c017561c1b0de0b4f145/components/engine/hack/make/binary-daemon#L24
# "vpnkit is amd64-only" ... for now??
if [ "$bashbrewArch" = 'amd64' ] && wget --quiet --spider "$rootlessExtrasUrl" &> /dev/null; then
export rootlessExtrasUrl
doc="$(
jq <<<"$doc" -c \
'.arches[env.bashbrewArch].rootlessExtrasUrl = env.rootlessExtrasUrl'
)"
fi
done
# order here controls the order of the library/ file
for variant in \
'' \
dind \
dind-rootless \
git \
windows/windowsservercore-1809 \
; do
base="${variant%%/*}" # "buster", "windows", etc.
[ -d "$version/$base" ] || continue
if [ "$base" = 'windows' ] && [ -z "$hasWindows" ]; then
continue
fi
export variant
doc="$(jq <<<"$doc" -c '.variants += [ env.variant ]')"
done
export version
json="$(jq <<<"$json" -c --argjson doc "$doc" '.[env.version] = $doc')"
done
jq <<<"$json" -S . > versions.json