Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update golang #9691

Merged
merged 1 commit into from
Feb 25, 2021
Merged

Update golang #9691

merged 1 commit into from
Feb 25, 2021

Conversation

tianon
Copy link
Member

@tianon tianon commented Feb 25, 2021

Changes:

Changes:

- docker-library/golang@a9533c8: Merge pull request docker-library/golang#360 from infosiftr/i386-softfloat
- docker-library/golang@01c68e7: Fix i386 "softfloat" bug
@github-actions
Copy link

Diff for 5831ead:
diff --git a/_bashbrew-cat b/_bashbrew-cat
index 6c7b4ee..c45ad38 100644
--- a/_bashbrew-cat
+++ b/_bashbrew-cat
@@ -3,18 +3,18 @@ GitRepo: https://github.com/docker-library/golang.git
 
 Tags: 1.15.8-alpine3.12, 1.15-alpine3.12
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: f0f1b321e3e8013373f89e939f2a83e0a536e546
+GitCommit: 01c68e748081c5878806f4e384351b7e66781711
 Directory: 1.15/alpine3.12
 
 Tags: 1.15.8-alpine3.13, 1.15-alpine3.13, 1.15.8-alpine, 1.15-alpine
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: f0f1b321e3e8013373f89e939f2a83e0a536e546
+GitCommit: 01c68e748081c5878806f4e384351b7e66781711
 Directory: 1.15/alpine3.13
 
 Tags: 1.15.8-buster, 1.15-buster
 SharedTags: 1.15.8, 1.15
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: f0f1b321e3e8013373f89e939f2a83e0a536e546
+GitCommit: 01c68e748081c5878806f4e384351b7e66781711
 Directory: 1.15/buster
 
 Tags: 1.15.8-nanoserver-1809, 1.15-nanoserver-1809
@@ -40,18 +40,18 @@ Constraints: windowsservercore-ltsc2016
 
 Tags: 1.16.0-alpine3.12, 1.16-alpine3.12, 1-alpine3.12, alpine3.12
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: b36af443fb19f5d7d036e8bc787e3e40862cd550
+GitCommit: 01c68e748081c5878806f4e384351b7e66781711
 Directory: 1.16/alpine3.12
 
 Tags: 1.16.0-alpine3.13, 1.16-alpine3.13, 1-alpine3.13, alpine3.13, 1.16.0-alpine, 1.16-alpine, 1-alpine, alpine
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: b36af443fb19f5d7d036e8bc787e3e40862cd550
+GitCommit: 01c68e748081c5878806f4e384351b7e66781711
 Directory: 1.16/alpine3.13
 
 Tags: 1.16.0-buster, 1.16-buster, 1-buster, buster
 SharedTags: 1.16.0, 1.16, 1, latest
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b36af443fb19f5d7d036e8bc787e3e40862cd550
+GitCommit: 01c68e748081c5878806f4e384351b7e66781711
 Directory: 1.16/buster
 
 Tags: 1.16.0-nanoserver-1809, 1.16-nanoserver-1809, 1-nanoserver-1809, nanoserver-1809
diff --git a/golang_1.15-alpine/Dockerfile b/golang_1.15-alpine/Dockerfile
index 82445cf..9836c04 100644
--- a/golang_1.15-alpine/Dockerfile
+++ b/golang_1.15-alpine/Dockerfile
@@ -27,23 +27,30 @@ RUN set -eux; \
 		musl-dev \
 		openssl \
 	; \
-	export \
-# set GOROOT_BOOTSTRAP such that we can actually build Go
-		GOROOT_BOOTSTRAP="$(go env GOROOT)" \
-# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
-# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
-		GOOS="$(go env GOOS)" \
-		GOARCH="$(go env GOARCH)" \
-		GOHOSTOS="$(go env GOHOSTOS)" \
-		GOHOSTARCH="$(go env GOHOSTARCH)" \
-	; \
-# also explicitly set GO386 and GOARM if appropriate
-# https://github.com/docker-library/golang/issues/184
 	apkArch="$(apk --print-arch)"; \
 	case "$apkArch" in \
