diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index d9f2145..964169a 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -44,11 +44,16 @@ RUN \ ENV PATH /osxcross/target/bin:$PATH -# Inject the Go package downloader and tool-chain bootstrapper +# Inject the old Go package downloader and tool-chain bootstrapper ADD bootstrap.sh /bootstrap.sh ENV BOOTSTRAP /bootstrap.sh RUN chmod +x $BOOTSTRAP +# Inject the new Go root distribution downloader and secondary bootstrapper +ADD bootstrap_pure.sh /bootstrap_pure.sh +ENV BOOTSTRAP_PURE /bootstrap_pure.sh +RUN chmod +x $BOOTSTRAP_PURE + # Inject the C dependency cross compiler ADD build_deps.sh /build_deps.sh ENV BUILD_DEPS /build_deps.sh diff --git a/docker/base/bootstrap.sh b/docker/base/bootstrap.sh index 24c11ab..22bc852 100644 --- a/docker/base/bootstrap.sh +++ b/docker/base/bootstrap.sh @@ -13,7 +13,7 @@ # DIST_OSX_64, DIST_OSX_64_SHA1 - 64 bit Mac OSX Go binaries and checksum # DIST_OSX_32, DIST_OSX_32_SHA1 - 32 bit Mac OSX Go binaries and checksum # DIST_WIN_64, DIST_WIN_64_SHA1 - 64 bit Windows Go binaries and checksum -# DIST_WIN_32, DIST_WIN_32_SHA1 - 32 bit Windows Go binaries and checksum +# DIST_WIN_32, DIST_WIN_32_SHA1 - 32 bit Windows Go binaries and checksum set -e # Download and verify all the binary packages @@ -27,24 +27,41 @@ $FETCH $DIST_WIN_32 $DIST_WIN_32_SHA1 # Extract the 64 bit Linux package as the primary Go SDK tar -C /usr/local -xzf `basename $DIST_LINUX_64` +rm -f `basename $DIST_LINUX_64` + +export GOROOT=/usr/local/go +export GOROOT_BOOTSTRAP=$GOROOT # Extract all other packages as secondary ones, keeping only the binaries -tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_32` go/pkg/linux_386* -GOOS=linux GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap -tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_ARM` go/pkg/linux_arm* -GOOS=linux GOARCH=arm /usr/local/go/pkg/tool/linux_amd64/dist bootstrap +if [ "$DIST_LINUX_32" != "" ]; then + tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_32` go/pkg/linux_386* + GOOS=linux GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap + rm -f `basename $DIST_LINUX_32` +fi +if [ "$DIST_LINUX_ARM" != "" ]; then + tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_ARM` go/pkg/linux_arm* + GOOS=linux GOARCH=arm /usr/local/go/pkg/tool/linux_amd64/dist bootstrap + rm -f `basename $DIST_LINUX_ARM` +fi -tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_64` go/pkg/darwin_amd64* -GOOS=darwin GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap -tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_32` go/pkg/darwin_386* -GOOS=darwin GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap +if [ "$DIST_OSX_64" != "" ]; then + tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_64` go/pkg/darwin_amd64* + GOOS=darwin GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap + rm -f `basename $DIST_OSX_64` +fi +if [ "$DIST_OSX_32" != "" ]; then + tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_32` go/pkg/darwin_386* + GOOS=darwin GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap + rm -f `basename $DIST_OSX_32` +fi -unzip -d /usr/local -q `basename $DIST_WIN_64` go/pkg/windows_amd64* -GOOS=windows GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap -unzip -d /usr/local -q `basename $DIST_WIN_32` go/pkg/windows_386* -GOOS=windows GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap - -# Delete all the intermediate downloaded files -rm -f `basename $DIST_LINUX_64` `basename $DIST_LINUX_32` `basename $DIST_LINUX_ARM` \ - `basename $DIST_OSX_64` `basename $DIST_OSX_32` \ - `basename $DIST_WIN_64` `basename $DIST_WIN_32` +if [ "$DIST_WIN_64" != "" ]; then + unzip -d /usr/local -q `basename $DIST_WIN_64` go/pkg/windows_amd64* + GOOS=windows GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap + rm -f `basename $DIST_WIN_64` +fi +if [ "$DIST_WIN_32" != "" ]; then + unzip -d /usr/local -q `basename $DIST_WIN_32` go/pkg/windows_386* + GOOS=windows GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap + rm -f `basename $DIST_WIN_32` +fi diff --git a/docker/base/bootstrap_pure.sh b/docker/base/bootstrap_pure.sh new file mode 100644 index 0000000..c56ac7c --- /dev/null +++ b/docker/base/bootstrap_pure.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Contains the Go tool-chain pure-Go bootstrapper, that as of Go 1.5, initiates +# not only a few pre-built Go cross compilers, but rather bootstraps all of the +# supported platforms from the origin Linux amd64 distribution. +# +# Usage: bootstrap.sh +# +# Needed environment variables: +# FETCH - Remote file fetcher and checksum verifier (injected by image) +# ROOT_DIST - 64 but Linux Go binary distribution package +# ROOT_DIST_SHA1 - 64 bit Linux Go distribution package checksum +set -e + +# Download, verify and install the root distribution +$FETCH $ROOT_DIST $ROOT_DIST_SHA1 + +tar -C /usr/local -xzf `basename $ROOT_DIST` +rm -f `basename $ROOT_DIST` + +export GOROOT=/usr/local/go +export GOROOT_BOOTSTRAP=$GOROOT + +# Pre-build all guest distributions based on the root distribution +echo "Bootstrapping linux/386..." +GOOS=linux GOARCH=386 CGO_ENABLED=1 go install std + +echo "Bootstrapping linux/arm..." +GOOS=linux GOARCH=arm CGO_ENABLED=1 CC=arm-linux-gnueabi-gcc go install std + +echo "Bootstrapping windows/amd64..." +GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go install std + +echo "Bootstrapping windows/386..." +GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go install std + +echo "Bootstrapping darwin/amd64..." +GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=o64-clang go install std + +echo "Bootstrapping darwin/386..." +GOOS=darwin GOARCH=386 CGO_ENABLED=1 CC=o32-clang go install std diff --git a/docker/base/build.sh b/docker/base/build.sh index 0099f73..d7d6845 100644 --- a/docker/base/build.sh +++ b/docker/base/build.sh @@ -92,12 +92,12 @@ CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 CGO_ENABLED=1 go build $V -o $NA echo "Compiling for darwin/amd64..." CC=o64-clang HOST=x86_64-apple-darwin10 PREFIX=/usr/local $BUILD_DEPS /deps CC=o64-clang GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go get -d ./$PACK -CC=o64-clang GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $R -o $NAME-darwin-amd64$R ./$PACK +CC=o64-clang GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -ldflags=-s $V $R -o $NAME-darwin-amd64$R ./$PACK echo "Compiling for darwin/386..." CC=o32-clang HOST=i386-apple-darwin10 PREFIX=/usr/local $BUILD_DEPS /deps CC=o32-clang GOOS=darwin GOARCH=386 CGO_ENABLED=1 go get -d ./$PACK -CC=o32-clang GOOS=darwin GOARCH=386 CGO_ENABLED=1 go build $V -o $NAME-darwin-386 ./$PACK +CC=o32-clang GOOS=darwin GOARCH=386 CGO_ENABLED=1 go build -ldflags=-s $V -o $NAME-darwin-386 ./$PACK echo "Moving binaries to host..." cp `ls -t | head -n 7` /build diff --git a/docker/base/fetch.sh b/docker/base/fetch.sh index d0b5039..35926c1 100644 --- a/docker/base/fetch.sh +++ b/docker/base/fetch.sh @@ -6,6 +6,12 @@ # Usage: fetch.sh set -e +# Skip the download if no operands specified +if [ "$1" == "" -o "$2" == "" ]; then + echo "Fetch operands missing, skipping..." + exit +fi + # Pull the file from the remote URL file=`basename $1` echo "Downloading $1..." diff --git a/docker/go-1.5.0/Dockerfile b/docker/go-1.5.0/Dockerfile new file mode 100644 index 0000000..6db3414 --- /dev/null +++ b/docker/go-1.5.0/Dockerfile @@ -0,0 +1,15 @@ +# Go cross compiler (xgo): Go 1.5.0 layer +# Copyright (c) 2015 Péter Szilágyi. All rights reserved. +# +# Released under the MIT license. + +FROM karalabe/xgo-base + +MAINTAINER Péter Szilágyi + +# Configure the root Go distribution and bootstrap based on it +RUN \ + export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz && \ + export ROOT_DIST_SHA1=5817fa4b2252afdb02e11e8b9dc1d9173ef3bd5a && \ + \ + $BOOTSTRAP_PURE diff --git a/docker/go-1.5.1/Dockerfile b/docker/go-1.5.1/Dockerfile new file mode 100644 index 0000000..5e31278 --- /dev/null +++ b/docker/go-1.5.1/Dockerfile @@ -0,0 +1,15 @@ +# Go cross compiler (xgo): Go 1.5.1 layer +# Copyright (c) 2015 Péter Szilágyi. All rights reserved. +# +# Released under the MIT license. + +FROM karalabe/xgo-base + +MAINTAINER Péter Szilágyi + +# Configure the root Go distribution and bootstrap based on it +RUN \ + export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz && \ + export ROOT_DIST_SHA1=46eecd290d8803887dec718c691cc243f2175fe0 && \ + \ + $BOOTSTRAP_PURE diff --git a/docker/go-1.5.x/Dockerfile b/docker/go-1.5.x/Dockerfile new file mode 100644 index 0000000..d8c1b46 --- /dev/null +++ b/docker/go-1.5.x/Dockerfile @@ -0,0 +1,8 @@ +# Go cross compiler (xgo): Wildcard layer to the latest 1.5 release +# Copyright (c) 2015 Péter Szilágyi. All rights reserved. +# +# Released under the MIT license. + +FROM karalabe/xgo-1.5.1 + +MAINTAINER Péter Szilágyi diff --git a/docker/go-latest/Dockerfile b/docker/go-latest/Dockerfile index fa34702..130531a 100644 --- a/docker/go-latest/Dockerfile +++ b/docker/go-latest/Dockerfile @@ -3,6 +3,6 @@ # # Released under the MIT license. -FROM karalabe/xgo-1.4.x +FROM karalabe/xgo-1.5.x MAINTAINER Péter Szilágyi