Skip to content

Commit 089b335

Browse files
committed
Simplify update.sh a bit now that we no longer support 1.4 (and no longer need GOLANG_BOOTSTRAP_*)
1 parent 292b03a commit 089b335

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

update.sh

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,11 @@ versions=( "${versions[@]%/}" )
1313
travisEnv=
1414
googleSource="$(curl -fsSL 'https://golang.org/dl/')"
1515
for version in "${versions[@]}"; do
16-
# This is kinda gross, but 1.5+ versions install from the binary package
17-
# while 1.4 installs from src
18-
if [ "$version" = '1.4' ]; then
19-
package='src'
20-
else
21-
package='linux-amd64'
22-
fi
23-
2416
# First check for full version from GitHub as a canonical source
2517
fullVersion="$(curl -fsSL "https://raw.githubusercontent.com/golang/go/release-branch.go$version/VERSION" 2>/dev/null || true)"
2618
if [ -z "$fullVersion" ]; then
2719
echo >&2 "warning: cannot find version from GitHub for $version, scraping golang download page"
28-
fullVersion="$(echo $googleSource | grep -Po '">go'"$version"'.*?\.'"$package"'\.tar\.gz</a>' | sed -r 's!.*go([^"/<]+)\.'"$package"'\.tar\.gz.*!\1!' | sort -V | tail -1)"
20+
fullVersion="$(echo $googleSource | grep -Po '">go'"$version"'.*?\.src\.tar\.gz</a>' | sed -r 's!.*go([^"/<]+)\.src\.tar\.gz.*!\1!' | sort -V | tail -1)"
2921
fi
3022
if [ -z "$fullVersion" ]; then
3123
echo >&2 "warning: cannot find full version for $version"
@@ -35,45 +27,29 @@ for version in "${versions[@]}"; do
3527
versionTag="$fullVersion"
3628

3729
# Try and fetch the checksum from the golang source page
38-
sha256="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.'"$package"'\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{64})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
39-
sha1="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.'"$package"'\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{40})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
40-
if [ -z "$sha1" -a -z "$sha256" ]; then
30+
linuxSha256="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.linux-amd64\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{64})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
31+
linuxSha1="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.linux-amd64\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{40})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
32+
if [ -z "$linuxSha1" -a -z "$linuxSha256" ]; then
4133
echo >&2 "warning: cannot find sha256 or sha1 for $fullVersion"
4234
continue
4335
fi
4436

45-
if [ "$package" = 'src' ]; then
46-
srcSha256="$sha256"
47-
srcSha1="$sha1"
48-
else
49-
srcSha256="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.src\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{64})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
50-
srcSha1="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.src\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{40})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
51-
fi
37+
srcSha256="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.src\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{64})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
38+
srcSha1="$(echo $googleSource | grep -Po '">go'"$fullVersion"'\.src\.tar\.gz</a>.*?>[a-f0-9]{40,64}<' | sed -r 's!.*>([a-f0-9]{40})<.*!\1!; s!.*[<>]+.*!!' | tail -1)"
5239

5340
[[ "$versionTag" == *.*[^0-9]* ]] || versionTag+='.0'
5441
(
5542
set -x
5643
sed -ri '
5744
s/^(ENV GOLANG_VERSION) .*/\1 '"$fullVersion"'/;
58-
s/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$sha256"'/;
59-
s/^(ENV GOLANG_DOWNLOAD_SHA1) .*/\1 '"$sha1"'/;
45+
s/^(ENV GOLANG_DOWNLOAD_SHA256) .*/\1 '"$linuxSha256"'/;
46+
s/^(ENV GOLANG_DOWNLOAD_SHA1) .*/\1 '"$linuxSha1"'/;
6047
s/^(ENV GOLANG_SRC_SHA256) .*/\1 '"$srcSha256"'/;
6148
s/^(ENV GOLANG_SRC_SHA1) .*/\1 '"$srcSha1"'/;
6249
s/^(FROM golang):.*/\1:'"$version"'/;
6350
' "$version/Dockerfile" "$version/"*"/Dockerfile"
6451
cp go-wrapper "$version/"
6552
)
66-
if [ "$version" = '1.4' ]; then
67-
# 1.4 is our "bootstrap" version for all future versions
68-
(
69-
set -x
70-
sed -ri '
71-
s/^(ENV GOLANG_BOOTSTRAP_VERSION) .*/\1 '"$fullVersion"'/;
72-
s/^(ENV GOLANG_BOOTSTRAP_SHA256) .*/\1 '"$srcSha256"'/;
73-
s/^(ENV GOLANG_BOOTSTRAP_SHA1) .*/\1 '"$srcSha1"'/;
74-
' */Dockerfile */*/Dockerfile
75-
)
76-
fi
7753
for variant in alpine wheezy; do
7854
if [ -d "$version/$variant" ]; then
7955
if [ "$variant" != 'alpine' ]; then

0 commit comments

Comments
 (0)