-		armhf) export GOARM='6' ;; \
-		armv7) export GOARM='7' ;; \
-		x86) export GO386='387' ;; \
+		'x86_64') \
+			export GOARCH='amd64' GOOS='linux'; \
+			;; \
+		'armhf') \
+			export GOARCH='arm' GOARM='6' GOOS='linux'; \
+			;; \
+		'armv7') \
+			export GOARCH='arm' GOARM='7' GOOS='linux'; \
+			;; \
+		'aarch64') \
+			export GOARCH='arm64' GOOS='linux'; \
+			;; \
+		'x86') \
+			export GO386='387' GOARCH='386' GOOS='linux'; \
+			;; \
+		'ppc64le') \
+			export GOARCH='ppc64le' GOOS='linux'; \
+			;; \
+		's390x') \
+			export GOARCH='s390x' GOOS='linux'; \
+			;; \
+		*) echo >&2 "error: unsupported architecture '$apkArch' (likely packaging update needed)"; exit 1 ;; \
 	esac; \
 	\
 # https://github.com/golang/go/issues/38536#issuecomment-616897960
@@ -65,13 +72,21 @@ RUN set -eux; \
 	tar -C /usr/local -xzf go.tgz; \
 	rm go.tgz; \
 	\
-	goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
-	eval "$goEnv"; \
-	[ -n "$GOOS" ]; \
-	[ -n "$GOARCH" ]; \
 	( \
 		cd /usr/local/go/src; \
+# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
+		export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+# https://github.com/docker-library/golang/issues/359 -> https://github.com/golang/go/issues/44500
+# (once our Alpine base has Go 1.16, we can remove this hack)
+			GO386= ./bootstrap.bash; \
+			export GOROOT_BOOTSTRAP="/usr/local/go-$GOOS-$GOARCH-bootstrap"; \
+			"$GOROOT_BOOTSTRAP/bin/go" version; \
+		fi; \
 		./make.bash; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+			rm -rf "$GOROOT_BOOTSTRAP"; \
+		fi; \
 	); \
 	\
 	apk del --no-network .build-deps; \
diff --git a/golang_1.15-alpine3.12/Dockerfile b/golang_1.15-alpine3.12/Dockerfile
index c85b4e7..3c739da 100644
--- a/golang_1.15-alpine3.12/Dockerfile
+++ b/golang_1.15-alpine3.12/Dockerfile
@@ -27,23 +27,30 @@ RUN set -eux; \
 		musl-dev \
 		openssl \
 	; \
-	export \
-# set GOROOT_BOOTSTRAP such that we can actually build Go
-		GOROOT_BOOTSTRAP="$(go env GOROOT)" \
-# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
-# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
-		GOOS="$(go env GOOS)" \
-		GOARCH="$(go env GOARCH)" \
-		GOHOSTOS="$(go env GOHOSTOS)" \
-		GOHOSTARCH="$(go env GOHOSTARCH)" \
-	; \
-# also explicitly set GO386 and GOARM if appropriate
-# https://github.com/docker-library/golang/issues/184
 	apkArch="$(apk --print-arch)"; \
 	case "$apkArch" in \
-		armhf) export GOARM='6' ;; \
-		armv7) export GOARM='7' ;; \
-		x86) export GO386='387' ;; \
+		'x86_64') \
+			export GOARCH='amd64' GOOS='linux'; \
+			;; \
+		'armhf') \
+			export GOARCH='arm' GOARM='6' GOOS='linux'; \
+			;; \
+		'armv7') \
+			export GOARCH='arm' GOARM='7' GOOS='linux'; \
+			;; \
+		'aarch64') \
+			export GOARCH='arm64' GOOS='linux'; \
+			;; \
+		'x86') \
+			export GO386='387' GOARCH='386' GOOS='linux'; \
+			;; \
+		'ppc64le') \
+			export GOARCH='ppc64le' GOOS='linux'; \
+			;; \
+		's390x') \
+			export GOARCH='s390x' GOOS='linux'; \
+			;; \
+		*) echo >&2 "error: unsupported architecture '$apkArch' (likely packaging update needed)"; exit 1 ;; \
 	esac; \
 	\
 # https://github.com/golang/go/issues/38536#issuecomment-616897960
