forked from docker-library/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·49 lines (42 loc) · 1.62 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
#!/bin/bash
set -eo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
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 }')"
dockerVerions="$(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 "$dockerVerions" | grep $rcGrepV -- '-rc' | grep "^$rcVersion[.]" | head -n1)"
if [ -z "$fullVersion" ]; then
echo >&2 "warning: cannot find full version for $version"
continue
fi
bucket='get.docker.com'
if [ "$rcVersion" != "$version" ]; then
bucket='test.docker.com'
fi
sha256="$(curl -fsSL "https://$bucket/builds/Linux/x86_64/docker-$fullVersion.sha256" | cut -d' ' -f1)"
(
set -x
sed -ri '
s/^(ENV DOCKER_BUCKET) .*/\1 '"$bucket"'/;
s/^(ENV DOCKER_VERSION) .*/\1 '"$fullVersion"'/;
s/^(ENV DOCKER_SHA256) .*/\1 '"$sha256"'/;
s/^(ENV DIND_COMMIT) .*/\1 '"$dindLatest"'/;
s/^(FROM docker):.*/\1:'"$version"'/;
' "$version/Dockerfile" "$version"/*/Dockerfile
)
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