2015-05-08 09:21:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Contains the Go tool-chain bootstrapper, that retrieves all the configured
|
|
|
|
# distribution packages, extracts the binaries and deletes anything not needed.
|
|
|
|
#
|
|
|
|
# Usage: bootstrap.sh
|
|
|
|
#
|
|
|
|
# Needed environment variables:
|
|
|
|
# FETCH - Remote file fetcher and checksum verifier (injected by image)
|
2016-01-14 10:14:59 +00:00
|
|
|
# DIST_LINUX_64, DIST_LINUX_64_SHA - 64 bit Linux Go binaries and checksum
|
|
|
|
# DIST_LINUX_32, DIST_LINUX_32_SHA - 32 bit Linux Go binaries and checksum
|
|
|
|
# DIST_LINUX_ARM, DIST_LINUX_ARM_SHA - ARM v5 Linux Go binaries and checksum
|
|
|
|
# DIST_OSX_64, DIST_OSX_64_SHA - 64 bit Mac OSX Go binaries and checksum
|
|
|
|
# DIST_OSX_32, DIST_OSX_32_SHA - 32 bit Mac OSX Go binaries and checksum
|
|
|
|
# DIST_WIN_64, DIST_WIN_64_SHA - 64 bit Windows Go binaries and checksum
|
|
|
|
# DIST_WIN_32, DIST_WIN_32_SHA - 32 bit Windows Go binaries and checksum
|
2015-05-08 09:21:51 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# Download and verify all the binary packages
|
2016-01-14 10:14:59 +00:00
|
|
|
$FETCH $DIST_LINUX_64 $DIST_LINUX_64_SHA
|
|
|
|
$FETCH $DIST_LINUX_32 $DIST_LINUX_32_SHA
|
|
|
|
$FETCH $DIST_LINUX_ARM $DIST_LINUX_ARM_SHA
|
|
|
|
$FETCH $DIST_OSX_64 $DIST_OSX_64_SHA
|
|
|
|
$FETCH $DIST_OSX_32 $DIST_OSX_32_SHA
|
|
|
|
$FETCH $DIST_WIN_64 $DIST_WIN_64_SHA
|
|
|
|
$FETCH $DIST_WIN_32 $DIST_WIN_32_SHA
|
2015-05-08 09:21:51 +00:00
|
|
|
|
|
|
|
# Extract the 64 bit Linux package as the primary Go SDK
|
|
|
|
tar -C /usr/local -xzf `basename $DIST_LINUX_64`
|
2015-09-10 08:37:52 +00:00
|
|
|
rm -f `basename $DIST_LINUX_64`
|
2015-05-08 09:21:51 +00:00
|
|
|
|
2015-09-10 08:37:52 +00:00
|
|
|
export GOROOT=/usr/local/go
|
|
|
|
export GOROOT_BOOTSTRAP=$GOROOT
|
2015-05-08 09:21:51 +00:00
|
|
|
|
2015-09-10 08:37:52 +00:00
|
|
|
# Extract all other packages as secondary ones, keeping only the binaries
|
|
|
|
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
|
2015-05-08 09:21:51 +00:00
|
|
|
|
2015-09-10 08:37:52 +00:00
|
|
|
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
|
2015-05-08 09:21:51 +00:00
|
|
|
|
2015-09-10 08:37:52 +00:00
|
|
|
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
|
2015-11-27 11:37:46 +00:00
|
|
|
|
|
|
|
# Install xgo within the container to enable internal cross compilation
|
|
|
|
echo "Installing xgo-in-xgo..."
|
|
|
|
go get -u github.com/karalabe/xgo
|