@@ -65,13 +72,21 @@ RUN set -eux; \
 	tar -C /usr/local -xzf go.tgz; \
 	rm go.tgz; \
 	\
-	goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
-	eval "$goEnv"; \
-	[ -n "$GOOS" ]; \
-	[ -n "$GOARCH" ]; \
 	( \
 		cd /usr/local/go/src; \
+# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
+		export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+# https://github.com/docker-library/golang/issues/359 -> https://github.com/golang/go/issues/44500
+# (once our Alpine base has Go 1.16, we can remove this hack)
+			GO386= ./bootstrap.bash; \
+			export GOROOT_BOOTSTRAP="/usr/local/go-$GOOS-$GOARCH-bootstrap"; \
+			"$GOROOT_BOOTSTRAP/bin/go" version; \
+		fi; \
 		./make.bash; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+			rm -rf "$GOROOT_BOOTSTRAP"; \
+		fi; \
 	); \
 	\
 	apk del --no-network .build-deps; \
diff --git a/golang_1.15-buster/Dockerfile b/golang_1.15-buster/Dockerfile
index e254a69..e53f88d 100644
--- a/golang_1.15-buster/Dockerfile
+++ b/golang_1.15-buster/Dockerfile
@@ -22,47 +22,50 @@ ENV GOLANG_VERSION 1.15.8
 RUN set -eux; \
 	\
 	dpkgArch="$(dpkg --print-architecture)"; \
+	url=; \
 	case "${dpkgArch##*-}" in \
 		'amd64') \
-			arch='linux-amd64'; \
 			url='https://storage.googleapis.com/golang/go1.15.8.linux-amd64.tar.gz'; \
 			sha256='d3379c32a90fdf9382166f8f48034c459a8cc433730bc9476d39d9082c94583b'; \
 			;; \
+		'armel') \
+			export GOARCH='arm' GOARM='5' GOOS='linux'; \
+			;; \
 		'armhf') \
-			arch='linux-armv6l'; \
 			url='https://storage.googleapis.com/golang/go1.15.8.linux-armv6l.tar.gz'; \
 			sha256='708c398cb9e5029cfd5b654370978bf0e797d4d4a71153c06c7378db7e249a53'; \
 			;; \
 		'arm64') \
-			arch='linux-arm64'; \
 			url='https://storage.googleapis.com/golang/go1.15.8.linux-arm64.tar.gz'; \
 			sha256='0e31ea4bf53496b0f0809730520dee98c0ae5c530f3701a19df0ba0a327bf3d2'; \
 			;; \
 		'i386') \
-			arch='linux-386'; \
 			url='https://storage.googleapis.com/golang/go1.15.8.linux-386.tar.gz'; \
 			sha256='a0cc9df6d04f89af8396278d171087894a453a03a950b0f60a4ac18b480f758f'; \
 			;; \
+		'mips64el') \
+			export GOARCH='mips64le' GOOS='linux'; \
+			;; \
 		'ppc64el') \
-			arch='linux-ppc64le'; \
 			url='https://storage.googleapis.com/golang/go1.15.8.linux-ppc64le.tar.gz'; \
 			sha256='c6ddeab22b23ee33f5e8f06f9667e2092f48dbc6d5db553a66f7fe21da73fbfa'; \
 			;; \
 		's390x') \
-			arch='linux-s390x'; \
 			url='https://storage.googleapis.com/golang/go1.15.8.linux-s390x.tar.gz'; \
 			sha256='ba922f54fe99dee3246705bacbfac27fa88375439025429297aa1e9caf3f2297'; \
 			;; \
