diff --git a/Makefile b/Makefile index 613425531b..86b2a0207f 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ binary: build $(DOCKER_RUN_DOCKER) hack/make.sh binary cross: build - $(DOCKER_RUN_DOCKER) hack/make.sh cross + $(DOCKER_RUN_DOCKER) hack/make.sh binary cross docs: docker build -t docker-docs docs && docker run -p 8000:8000 docker-docs diff --git a/hack/make/cross b/hack/make/cross index fe68d7b4b8..a67ab6c28a 100644 --- a/hack/make/cross +++ b/hack/make/cross @@ -2,12 +2,22 @@ DEST=$1 +# if we have our linux/amd64 version compiled, let's symlink it in +if [ -x "$DEST/../binary/docker-$VERSION" ]; then + mkdir -p "$DEST/linux/amd64" + ( + cd "$DEST/linux/amd64" + ln -s ../../../binary/* ./ + ) + echo "Created symlinks:" "$DEST/linux/amd64/"* +fi + for platform in $DOCKER_CROSSPLATFORMS; do ( + mkdir -p "$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION export GOOS=${platform%/*} export GOARCH=${platform##*/} - export VERSION="$GOOS-$GOARCH-$VERSION" # for a nice filename export LDFLAGS_STATIC="" # we just need a simple client for these platforms (TODO this might change someday) - source "$(dirname "$BASH_SOURCE")/binary" + source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform" ) done diff --git a/hack/make/tgz b/hack/make/tgz index 86a7a9827d..5d03306322 100644 --- a/hack/make/tgz +++ b/hack/make/tgz @@ -1,23 +1,29 @@ #!/bin/bash DEST="$1" -BINARY="$DEST/../binary/docker-$VERSION" -TGZ="$DEST/docker-$VERSION.tgz" +CROSS="$DEST/../cross" set -e -if [ ! -x "$BINARY" ]; then - echo >&2 'error: binary must be run before tgz' +if [ ! -d "$CROSS/linux/amd64" ]; then + echo >&2 'error: binary and cross must be run before tgz' false fi -mkdir -p "$DEST/build" - -mkdir -p "$DEST/build/usr/local/bin" -cp -L "$BINARY" "$DEST/build/usr/local/bin/docker" - -tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr - -rm -rf "$DEST/build" - -echo "Created tgz: $TGZ" +for d in "$CROSS/"*/*; do + GOARCH="$(basename "$d")" + GOOS="$(basename "$(dirname "$d")")" + mkdir -p "$DEST/$GOOS/$GOARCH" + TGZ="$DEST/$GOOS/$GOARCH/docker-$VERSION.tgz" + + mkdir -p "$DEST/build" + + mkdir -p "$DEST/build/usr/local/bin" + cp -L "$d/docker-$VERSION" "$DEST/build/usr/local/bin/docker" + + tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr + + rm -rf "$DEST/build" + + echo "Created tgz: $TGZ" +done diff --git a/hack/release.sh b/hack/release.sh index 9021345eb2..d1278a4c36 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -114,6 +114,77 @@ s3_url() { esac } +release_build() { + GOOS=$1 + GOARCH=$2 + + BINARY=bundles/$VERSION/cross/$GOOS/$GOARCH/docker-$VERSION + TGZ=bundles/$VERSION/tgz/$GOOS/$GOARCH/docker-$VERSION.tgz + + # we need to map our GOOS and GOARCH to uname values + # see https://en.wikipedia.org/wiki/Uname + # ie, GOOS=linux -> "uname -s"=Linux + + S3OS=$GOOS + case "$S3OS" in + darwin) + S3OS=Darwin + ;; + freebsd) + S3OS=FreeBSD + ;; + linux) + S3OS=Linux + ;; + *) + echo >&2 "error: can't convert $S3OS to an appropriate value for 'uname -s'" + exit 1 + ;; + esac + + S3ARCH=$GOARCH + case "$S3ARCH" in + amd64) + S3ARCH=x86_64 + ;; + 386) + S3ARCH=i386 + ;; + arm) + # GOARCH is fine + ;; + *) + echo >&2 "error: can't convert $S3ARCH to an appropriate value for 'uname -m'" + exit 1 + ;; + esac + + S3DIR=s3://$BUCKET/builds/$S3OS/$S3ARCH + + if [ ! -x "$BINARY" ]; then + echo >&2 "error: can't find $BINARY - was it compiled properly?" + exit 1 + fi + if [ ! -f "$TGZ" ]; then + echo >&2 "error: can't find $TGZ - was it packaged properly?" + exit 1 + fi + + echo "Uploading $BINARY to $S3OS/$S3ARCH/docker-$VERSION" + s3cmd --follow-symlinks --preserve --acl-public put $BINARY $S3DIR/docker-$VERSION + + echo "Uploading $TGZ to $S3OS/$S3ARCH/docker-$VERSION.tgz" + s3cmd --follow-symlinks --preserve --acl-public put $TGZ $S3DIR/docker-$VERSION.tgz + + if [ -z "$NOLATEST" ]; then + echo "Copying $S3OS/$S3ARCH/docker-$VERSION to $S3OS/$S3ARCH/docker-latest" + s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest + + echo "Copying $S3OS/$S3ARCH/docker-$VERSION.tgz to $S3OS/$S3ARCH/docker-latest.tgz" + s3cmd --acl-public cp $S3DIR/docker-$VERSION.tgz $S3DIR/docker-latest.tgz + fi +} + # Upload the 'ubuntu' bundle to S3: # 1. A full APT repository is published at $BUCKET/ubuntu/ # 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/index @@ -190,31 +261,21 @@ EOF echo "APT repository uploaded. Instructions available at $(s3_url)/ubuntu" } -# Upload a tgz to S3 -release_tgz() { - [ -e bundles/$VERSION/tgz/docker-$VERSION.tgz ] || { - echo >&2 './hack/make.sh must be run before release_binary' +# Upload binaries and tgz files to S3 +release_binaries() { + [ -e bundles/$VERSION/cross/linux/amd64/docker-$VERSION ] || { + echo >&2 './hack/make.sh must be run before release_binaries' exit 1 } - S3DIR=s3://$BUCKET/builds/Linux/x86_64 - s3cmd --acl-public put bundles/$VERSION/tgz/docker-$VERSION.tgz $S3DIR/docker-$VERSION.tgz + for d in bundles/$VERSION/cross/*/*; do + GOARCH="$(basename "$d")" + GOOS="$(basename "$(dirname "$d")")" + release_build "$GOOS" "$GOARCH" + done - if [ -z "$NOLATEST" ]; then - echo "Copying docker-$VERSION.tgz to docker-latest.tgz" - s3cmd --acl-public cp $S3DIR/docker-$VERSION.tgz $S3DIR/docker-latest.tgz - fi -} + # TODO create redirect from builds/*/i686 to builds/*/i386 -# Upload a static binary to S3 -release_binary() { - [ -e bundles/$VERSION/binary/docker-$VERSION ] || { - echo >&2 './hack/make.sh must be run before release_binary' - exit 1 - } - - S3DIR=s3://$BUCKET/builds/Linux/x86_64 - s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION cat <&2 './hack/make.sh must be run before release_binary' - exit 1 - } - - # TODO find out from @shykes what URLs he'd like to use here -} - # Upload the index script release_index() { sed "s,https://get.docker.io/,$(s3_url)/," hack/install.sh | write_to_s3 s3://$BUCKET/index @@ -257,12 +306,15 @@ release_test() { main() { setup_s3 - release_binary - release_cross - release_tgz + release_binaries release_ubuntu release_index release_test } main + +echo +echo +echo "Release complete; see $(s3_url)" +echo