Browse Source

build: support building out of path when GOPATH is not set

Otherwise gets "go: GOPATH entry is relative; must be absolute path: ""."
Anthony Romano 9 years ago
parent
commit
1e3a71d098
2 changed files with 5 additions and 2 deletions
  1. 1 1
      .travis.yml
  2. 4 1
      build

+ 1 - 1
.travis.yml

@@ -55,6 +55,6 @@ script:
         ;;
         ;;
       *)
       *)
         # test building out of gopath
         # test building out of gopath
-        GO_BUILD_FLAGS="-a -v" GOPATH=/bad-go-path GOARCH="${TARGET}" ./build
+        GO_BUILD_FLAGS="-a -v" GOPATH="" GOARCH="${TARGET}" ./build
         ;;
         ;;
     esac
     esac

+ 4 - 1
build

@@ -40,7 +40,10 @@ etcd_setup_gopath() {
 	cd "$CDIR"
 	cd "$CDIR"
 	etcdGOPATH=${CDIR}/gopath
 	etcdGOPATH=${CDIR}/gopath
 	# preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
 	# preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
-	export GOPATH=${etcdGOPATH}:$GOPATH
+	if [ -n "$GOPATH" ]; then
+		GOPATH=":$GOPATH"
+	fi
+	export GOPATH=${etcdGOPATH}$GOPATH
 	rm -f ${etcdGOPATH}/src
 	rm -f ${etcdGOPATH}/src
 	mkdir -p ${etcdGOPATH}
 	mkdir -p ${etcdGOPATH}
 	ln -s ${CDIR}/cmd/vendor ${etcdGOPATH}/src
 	ln -s ${CDIR}/cmd/vendor ${etcdGOPATH}/src