Browse code

Add new "cross" bundle to cross-compile the Docker client for other platforms (currently just 32-bit and 64-bit OS X)

Tianon Gravi authored on 2013/12/19 15:06:14
Showing 5 changed files
... ...
@@ -39,7 +39,12 @@ RUN	apt-get install -y -q build-essential libsqlite3-dev
39 39
 RUN	curl -s https://go.googlecode.com/files/go1.2.src.tar.gz | tar -v -C /usr/local -xz
40 40
 ENV	PATH	/usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
41 41
 ENV	GOPATH	/go:/go/src/github.com/dotcloud/docker/vendor
42
-RUN	cd /usr/local/go/src && ./make.bash
42
+RUN	cd /usr/local/go/src && ./make.bash --no-clean 2>&1
43
+
44
+# Cross compilation
45
+ENV	DOCKER_CROSSPLATFORMS	darwin/amd64 darwin/386
46
+# TODO add linux/386 and linux/arm
47
+RUN	cd /usr/local/go/src && bash -xc 'for platform in $DOCKER_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
43 48
 
44 49
 # Ubuntu stuff
45 50
 RUN	apt-get install -y -q ruby1.9.3 rubygems libffi-dev
... ...
@@ -1,4 +1,4 @@
1
-.PHONY: all binary build default docs shell test
1
+.PHONY: all binary build cross default docs shell test
2 2
 
3 3
 DOCKER_RUN_DOCKER := docker run -rm -i -t -privileged -e TESTFLAGS -v $(CURDIR)/bundles:/go/src/github.com/dotcloud/docker/bundles docker
4 4
 
... ...
@@ -10,6 +10,9 @@ all: build
10 10
 binary: build
11 11
 	$(DOCKER_RUN_DOCKER) hack/make.sh binary
12 12
 
13
+cross: build
14
+	$(DOCKER_RUN_DOCKER) hack/make.sh cross
15
+
13 16
 docs:
14 17
 	docker build -t docker-docs docs && docker run -p 8000:8000 docker-docs
15 18
 
... ...
@@ -40,6 +40,7 @@ DEFAULT_BUNDLES=(
40 40
 	dyntest
41 41
 	dyntest-integration
42 42
 	cover
43
+	cross
43 44
 	tgz
44 45
 	ubuntu
45 46
 )
46 47
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+#!/bin/bash
1
+
2
+DEST=$1
3
+
4
+for platform in $DOCKER_CROSSPLATFORMS; do
5
+	(
6
+		export GOOS=${platform%/*}
7
+		export GOARCH=${platform##*/}
8
+		export VERSION="$GOOS-$GOARCH-$VERSION" # for a nice filename
9
+		export LDFLAGS_STATIC="" # we just need a simple client for these platforms (TODO this might change someday)
10
+		source "$(dirname "$BASH_SOURCE")/binary"
11
+	)
12
+done
... ...
@@ -47,6 +47,7 @@ cd /go/src/github.com/dotcloud/docker
47 47
 
48 48
 RELEASE_BUNDLES=(
49 49
 	binary
50
+	cross
50 51
 	tgz
51 52
 	ubuntu
52 53
 )
... ...
@@ -233,6 +234,16 @@ EOF
233 233
 	fi
234 234
 }
235 235
 
236
+# Upload a cross-compiled client binaries to S3
237
+release_cross() {
238
+	[ -e bundles/$VERSION/cross ] || {
239
+		echo >&2 './hack/make.sh must be run before release_binary'
240
+		exit 1
241
+	}
242
+	
243
+	# TODO find out from @shykes what URLs he'd like to use here
244
+}
245
+
236 246
 # Upload the index script
237 247
 release_index() {
238 248
 	sed "s,https://get.docker.io/,$(s3_url)/," hack/install.sh | write_to_s3 s3://$BUCKET/index
... ...
@@ -247,6 +258,7 @@ release_test() {
247 247
 main() {
248 248
 	setup_s3
249 249
 	release_binary
250
+	release_cross
250 251
 	release_tgz
251 252
 	release_ubuntu
252 253
 	release_index