Browse code

Add slightly better GOPATH detection/handling

This also adds a new "AUTO_GOPATH" environment variable that will create an appropriate GOPATH as part of the build process.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Tianon Gravi authored on 2014/02/10 10:21:01
Showing 1 changed files
... ...
@@ -68,6 +68,19 @@ else
68 68
 	exit 1
69 69
 fi
70 70
 
71
+if [ "$AUTO_GOPATH" ]; then
72
+	rm -rf .gopath
73
+	mkdir -p .gopath/src/github.com/dotcloud
74
+	ln -sf ../../../.. .gopath/src/github.com/dotcloud/docker
75
+	export GOPATH="$(pwd)/.gopath:$(pwd)/vendor"
76
+fi
77
+
78
+if [ ! "$GOPATH" ]; then
79
+	echo >&2 'error: missing GOPATH; please see http://golang.org/doc/code.html#GOPATH'
80
+	echo >&2 '  alternatively, set AUTO_GOPATH=1'
81
+	exit 1
82
+fi
83
+
71 84
 # Use these flags when compiling the tests and final binary
72 85
 LDFLAGS='-X main.GITCOMMIT "'$GITCOMMIT'" -X main.VERSION "'$VERSION'" -w'
73 86
 LDFLAGS_STATIC='-X github.com/dotcloud/docker/utils.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"'