Browse code

Update cross and tgz to play nicely together (creating a tgz for each supported OS/ARCH), and update release.sh to upload binaries and tgz files for all the supported OS/ARCH combos

Tianon Gravi authored on 2013/12/24 15:31:53
Showing 4 changed files
... ...
@@ -11,7 +11,7 @@ binary: build
11 11
 	$(DOCKER_RUN_DOCKER) hack/make.sh binary
12 12
 
13 13
 cross: build
14
-	$(DOCKER_RUN_DOCKER) hack/make.sh cross
14
+	$(DOCKER_RUN_DOCKER) hack/make.sh binary cross
15 15
 
16 16
 docs:
17 17
 	docker build -t docker-docs docs && docker run -p 8000:8000 docker-docs
... ...
@@ -2,12 +2,22 @@
2 2
 
3 3
 DEST=$1
4 4
 
5
+# if we have our linux/amd64 version compiled, let's symlink it in
6
+if [ -x "$DEST/../binary/docker-$VERSION" ]; then
7
+	mkdir -p "$DEST/linux/amd64"
8
+	(
9
+		cd "$DEST/linux/amd64"
10
+		ln -s ../../../binary/* ./
11
+	)
12
+	echo "Created symlinks:" "$DEST/linux/amd64/"*
13
+fi
14
+
5 15
 for platform in $DOCKER_CROSSPLATFORMS; do
6 16
 	(
17
+		mkdir -p "$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
7 18
 		export GOOS=${platform%/*}
8 19
 		export GOARCH=${platform##*/}
9
-		export VERSION="$GOOS-$GOARCH-$VERSION" # for a nice filename
10 20
 		export LDFLAGS_STATIC="" # we just need a simple client for these platforms (TODO this might change someday)
11
-		source "$(dirname "$BASH_SOURCE")/binary"
21
+		source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform"
12 22
 	)
13 23
 done
... ...
@@ -1,23 +1,29 @@
1 1
 #!/bin/bash
2 2
 
3 3
 DEST="$1"
4
-BINARY="$DEST/../binary/docker-$VERSION"
5
-TGZ="$DEST/docker-$VERSION.tgz"
4
+CROSS="$DEST/../cross"
6 5
 
7 6
 set -e
8 7
 
9
-if [ ! -x "$BINARY" ]; then
10
-	echo >&2 'error: binary must be run before tgz'
8
+if [ ! -d "$CROSS/linux/amd64" ]; then
9
+	echo >&2 'error: binary and cross must be run before tgz'
11 10
 	false
12 11
 fi
13 12
 