-		*) \
+		*) echo >&2 "error: unsupported architecture '$dpkgArch' (likely packaging update needed)"; exit 1 ;; \
+	esac; \
+	build=; \
+	if [ -z "$url" ]; then \
 # https://github.com/golang/go/issues/38536#issuecomment-616897960
-			arch='src'; \
+		build=1; \
 		url='https://storage.googleapis.com/golang/go1.15.8.src.tar.gz'; \
 		sha256='540c0ab7781084d124991321ed1458e479982de94454a98afab6acadf38497c2'; \
 		echo >&2; \
 		echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; \
 		echo >&2; \
-			;; \
-	esac; \
+	fi; \
 	\
 	wget -O go.tgz.asc "$url.asc" --progress=dot:giga; \
 	wget -O go.tgz "$url" --progress=dot:giga; \
@@ -79,17 +82,15 @@ RUN set -eux; \
 	tar -C /usr/local -xzf go.tgz; \
 	rm go.tgz; \
 	\
-	if [ "$arch" = 'src' ]; then \
+	if [ -n "$build" ]; then \
 		savedAptMark="$(apt-mark showmanual)"; \
 		apt-get update; \
 		apt-get install -y --no-install-recommends golang-go; \
 		\
-		goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
-		eval "$goEnv"; \
-		[ -n "$GOOS" ]; \
-		[ -n "$GOARCH" ]; \
 		( \
 			cd /usr/local/go/src; \
+# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
+			export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
 			./make.bash; \
 		); \
 		\
diff --git a/golang_alpine/Dockerfile b/golang_alpine/Dockerfile
index 8dd40ef..fda850a 100644
--- a/golang_alpine/Dockerfile
+++ b/golang_alpine/Dockerfile
@@ -27,23 +27,30 @@ RUN set -eux; \
 		musl-dev \
 		openssl \
 	; \
-	export \
-# set GOROOT_BOOTSTRAP such that we can actually build Go
-		GOROOT_BOOTSTRAP="$(go env GOROOT)" \
-# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
-# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
-		GOOS="$(go env GOOS)" \
-		GOARCH="$(go env GOARCH)" \
-		GOHOSTOS="$(go env GOHOSTOS)" \
-		GOHOSTARCH="$(go env GOHOSTARCH)" \
-	; \
-# also explicitly set GO386 and GOARM if appropriate
-# https://github.com/docker-library/golang/issues/184
 	apkArch="$(apk --print-arch)"; \
 	case "$apkArch" in \
-		armhf) export GOARM='6' ;; \
-		armv7) export GOARM='7' ;; \
-		x86) export GO386='softfloat' ;; \
+		'x86_64') \
+			export GOARCH='amd64' GOOS='linux'; \
+			;; \
+		'armhf') \
+			export GOARCH='arm' GOARM='6' GOOS='linux'; \
+			;; \
+		'armv7') \
+			export GOARCH='arm' GOARM='7' GOOS='linux'; \
+			;; \
+		'aarch64') \
+			export GOARCH='arm64' GOOS='linux'; \
+			;; \
+		'x86') \
+			export GO386='softfloat' GOARCH='386' GOOS='linux'; \
+			;; \
+		'ppc64le') \
+			export GOARCH='ppc64le' GOOS='linux'; \
+			;; \
+		's390x') \
+			export GOARCH='s390x' GOOS='linux'; \
+			;; \
+		*) echo >&2 "error: unsupported architecture '$apkArch' (likely packaging update needed)"; exit 1 ;; \
 	esac; \
 	\
 # https://github.com/golang/go/issues/38536#issuecomment-616897960
@@ -65,13 +72,21 @@ RUN set -eux; \
 	tar -C /usr/local -xzf go.tgz; \
 	rm go.tgz; \
 	\
