build 943 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh -e
  2. ORG_PATH="github.com/coreos"
  3. REPO_PATH="${ORG_PATH}/etcd"
  4. export GOPATH=${PWD}/gopath
  5. rm -f $GOPATH/src/${REPO_PATH}
  6. mkdir -p $GOPATH/src/${ORG_PATH}
  7. ln -s ${PWD} $GOPATH/src/${REPO_PATH}
  8. eval $(go env)
  9. GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
  10. val=$(go version)
  11. # if 'go version' contains string 'devel', it assumes the go tip branch,
  12. # which is greater than go 1.5+.
  13. if test "${val#*devel}" != "$val"
  14. then
  15. LINK_OPERATOR="="
  16. else
  17. ver=$(echo $val | awk -F ' ' '{print $3}' | awk -F '.' '{print $2}')
  18. if [ $ver -gt 4 ]; then
  19. LINK_OPERATOR="="
  20. else
  21. LINK_OPERATOR=" "
  22. fi
  23. fi
  24. # Static compilation is useful when etcd is run in a container
  25. 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}
  26. CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o bin/etcdctl ${REPO_PATH}/etcdctl