From b2c2a64da9af4d5e125d87fcb24cbe8fa1d3f17c Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Thu, 20 Aug 2015 16:09:09 -0600 Subject: [PATCH] Version= doesnt work on go1.4.2 fixing makefile & vagrantfile & build script to reflect that --- Makefile | 2 +- Vagrantfile | 5 ++++- circle-test.sh | 16 ++++++++++------ package.sh | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8f253c58d..1e2f9c383 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/Vagrantfile b/Vagrantfile index 08b674a10..79996489f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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| diff --git a/circle-test.sh b/circle-test.sh index fd4a5bcdc..e8c7c131b 100755 --- a/circle-test.sh +++ b/circle-test.sh @@ -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 \ diff --git a/package.sh b/package.sh index df505fa97..57a96d251 100755 --- a/package.sh +++ b/package.sh @@ -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