Version= doesnt work on go1.4.2

fixing makefile & vagrantfile & build script to reflect that
This commit is contained in:
Cameron Sparr 2015-08-20 16:09:09 -06:00
parent a29b39e17a
commit 9d00b5e165
4 changed files with 16 additions and 9 deletions

View File

@ -3,7 +3,7 @@ VERSION := $(shell sh -c 'git describe --always --tags')
build: prepare
$(GOPATH)/bin/godep go build -o telegraf -ldflags \
"-X main.Version=$(VERSION)" \
"-X main.Version $(VERSION)" \
./cmd/telegraf/telegraf.go
prepare:

5
Vagrantfile vendored
View File

@ -22,7 +22,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
gvm install go1.4.2 --prefer-binary
gvm use go1.4.2 --default
echo "export PATH=$PATH:$GOPATH/bin" >> "$HOME/.bashrc"
cd "$HOME/go/src/github.com/influxdb/telegraf" && make
echo 'export GOPATH=/home/vagrant/go' >> "$HOME/.bashrc"
cd "$HOME/go/src/github.com/influxdb/telegraf" &&\
rm -rf Godeps/_workspace/pkg &&\
GOPATH="$HOME/go" make
SHELL
config.vm.provider "virtualbox" do |vb|

View File

@ -5,6 +5,7 @@
# build process for InfluxDB.
BUILD_DIR=$HOME/telegraf-build
VERSION=`git describe --always --tags`
# GO_VERSION=go1.4.2
# source $HOME/.gvm/scripts/gvm
# exit_if_fail gvm use $GO_VERSION
@ -13,7 +14,7 @@ BUILD_DIR=$HOME/telegraf-build
function exit_if_fail {
command=$@
echo "Executing '$command'"
$command
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
@ -25,7 +26,7 @@ function exit_if_fail {
function build {
echo -n "=> $1-$2: "
GOOS=$1 GOARCH=$2 godep go build -o telegraf-$1-$2 \
-ldflags "-X main.Version=$3" \
-ldflags "-X main.Version $3" \
./cmd/telegraf/telegraf.go
du -h telegraf-$1-$2
}
@ -61,11 +62,14 @@ exit_if_fail godep go vet ./...
exit_if_fail godep go test -v -short ./...
# Build binaries
build "linux" "amd64" `git describe --always --tags`
build "linux" "386" `git describe --always --tags`
build "linux" "arm" `git describe --always --tags`
build "linux" "amd64" $VERSION
build "linux" "386" $VERSION
build "linux" "arm" $VERSION
# simple integration test
# Simple Integration Tests
# check that version was properly set
exit_if_fail "./telegraf-linux-amd64 -version | grep $VERSION"
# check that one test cpu & mem output work
tmpdir=$(mktemp -d)
./telegraf-linux-amd64 -sample-config > $tmpdir/config.toml
exit_if_fail ./telegraf-linux-amd64 -config $tmpdir/config.toml \

View File

@ -141,7 +141,7 @@ do_build() {
rm -f $GOPATH_INSTALL/bin/$b
done
godep go install -a -ldflags="-X main.Version=$version" ./...
godep go install -a -ldflags="-X main.Version $version" ./...
if [ $? -ne 0 ]; then
echo "Build failed, unable to create package -- aborting"
cleanup_exit 1