2015-05-30 09:34:54 +03:00
|
|
|
#!/bin/sh -e
|
2014-09-09 10:06:03 +04:00
|
|
|
|
|
|
|
ORG_PATH="github.com/coreos"
|
|
|
|
REPO_PATH="${ORG_PATH}/etcd"
|
|
|
|
|
2014-09-18 21:57:56 +04:00
|
|
|
export GOPATH=${PWD}/gopath
|
2014-09-09 10:06:03 +04:00
|
|
|
|
2014-09-18 21:57:56 +04:00
|
|
|
rm -f $GOPATH/src/${REPO_PATH}
|
|
|
|
mkdir -p $GOPATH/src/${ORG_PATH}
|
|
|
|
ln -s ${PWD} $GOPATH/src/${REPO_PATH}
|
2014-09-09 10:06:03 +04:00
|
|
|
|
|
|
|
eval $(go env)
|
|
|
|
|
2015-06-05 03:07:28 +03:00
|
|
|
GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
|
2015-05-09 02:49:12 +03:00
|
|
|
|
2015-09-02 08:28:55 +03:00
|
|
|
val=$(go version)
|
2015-12-04 22:37:01 +03:00
|
|
|
# if 'go version' contains string 'devel', it assumes the go tip branch,
|
|
|
|
# which is greater than go 1.5+.
|
2015-12-08 08:05:55 +03:00
|
|
|
if test "${val#*devel}" != "$val"
|
2015-12-04 22:37:01 +03:00
|
|
|
then
|
2015-08-30 13:14:23 +03:00
|
|
|
LINK_OPERATOR="="
|
2015-09-02 08:28:55 +03:00
|
|
|
else
|
2015-12-04 22:37:01 +03:00
|
|
|
ver=$(echo $val | awk -F ' ' '{print $3}' | awk -F '.' '{print $2}')
|
|
|
|
if [ $ver -gt 4 ]; then
|
|
|
|
LINK_OPERATOR="="
|
|
|
|
else
|
|
|
|
LINK_OPERATOR=" "
|
|
|
|
fi
|
2015-08-30 13:14:23 +03:00
|
|
|
fi
|
|
|
|
|
2015-01-12 13:19:53 +03:00
|
|
|
# Static compilation is useful when etcd is run in a container
|
2016-02-09 08:11:44 +03:00
|
|
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s -X ${REPO_PATH}/version.GitSHA${LINK_OPERATOR}${GIT_SHA}" -o bin/etcd ${REPO_PATH}
|
|
|
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o bin/etcdctl ${REPO_PATH}/etcdctl
|