Skip to content

Commit 108d578

Browse files
authored
Merge pull request #162 from infosiftr/alpine3.6
Add alpine3.6 variants
2 parents 64b88dc + 495a742 commit 108d578

File tree

10 files changed

+377
-3
lines changed

10 files changed

+377
-3
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ env:
55
- VERSION=1.8 VARIANT=
66
- VERSION=1.8 VARIANT=stretch
77
- VERSION=1.8 VARIANT=alpine
8+
- VERSION=1.8 VARIANT=alpine3.6
89
- VERSION=1.7 VARIANT=
910
- VERSION=1.7 VARIANT=wheezy
1011
- VERSION=1.7 VARIANT=alpine
12+
- VERSION=1.7 VARIANT=alpine3.6
1113
- VERSION=1.7 VARIANT=alpine3.5
1214

1315
install:

1.7/alpine3.6/17847.patch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 14f4fa9..bf2de57 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1251,6 +1251,28 @@ func hostlink() {
6+
}
7+
}
8+
9+
+ // When building a program with the default -buildmode=exe the
10+
+ // gc compiler generates code requires DT_TEXTREL in a
11+
+ // position independent executable (PIE). On systems where the
12+
+ // toolchain creates PIEs by default, and where DT_TEXTREL
13+
+ // does not work, the resulting programs will not run. See
14+
+ // issue #17847. To avoid this problem pass -no-pie to the
15+
+ // toolchain if it is supported.
16+
+ if Buildmode == BuildmodeExe {
17+
+ src := filepath.Join(tmpdir, "trivial.c")
18+
+ if err := ioutil.WriteFile(src, []byte{}, 0666); err != nil {
19+
+ Ctxt.Diag("WriteFile trivial.c failed: %v", err)
20+
+ }
21+
+ cmd := exec.Command(argv[0], "-c", "-no-pie", "trivial.c")
22+
+ cmd.Dir = tmpdir
23+
+ cmd.Env = append([]string{"LC_ALL=C"}, os.Environ()...)
24+
+ out, err := cmd.CombinedOutput()
25+
+ supported := err == nil && !bytes.Contains(out, []byte("unrecognized"))
26+
+ if supported {
27+
+ argv = append(argv, "-no-pie")
28+
+ }
29+
+ }
30+
+
31+
for _, p := range strings.Fields(extldflags) {
32+
argv = append(argv, p)
33+

1.7/alpine3.6/Dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
FROM alpine:3.6
2+
3+
RUN apk add --no-cache ca-certificates
4+
5+
ENV GOLANG_VERSION 1.7.6
6+
7+
# https://golang.org/issue/14851 (Go 1.8 & 1.7)
8+
# https://golang.org/issue/17847 (Go 1.7)
9+
COPY *.patch /go-alpine-patches/
10+
11+
RUN set -eux; \
12+
apk add --no-cache --virtual .build-deps \
13+
bash \
14+
gcc \
15+
musl-dev \
16+
openssl \
17+
go \
18+
; \
19+
export \
20+
# set GOROOT_BOOTSTRAP such that we can actually build Go
21+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
22+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
23+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
24+
GOOS="$(go env GOOS)" \
25+
GOARCH="$(go env GOARCH)" \
26+
GO386="$(go env GO386)" \
27+
GOARM="$(go env GOARM)" \
28+
GOHOSTOS="$(go env GOHOSTOS)" \
29+
GOHOSTARCH="$(go env GOHOSTARCH)" \
30+
; \
31+
\
32+
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
33+
echo '1a67a4e688673fdff7ba41e73482b0e59ac5bd0f7acf703bc6d50cc775c5baba *go.tgz' | sha256sum -c -; \
34+
tar -C /usr/local -xzf go.tgz; \
35+
rm go.tgz; \
36+
\
37+
cd /usr/local/go/src; \
38+
for p in /go-alpine-patches/*.patch; do \
39+
[ -f "$p" ] || continue; \
40+
patch -p2 -i "$p"; \
41+
done; \
42+
./make.bash; \
43+
\
44+
rm -rf /go-alpine-patches; \
45+
apk del .build-deps; \
46+
\
47+
export PATH="/usr/local/go/bin:$PATH"; \
48+
go version
49+
50+
ENV GOPATH /go
51+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
52+
53+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
54+
WORKDIR $GOPATH
55+
56+
COPY go-wrapper /usr/local/bin/

1.7/alpine3.6/go-wrapper

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
set -e
3+
4+
usage() {
5+
base="$(basename "$0")"
6+
cat <<EOUSAGE
7+
8+
usage: $base command [args]
9+
10+
This script assumes that is is run from the root of your Go package (for
11+
example, "/go/src/app" if your GOPATH is set to "/go").
12+
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
26+
27+
Available Commands:
28+
29+
$base download
30+
$base download -u
31+
(equivalent to "go get -d [args] [godir]")
32+
33+
$base install
34+
$base install -race
35+
(equivalent to "go install [args] [godir]")
36+
37+
$base run
38+
$base run -app -specific -arguments
39+
(assumes "GOPATH/bin" is in "PATH")
40+
41+
EOUSAGE
42+
}
43+
44+
# make sure there is a subcommand specified
45+
if [ "$#" -eq 0 ]; then
46+
usage >&2
47+
exit 1
48+
fi
49+
# "shift" so that "$@" becomes the remaining arguments and can be passed along to other "go" subcommands easily
50+
cmd="$1"
51+
shift
52+
53+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
54+
55+
if [ -z "$goDir" -a -s .godir ]; then
56+
goDir="$(cat .godir)"
57+
fi
58+
59+
dir="$(pwd -P)"
60+
if [ "$goDir" ]; then
61+
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
62+
goDirPath="$goPath/src/$goDir"
63+
mkdir -p "$(dirname "$goDirPath")"
64+
if [ ! -e "$goDirPath" ]; then
65+
ln -sfv "$dir" "$goDirPath"
66+
elif [ ! -L "$goDirPath" ]; then
67+
echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!"
68+
exit 1
69+
fi
70+
goBin="$goPath/bin/$(basename "$goDir")"
71+
else
72+
goBin="$(basename "$dir")" # likely "app"
73+
fi
74+
75+
case "$cmd" in
76+
download)
77+
set -- go get -v -d "$@"
78+
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
79+
set -x; exec "$@"
80+
;;
81+
82+
install)
83+
set -- go install -v "$@"
84+
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
85+
set -x; exec "$@"
86+
;;
87+
88+
run)
89+
set -x; exec "$goBin" "$@"
90+
;;
91+
92+
*)
93+
echo >&2 'error: unknown command:' "$cmd"
94+
usage >&2
95+
exit 1
96+
;;
97+
esac

1.7/alpine3.6/no-pic.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 14f4fa9..5599307 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1272,6 +1272,11 @@ func hostlink() {
6+
argv = append(argv, peimporteddlls()...)
7+
}
8+
9+
+ // The Go linker does not currently support building PIE
10+
+ // executables when using the external linker. See:
11+
+ // https://github.com/golang/go/issues/6940
12+
+ argv = append(argv, "-fno-PIC")
13+
+
14+
if Debug['v'] != 0 {
15+
fmt.Fprintf(Bso, "host link:")
16+
for _, v := range argv {

1.8/alpine3.6/Dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
FROM alpine:3.6
2+
3+
RUN apk add --no-cache ca-certificates
4+
5+
ENV GOLANG_VERSION 1.8.3
6+
7+
# https://golang.org/issue/14851 (Go 1.8 & 1.7)
8+
# https://golang.org/issue/17847 (Go 1.7)
9+
COPY *.patch /go-alpine-patches/
10+
11+
RUN set -eux; \
12+
apk add --no-cache --virtual .build-deps \
13+
bash \
14+
gcc \
15+
musl-dev \
16+
openssl \
17+
go \
18+
; \
19+
export \
20+
# set GOROOT_BOOTSTRAP such that we can actually build Go
21+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
22+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
23+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
24+
GOOS="$(go env GOOS)" \
25+
GOARCH="$(go env GOARCH)" \
26+
GO386="$(go env GO386)" \
27+
GOARM="$(go env GOARM)" \
28+
GOHOSTOS="$(go env GOHOSTOS)" \
29+
GOHOSTARCH="$(go env GOHOSTARCH)" \
30+
; \
31+
\
32+
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
33+
echo '5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6 *go.tgz' | sha256sum -c -; \
34+
tar -C /usr/local -xzf go.tgz; \
35+
rm go.tgz; \
36+
\
37+
cd /usr/local/go/src; \
38+
for p in /go-alpine-patches/*.patch; do \
39+
[ -f "$p" ] || continue; \
40+
patch -p2 -i "$p"; \
41+
done; \
42+
./make.bash; \
43+
\
44+
rm -rf /go-alpine-patches; \
45+
apk del .build-deps; \
46+
\
47+
export PATH="/usr/local/go/bin:$PATH"; \
48+
go version
49+
50+
ENV GOPATH /go
51+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
52+
53+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
54+
WORKDIR $GOPATH
55+
56+
COPY go-wrapper /usr/local/bin/

1.8/alpine3.6/go-wrapper

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
set -e
3+
4+
usage() {
5+
base="$(basename "$0")"
6+
cat <<EOUSAGE
7+
8+
usage: $base command [args]
9+
10+
This script assumes that is is run from the root of your Go package (for
11+
example, "/go/src/app" if your GOPATH is set to "/go").
12+
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
26+
27+
Available Commands:
28+
29+
$base download
30+
$base download -u
31+
(equivalent to "go get -d [args] [godir]")
32+
33+
$base install
34+
$base install -race
35+
(equivalent to "go install [args] [godir]")
36+
37+
$base run
38+
$base run -app -specific -arguments
39+
(assumes "GOPATH/bin" is in "PATH")
40+
41+
EOUSAGE
42+
}
43+
44+
# make sure there is a subcommand specified
45+
if [ "$#" -eq 0 ]; then
46+
usage >&2
47+
exit 1
48+
fi
49+
# "shift" so that "$@" becomes the remaining arguments and can be passed along to other "go" subcommands easily
50+
cmd="$1"
51+
shift
52+
53+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
54+
55+
if [ -z "$goDir" -a -s .godir ]; then
56+
goDir="$(cat .godir)"
57+
fi
58+
59+
dir="$(pwd -P)"
60+
if [ "$goDir" ]; then
61+
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
62+
goDirPath="$goPath/src/$goDir"
63+
mkdir -p "$(dirname "$goDirPath")"
64+
if [ ! -e "$goDirPath" ]; then
65+
ln -sfv "$dir" "$goDirPath"
66+
elif [ ! -L "$goDirPath" ]; then
67+
echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!"
68+
exit 1
69+
fi
70+
goBin="$goPath/bin/$(basename "$goDir")"
71+
else
72+
goBin="$(basename "$dir")" # likely "app"
73+
fi
74+
75+
case "$cmd" in
76+
download)
77+
set -- go get -v -d "$@"
78+
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
79+
set -x; exec "$@"
80+
;;
81+
82+
install)
83+
set -- go install -v "$@"
84+
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
85+
set -x; exec "$@"
86+
;;
87+
88+
run)
89+
set -x; exec "$goBin" "$@"
90+
;;
91+
92+
*)
93+
echo >&2 'error: unknown command:' "$cmd"
94+
usage >&2
95+
exit 1
96+
;;
97+
esac

1.8/alpine3.6/no-pic.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 14f4fa9..5599307 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1272,6 +1272,11 @@ func hostlink() {
6+
argv = append(argv, peimporteddlls()...)
7+
}
8+
9+
+ // The Go linker does not currently support building PIE
10+
+ // executables when using the external linker. See:
11+
+ // https://github.com/golang/go/issues/6940
12+
+ argv = append(argv, "-fno-PIC")
13+
+
14+
if l.Debugvlog != 0 {
15+
l.Logf("%5.2f host link:", obj.Cputime())
16+
for _, v := range argv {

generate-stackbrew-library.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ for version in "${versions[@]}"; do
7979
EOE
8080

8181
for v in \
82-
onbuild wheezy stretch alpine alpine3.5 \
82+
onbuild wheezy stretch alpine alpine3.6 alpine3.5 \
8383
windows/windowsservercore windows/nanoserver \
8484
; do
8585
dir="$version/$v"

0 commit comments

Comments
 (0)