2015-11-09 12:37:23 +03:00
|
|
|
#!/bin/bash -x
|
2014-03-05 04:36:05 +04:00
|
|
|
|
2015-11-09 11:24:52 +03:00
|
|
|
ORG_PATH="github.com/coreos"
|
|
|
|
REPO_PATH="${ORG_PATH}/coreos-cloudinit"
|
2015-11-09 11:15:44 +03:00
|
|
|
VERSION=$(git describe --tags)
|
2015-11-09 12:08:44 +03:00
|
|
|
GLDFLAGS="-X main.version=${VERSION}"
|
2014-05-10 12:42:57 +04:00
|
|
|
|
2015-11-09 10:23:54 +03:00
|
|
|
rm -rf bin tmp
|
|
|
|
|
|
|
|
export GO15VENDOREXPERIMENT=1
|
2014-03-05 04:36:05 +04:00
|
|
|
export GOBIN=${PWD}/bin
|
2015-11-09 10:23:54 +03:00
|
|
|
export GOPATH=${PWD}/gopath
|
2015-03-30 12:05:49 +03:00
|
|
|
mkdir -p $GOBIN
|
2015-11-09 10:23:54 +03:00
|
|
|
mkdir -p $GOPATH
|
2015-11-09 12:39:24 +03:00
|
|
|
mkdir -p bin tmp
|
2015-11-09 10:23:54 +03:00
|
|
|
|
2016-09-27 09:09:55 +03:00
|
|
|
which go 2>/dev/null
|
2015-11-09 10:23:54 +03:00
|
|
|
|
|
|
|
if [ "x$?" != "x0" ]; then
|
|
|
|
export GOROOT=$(pwd)/goroot
|
|
|
|
export PATH=$GOROOT/bin:$PATH
|
|
|
|
mkdir -p $GOROOT
|
|
|
|
wget https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz -O tmp/go.tar.gz
|
|
|
|
tar --strip-components=1 -C $GOROOT -xf tmp/go.tar.gz
|
|
|
|
fi
|
2014-03-05 04:36:05 +04:00
|
|
|
|
2015-03-30 10:51:56 +03:00
|
|
|
if [ ! -h $GOPATH/src/${REPO_PATH} ]; then
|
|
|
|
mkdir -p $GOPATH/src/${ORG_PATH}
|
|
|
|
ln -s ../../../.. $GOPATH/src/${REPO_PATH} || echo "exit 255"
|
|
|
|
fi
|
|
|
|
|
2015-11-09 12:37:23 +03:00
|
|
|
set -e
|
|
|
|
|
|
|
|
for os in linux freebsd netbsd openbsd windows; do
|
2015-11-09 11:15:44 +03:00
|
|
|
GOOS=${os} go build -x -ldflags "${GLDFLAGS}" -tags netgo -o bin/cloudinit-${os}-x86_64 ${REPO_PATH}
|
|
|
|
GOOS=${os} GOARCH=386 go build -x -ldflags "${GLDFLAGS}" -tags netgo -o bin/cloudinit-${os}-x86_32 ${REPO_PATH}
|
2015-03-28 20:04:09 +03:00
|
|
|
done
|