-	goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
-	eval "$goEnv"; \
-	[ -n "$GOOS" ]; \
-	[ -n "$GOARCH" ]; \
 	( \
 		cd /usr/local/go/src; \
+# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
+		export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+# https://github.com/docker-library/golang/issues/359 -> https://github.com/golang/go/issues/44500
+# (once our Alpine base has Go 1.16, we can remove this hack)
+			GO386= ./bootstrap.bash; \
+			export GOROOT_BOOTSTRAP="/usr/local/go-$GOOS-$GOARCH-bootstrap"; \
+			"$GOROOT_BOOTSTRAP/bin/go" version; \
+		fi; \
 		./make.bash; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+			rm -rf "$GOROOT_BOOTSTRAP"; \
+		fi; \
 	); \
 	\
 	apk del --no-network .build-deps; \
diff --git a/golang_alpine3.12/Dockerfile b/golang_alpine3.12/Dockerfile
index c980dcf..2620c2c 100644
--- a/golang_alpine3.12/Dockerfile
+++ b/golang_alpine3.12/Dockerfile
@@ -27,23 +27,30 @@ RUN set -eux; \
 		musl-dev \
 		openssl \
 	; \
-	export \
-# set GOROOT_BOOTSTRAP such that we can actually build Go
-		GOROOT_BOOTSTRAP="$(go env GOROOT)" \
-# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
-# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
-		GOOS="$(go env GOOS)" \
-		GOARCH="$(go env GOARCH)" \
-		GOHOSTOS="$(go env GOHOSTOS)" \
-		GOHOSTARCH="$(go env GOHOSTARCH)" \
-	; \
-# also explicitly set GO386 and GOARM if appropriate
-# https://github.com/docker-library/golang/issues/184
 	apkArch="$(apk --print-arch)"; \
 	case "$apkArch" in \
-		armhf) export GOARM='6' ;; \
-		armv7) export GOARM='7' ;; \
-		x86) export GO386='softfloat' ;; \
+		'x86_64') \
+			export GOARCH='amd64' GOOS='linux'; \
+			;; \
+		'armhf') \
+			export GOARCH='arm' GOARM='6' GOOS='linux'; \
+			;; \
+		'armv7') \
+			export GOARCH='arm' GOARM='7' GOOS='linux'; \
+			;; \
+		'aarch64') \
+			export GOARCH='arm64' GOOS='linux'; \
+			;; \
+		'x86') \
+			export GO386='softfloat' GOARCH='386' GOOS='linux'; \
+			;; \
+		'ppc64le') \
+			export GOARCH='ppc64le' GOOS='linux'; \
+			;; \
+		's390x') \
+			export GOARCH='s390x' GOOS='linux'; \
+			;; \
+		*) echo >&2 "error: unsupported architecture '$apkArch' (likely packaging update needed)"; exit 1 ;; \
 	esac; \
 	\
 # https://github.com/golang/go/issues/38536#issuecomment-616897960
@@ -65,13 +72,21 @@ RUN set -eux; \
 	tar -C /usr/local -xzf go.tgz; \
 	rm go.tgz; \
 	\
-	goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
-	eval "$goEnv"; \
-	[ -n "$GOOS" ]; \
-	[ -n "$GOARCH" ]; \
 	( \
 		cd /usr/local/go/src; \
+# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
+		export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+# https://github.com/docker-library/golang/issues/359 -> https://github.com/golang/go/issues/44500
+# (once our Alpine base has Go 1.16, we can remove this hack)
+			GO386= ./bootstrap.bash; \
+			export GOROOT_BOOTSTRAP="/usr/local/go-$GOOS-$GOARCH-bootstrap"; \
+			"$GOROOT_BOOTSTRAP/bin/go" version; \
+		fi; \
 		./make.bash; \
+		if [ "${GO386:-}" = 'softfloat' ]; then \
+			rm -rf "$GOROOT_BOOTSTRAP"; \
+		fi; \
 	); \
 	\
 	apk del --no-network .build-deps; \
diff --git a/golang_buster/Dockerfile b/golang_buster/Dockerfile
index 5904939..baa3b13 100644
--- a/golang_buster/Dockerfile
+++ b/golang_buster/Dockerfile
@@ -22,47 +22,50 @@ ENV GOLANG_VERSION 1.16
 RUN set -eux; \
 	\
 	dpkgArch="$(dpkg --print-architecture)"; \
