Skip to content

Commit 1eb0961

Browse files
authored
Merge pull request #335 from infosiftr/src
Build from source when upstream binaries are not available
2 parents cb17d92 + 11eef5d commit 1eb0961

11 files changed

+232
-75
lines changed

.architectures-lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
_awkArch() {
44
local version="$1"; shift
55
local awkExpr="$1"; shift
6-
awk "$@" "/^#|^\$/ { next } $awkExpr" "$version/release-architectures"
6+
awk "$@" "/^#|^\$/ { next } $awkExpr" release-architectures
77
}
88

99
dpkgArches() {

1.13/buster/Dockerfile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
99
pkg-config \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
ENV PATH /usr/local/go/bin:$PATH
13+
1214
ENV GOLANG_VERSION 1.13.12
1315

1416
RUN set -eux; \
@@ -27,24 +29,50 @@ RUN set -eux; \
2729
esac; \
2830
\
2931
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
30-
wget -O go.tgz "$url"; \
32+
wget -O go.tgz "$url" --progress=dot:giga; \
3133
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
3234
tar -C /usr/local -xzf go.tgz; \
3335
rm go.tgz; \
3436
\
37+
# https://github.com/golang/go/issues/38536#issuecomment-616897960
3538
if [ "$goRelArch" = 'src' ]; then \
36-
echo >&2; \
37-
echo >&2 'error: UNIMPLEMENTED'; \
38-
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
39-
echo >&2; \
40-
exit 1; \
39+
savedAptMark="$(apt-mark showmanual)"; \
40+
apt-get update; \
41+
apt-get install -y --no-install-recommends golang-go; \
42+
\
43+
goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
44+
eval "$goEnv"; \
45+
[ -n "$GOOS" ]; \
46+
[ -n "$GOARCH" ]; \
47+
( \
48+
cd /usr/local/go/src; \
49+
./make.bash; \
50+
); \
51+
\
52+
apt-mark auto '.*' > /dev/null; \
53+
apt-mark manual $savedAptMark > /dev/null; \
54+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
55+
rm -rf /var/lib/apt/lists/*; \
56+
\
57+
# pre-compile the standard library, just like the official binary release tarballs do
58+
go install std; \
59+
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
60+
# go install -race std; \
61+
\
62+
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
63+
rm -rf \
64+
/usr/local/go/pkg/*/cmd \
65+
/usr/local/go/pkg/bootstrap \
66+
/usr/local/go/pkg/obj \
67+
/usr/local/go/pkg/tool/*/api \
68+
/usr/local/go/pkg/tool/*/go_bootstrap \
69+
/usr/local/go/src/cmd/dist/dist \
70+
; \
4171
fi; \
4272
\
43-
export PATH="/usr/local/go/bin:$PATH"; \
4473
go version
4574

4675
ENV GOPATH /go
47-
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
48-
76+
ENV PATH $GOPATH/bin:$PATH
4977
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5078
WORKDIR $GOPATH

1.13/stretch/Dockerfile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
99
pkg-config \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
ENV PATH /usr/local/go/bin:$PATH
13+
1214
ENV GOLANG_VERSION 1.13.12
1315

1416
RUN set -eux; \
@@ -27,24 +29,50 @@ RUN set -eux; \
2729
esac; \
2830
\
2931
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
30-
wget -O go.tgz "$url"; \
32+
wget -O go.tgz "$url" --progress=dot:giga; \
3133
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
3234
tar -C /usr/local -xzf go.tgz; \
3335
rm go.tgz; \
3436
\
37+
# https://github.com/golang/go/issues/38536#issuecomment-616897960
3538
if [ "$goRelArch" = 'src' ]; then \
36-
echo >&2; \
37-
echo >&2 'error: UNIMPLEMENTED'; \
38-
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
39-
echo >&2; \
40-
exit 1; \
39+
savedAptMark="$(apt-mark showmanual)"; \
40+
apt-get update; \
41+
apt-get install -y --no-install-recommends golang-go; \
42+
\
43+
goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
44+
eval "$goEnv"; \
45+
[ -n "$GOOS" ]; \
46+
[ -n "$GOARCH" ]; \
47+
( \
48+
cd /usr/local/go/src; \
49+
./make.bash; \
50+
); \
51+
\
52+
apt-mark auto '.*' > /dev/null; \
53+
apt-mark manual $savedAptMark > /dev/null; \
54+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
55+
rm -rf /var/lib/apt/lists/*; \
56+
\
57+
# pre-compile the standard library, just like the official binary release tarballs do
58+
go install std; \
59+
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
60+
# go install -race std; \
61+
\
62+
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
63+
rm -rf \
64+
/usr/local/go/pkg/*/cmd \
65+
/usr/local/go/pkg/bootstrap \
66+
/usr/local/go/pkg/obj \
67+
/usr/local/go/pkg/tool/*/api \
68+
/usr/local/go/pkg/tool/*/go_bootstrap \
69+
/usr/local/go/src/cmd/dist/dist \
70+
; \
4171
fi; \
4272
\
43-
export PATH="/usr/local/go/bin:$PATH"; \
4473
go version
4574

4675
ENV GOPATH /go
47-
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
48-
76+
ENV PATH $GOPATH/bin:$PATH
4977
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5078
WORKDIR $GOPATH

1.14/buster/Dockerfile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
99
pkg-config \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
ENV PATH /usr/local/go/bin:$PATH
13+
1214
ENV GOLANG_VERSION 1.14.4
1315

1416
RUN set -eux; \
@@ -27,24 +29,50 @@ RUN set -eux; \
2729
esac; \
2830
\
2931
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
30-
wget -O go.tgz "$url"; \
32+
wget -O go.tgz "$url" --progress=dot:giga; \
3133
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
3234
tar -C /usr/local -xzf go.tgz; \
3335
rm go.tgz; \
3436
\
37+
# https://github.com/golang/go/issues/38536#issuecomment-616897960
3538
if [ "$goRelArch" = 'src' ]; then \
36-
echo >&2; \
37-
echo >&2 'error: UNIMPLEMENTED'; \
38-
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
39-
echo >&2; \
40-
exit 1; \
39+
savedAptMark="$(apt-mark showmanual)"; \
40+
apt-get update; \
41+
apt-get install -y --no-install-recommends golang-go; \
42+
\
43+
goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
44+
eval "$goEnv"; \
45+
[ -n "$GOOS" ]; \
46+
[ -n "$GOARCH" ]; \
47+
( \
48+
cd /usr/local/go/src; \
49+
./make.bash; \
50+
); \
51+
\
52+
apt-mark auto '.*' > /dev/null; \
53+
apt-mark manual $savedAptMark > /dev/null; \
54+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
55+
rm -rf /var/lib/apt/lists/*; \
56+
\
57+
# pre-compile the standard library, just like the official binary release tarballs do
58+
go install std; \
59+
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
60+
# go install -race std; \
61+
\
62+
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
63+
rm -rf \
64+
/usr/local/go/pkg/*/cmd \
65+
/usr/local/go/pkg/bootstrap \
66+
/usr/local/go/pkg/obj \
67+
/usr/local/go/pkg/tool/*/api \
68+
/usr/local/go/pkg/tool/*/go_bootstrap \
69+
/usr/local/go/src/cmd/dist/dist \
70+
; \
4171
fi; \
4272
\
43-
export PATH="/usr/local/go/bin:$PATH"; \
4473
go version
4574

4675
ENV GOPATH /go
47-
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
48-
76+
ENV PATH $GOPATH/bin:$PATH
4977
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5078
WORKDIR $GOPATH

1.14/release-architectures

Lines changed: 0 additions & 9 deletions
This file was deleted.

1.14/stretch/Dockerfile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
99
pkg-config \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
ENV PATH /usr/local/go/bin:$PATH
13+
1214
ENV GOLANG_VERSION 1.14.4
1315

1416
RUN set -eux; \
@@ -27,24 +29,50 @@ RUN set -eux; \
2729
esac; \
2830
\
2931
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
30-
wget -O go.tgz "$url"; \
32+
wget -O go.tgz "$url" --progress=dot:giga; \
3133
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
3234
tar -C /usr/local -xzf go.tgz; \
3335
rm go.tgz; \
3436
\
37+
# https://github.com/golang/go/issues/38536#issuecomment-616897960
3538
if [ "$goRelArch" = 'src' ]; then \
36-
echo >&2; \
37-
echo >&2 'error: UNIMPLEMENTED'; \
38-
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
39-
echo >&2; \
40-
exit 1; \
39+
savedAptMark="$(apt-mark showmanual)"; \
40+
apt-get update; \
41+
apt-get install -y --no-install-recommends golang-go; \
42+
\
43+
goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
44+
eval "$goEnv"; \
45+
[ -n "$GOOS" ]; \
46+
[ -n "$GOARCH" ]; \
47+
( \
48+
cd /usr/local/go/src; \
49+
./make.bash; \
50+
); \
51+
\
52+
apt-mark auto '.*' > /dev/null; \
53+
apt-mark manual $savedAptMark > /dev/null; \
54+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
55+
rm -rf /var/lib/apt/lists/*; \
56+
\
57+
# pre-compile the standard library, just like the official binary release tarballs do
58+
go install std; \
59+
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
60+
# go install -race std; \
61+
\
62+
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
63+
rm -rf \
64+
/usr/local/go/pkg/*/cmd \
65+
/usr/local/go/pkg/bootstrap \
66+
/usr/local/go/pkg/obj \
67+
/usr/local/go/pkg/tool/*/api \
68+
/usr/local/go/pkg/tool/*/go_bootstrap \
69+
/usr/local/go/src/cmd/dist/dist \
70+
; \
4171
fi; \
4272
\
43-
export PATH="/usr/local/go/bin:$PATH"; \
4473
go version
4574

4675
ENV GOPATH /go
47-
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
48-
76+
ENV PATH $GOPATH/bin:$PATH
4977
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5078
WORKDIR $GOPATH

1.15-rc/buster/Dockerfile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
99
pkg-config \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
ENV PATH /usr/local/go/bin:$PATH
13+
1214
ENV GOLANG_VERSION 1.15beta1
1315

1416
RUN set -eux; \
@@ -27,24 +29,50 @@ RUN set -eux; \
2729
esac; \
2830
\
2931
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
30-
wget -O go.tgz "$url"; \
32+
wget -O go.tgz "$url" --progress=dot:giga; \
3133
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
3234
tar -C /usr/local -xzf go.tgz; \
3335
rm go.tgz; \
3436
\
37+
# https://github.com/golang/go/issues/38536#issuecomment-616897960
3538
if [ "$goRelArch" = 'src' ]; then \
36-
echo >&2; \
37-
echo >&2 'error: UNIMPLEMENTED'; \
38-
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
39-
echo >&2; \
40-
exit 1; \
39+
savedAptMark="$(apt-mark showmanual)"; \
40+
apt-get update; \
41+
apt-get install -y --no-install-recommends golang-go; \
42+
\
43+
goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; \
44+
eval "$goEnv"; \
45+
[ -n "$GOOS" ]; \
46+
[ -n "$GOARCH" ]; \
47+
( \
48+
cd /usr/local/go/src; \
49+
./make.bash; \
50+
); \
51+
\
52+
apt-mark auto '.*' > /dev/null; \
53+
apt-mark manual $savedAptMark > /dev/null; \
54+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
55+
rm -rf /var/lib/apt/lists/*; \
56+
\
57+
# pre-compile the standard library, just like the official binary release tarballs do
58+
go install std; \
59+
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
60+
# go install -race std; \
61+
\
62+
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
63+
rm -rf \
64+
/usr/local/go/pkg/*/cmd \
65+
/usr/local/go/pkg/bootstrap \
66+
/usr/local/go/pkg/obj \
67+
/usr/local/go/pkg/tool/*/api \
68+
/usr/local/go/pkg/tool/*/go_bootstrap \
69+
/usr/local/go/src/cmd/dist/dist \
70+
; \
4171
fi; \
4272
\
43-
export PATH="/usr/local/go/bin:$PATH"; \
4473
go version
4574

4675
ENV GOPATH /go
47-
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
48-
76+
ENV PATH $GOPATH/bin:$PATH
4977
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5078
WORKDIR $GOPATH

1.15-rc/release-architectures

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)