14
-mkdir -p "$DEST/build"
15
-
16
-mkdir -p "$DEST/build/usr/local/bin"
17
-cp -L "$BINARY" "$DEST/build/usr/local/bin/docker"
18
-
19
-tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr
20
-
21
-rm -rf "$DEST/build"
22
-
23
-echo "Created tgz: $TGZ"
13
+for d in "$CROSS/"*/*; do
14
+	GOARCH="$(basename "$d")"
15
+	GOOS="$(basename "$(dirname "$d")")"
16
+	mkdir -p "$DEST/$GOOS/$GOARCH"
17
+	TGZ="$DEST/$GOOS/$GOARCH/docker-$VERSION.tgz"
18
+	
19
+	mkdir -p "$DEST/build"
20
+	
21
+	mkdir -p "$DEST/build/usr/local/bin"
22
+	cp -L "$d/docker-$VERSION" "$DEST/build/usr/local/bin/docker"
23
+	
24
+	tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr
25
+	
26
+	rm -rf "$DEST/build"
27
+	
28
+	echo "Created tgz: $TGZ"
29
+done
... ...
@@ -114,6 +114,77 @@ s3_url() {
114 114
 	esac
115 115
 }
116 116
 
117
+release_build() {
118
+	GOOS=$1
119
+	GOARCH=$2
120
+
121
+	BINARY=bundles/$VERSION/cross/$GOOS/$GOARCH/docker-$VERSION
122
+	TGZ=bundles/$VERSION/tgz/$GOOS/$GOARCH/docker-$VERSION.tgz
123
+
124
+	# we need to map our GOOS and GOARCH to uname values
125
+	# see https://en.wikipedia.org/wiki/Uname
126
+	# ie, GOOS=linux -> "uname -s"=Linux
127
+
128
+	S3OS=$GOOS
129
+	case "$S3OS" in
130
+		darwin)
131
+			S3OS=Darwin
132
+			;;
133
+		freebsd)
134
+			S3OS=FreeBSD
135
+			;;
136
+		linux)
137
+			S3OS=Linux
138
+			;;
139
+		*)
140
+			echo >&2 "error: can't convert $S3OS to an appropriate value for 'uname -s'"
141
+			exit 1
142
+			;;
143
+	esac
144
+
145
+	S3ARCH=$GOARCH
146
+	case "$S3ARCH" in
147
+		amd64)
148
+			S3ARCH=x86_64
149
+			;;
150
+		386)
151
+			S3ARCH=i386
152
+			;;
153
+		arm)
154
+			# GOARCH is fine
155
+			;;
156
+		*)
157
+			echo >&2 "error: can't convert $S3ARCH to an appropriate value for 'uname -m'"
158
+			exit 1
159
+			;;
160
+	esac
161
+
162
+	S3DIR=s3://$BUCKET/builds/$S3OS/$S3ARCH
163
+
164
+	if [ ! -x "$BINARY" ]; then
165
+		echo >&2 "error: can't find $BINARY - was it compiled properly?"
166
+		exit 1
167
+	fi
168
+	if [ ! -f "$TGZ" ]; then
169
+		echo >&2 "error: can't find $TGZ - was it packaged properly?"
170
+		exit 1
171
+	fi
172
+
173
+	echo "Uploading $BINARY to $S3OS/$S3ARCH/docker-$VERSION"
174
+	s3cmd --follow-symlinks --preserve --acl-public put $BINARY $S3DIR/docker-$VERSION
175
+
176
+	echo "Uploading $TGZ to $S3OS/$S3ARCH/docker-$VERSION.tgz"
177
+	s3cmd --follow-symlinks --preserve --acl-public put $TGZ $S3DIR/docker-$VERSION.tgz
178
+
179
+	if [ -z "$NOLATEST" ]; then
180
+		echo "Copying $S3OS/$S3ARCH/docker-$VERSION to $S3OS/$S3ARCH/docker-latest"
181
+		s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
182
+
183
+		echo "Copying $S3OS/$S3ARCH/docker-$VERSION.tgz to $S3OS/$S3ARCH/docker-latest.tgz"
184
+		s3cmd --acl-public cp $S3DIR/docker-$VERSION.tgz $S3DIR/docker-latest.tgz
185
+	fi
186
+}
187
+
117 188
 # Upload the 'ubuntu' bundle to S3:
118 189
 # 1. A full APT repository is published at $BUCKET/ubuntu/
119 190
 # 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/index
... ...
@@ -190,31 +261,21 @@ EOF
190 190
 	echo "APT repository uploaded. Instructions available at $(s3_url)/ubuntu"
191 191
 }
192 192
 
193
-# Upload a tgz to S3
194
-release_tgz() {
195
-	[ -e bundles/$VERSION/tgz/docker-$VERSION.tgz ] || {
196
-		echo >&2 './hack/make.sh must be run before release_binary'
193
+# Upload binaries and tgz files to S3
194
+release_binaries() {
195
+	[ -e bundles/$VERSION/cross/linux/amd64/docker-$VERSION ] || {
196
+		echo >&2 './hack/make.sh must be run before release_binaries'
197 197
 		exit 1
198 198
 	}
199 199
 
200
-	S3DIR=s3://$BUCKET/builds/Linux/x86_64
201
-	s3cmd --acl-public put bundles/$VERSION/tgz/docker-$VERSION.tgz $S3DIR/docker-$VERSION.tgz
202
-
203
-	if [ -z "$NOLATEST" ]; then
204
-		echo "Copying docker-$VERSION.tgz to docker-latest.tgz"
205
-		s3cmd --acl-public cp $S3DIR/docker-$VERSION.tgz $S3DIR/docker-latest.tgz
206
-	fi
207
-}
200
+	for d in bundles/$VERSION/cross/*/*; do
201
+		GOARCH="$(basename "$d")"
202
+		GOOS="$(basename "$(dirname "$d")")"
203
+		release_build "$GOOS" "$GOARCH"
204
+	done
208 205
 
209
-# Upload a static binary to S3
210
-release_binary() {
211
-	[ -e bundles/$VERSION/binary/docker-$VERSION ] || {
212
-		echo >&2 './hack/make.sh must be run before release_binary'
213
-		exit 1
214
-	}
206
+	# TODO create redirect from builds/*/i686 to builds/*/i386
215 207
 
216
-	S3DIR=s3://$BUCKET/builds/Linux/x86_64
217
-	s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION
218 208
 	cat <<EOF | write_to_s3 s3://$BUCKET/builds/index
219 209
 # To install, run the following command as root:
220 210
 curl -O $(s3_url)/builds/Linux/x86_64/docker-$VERSION && chmod +x docker-$VERSION && sudo mv docker-$VERSION /usr/local/bin/docker
... ...
@@ -227,23 +288,11 @@ EOF
227 227
 	s3cmd --acl-public --add-header='x-amz-website-redirect-location:/builds/' --mime-type='text/plain' put /tmp/emptyfile s3://$BUCKET/builds/info
228 228
 
229 229
 	if [ -z "$NOLATEST" ]; then
230
-		echo "Copying docker-$VERSION to docker-latest"
231
-		s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
232 230
 		echo "Advertising $VERSION on $BUCKET as most recent version"
233 231
 		echo $VERSION | write_to_s3 s3://$BUCKET/latest
234 232
 	fi
235 233
 }
236 234
 
237
-# Upload a cross-compiled client binaries to S3
238
-release_cross() {
239
-	[ -e bundles/$VERSION/cross ] || {
240
-		echo >&2 './hack/make.sh must be run before release_binary'
241
-		exit 1
242
-	}
243
-	
244
-	# TODO find out from @shykes what URLs he'd like to use here
245
-}
246
-
247 235
 # Upload the index script
248 236
 release_index() {
249 237
 	sed "s,https://get.docker.io/,$(s3_url)/," hack/install.sh | write_to_s3 s3://$BUCKET/index
... ...
@@ -257,12 +306,15 @@ release_test() {
257 257
 
258 258
 main() {
259 259
 	setup_s3
260
-	release_binary
261
-	release_cross
262
-	release_tgz
260
+	release_binaries
263 261
 	release_ubuntu
264 262
 	release_index
265 263
 	release_test
266 264
 }
267 265
 
268 266
 main
267
+
268
+echo
269
+echo
270
+echo "Release complete; see $(s3_url)"
271
+echo