+	url=; \
 	case "${dpkgArch##*-}" in \
 		'amd64') \
-			arch='linux-amd64'; \
 			url='https://storage.googleapis.com/golang/go1.16.linux-amd64.tar.gz'; \
 			sha256='013a489ebb3e24ef3d915abe5b94c3286c070dfe0818d5bca8108f1d6e8440d2'; \
 			;; \
+		'armel') \
+			export GOARCH='arm' GOARM='5' GOOS='linux'; \
+			;; \
 		'armhf') \
-			arch='linux-armv6l'; \
 			url='https://storage.googleapis.com/golang/go1.16.linux-armv6l.tar.gz'; \
 			sha256='d1d9404b1dbd77afa2bdc70934e10fbfcf7d785c372efc29462bb7d83d0a32fd'; \
 			;; \
 		'arm64') \
-			arch='linux-arm64'; \
 			url='https://storage.googleapis.com/golang/go1.16.linux-arm64.tar.gz'; \
 			sha256='3770f7eb22d05e25fbee8fb53c2a4e897da043eb83c69b9a14f8d98562cd8098'; \
 			;; \
 		'i386') \
-			arch='linux-386'; \
 			url='https://storage.googleapis.com/golang/go1.16.linux-386.tar.gz'; \
 			sha256='ea435a1ac6d497b03e367fdfb74b33e961d813883468080f6e239b3b03bea6aa'; \
 			;; \
+		'mips64el') \
+			export GOARCH='mips64le' GOOS='linux'; \
+			;; \
 		'ppc64el') \
-			arch='linux-ppc64le'; \
 			url='https://storage.googleapis.com/golang/go1.16.linux-ppc64le.tar.gz'; \
 			sha256='27a1aaa988e930b7932ce459c8a63ad5b3333b3a06b016d87ff289f2a11aacd6'; \
 			;; \
 		's390x') \
-			arch='linux-s390x'; \
 			url='https://storage.googleapis.com/golang/go1.16.linux-s390x.tar.gz'; \
 			sha256='be4c9e4e2cf058efc4e3eb013a760cb989ddc4362f111950c990d1c63b27ccbe'; \
 			;; \
-		*) \
+		*) echo >&2 "error: unsupported architecture '$dpkgArch' (likely packaging update needed)"; exit 1 ;; \
+	esac; \
+	build=; \
+	if [ -z "$url" ]; then \
 # https://github.com/golang/go/issues/38536#issuecomment-616897960
-			arch='src'; \
+		build=1; \
 		url='https://storage.googleapis.com/golang/go1.16.src.tar.gz'; \
 		sha256='7688063d55656105898f323d90a79a39c378d86fe89ae192eb3b7fc46347c95a'; \
 		echo >&2; \
 		echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; \
 		echo >&2; \
-			;; \
-	esac; \
+	fi; \
 	\
 	wget -O go.tgz.asc "$url.asc" --progress=dot:giga; \
 	wget -O go.tgz "$url" --progress=dot:giga; \
@@ -79,17 +82,15 @@ RUN set -eux; \
 	tar -C /usr/local -xzf go.tgz; \
 	rm go.tgz; \
 	\
-	if [ "$arch" = 'src' ]; then \
+	if [ -n "$build" ]; then \
 		savedAptMark="$(apt-mark showmanual)"; \
 		apt-get update; \
 		apt-get install -y --no-install-recommends golang-go; \
 		\
-		goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
-		eval "$goEnv"; \
-		[ -n "$GOOS" ]; \
-		[ -n "$GOARCH" ]; \
 		( \
 			cd /usr/local/go/src; \
+# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
+			export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
 			./make.bash; \
 		); \
 		\

@yosifkit yosifkit merged commit fb61641 into docker-library:master Feb 25, 2021
@yosifkit yosifkit deleted the golang branch February 25, 2021 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants