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

This commit is contained in:
Tianon Gravi 2013-12-23 23:31:53 -07:00
parent 5875953d9b
commit 4100e9b7df
4 changed files with 120 additions and 52 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <<EOF | write_to_s3 s3://$BUCKET/builds/index
# To install, run the following command as root:
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
s3cmd --acl-public --add-header='x-amz-website-redirect-location:/builds/' --mime-type='text/plain' put /tmp/emptyfile s3://$BUCKET/builds/info
if [ -z "$NOLATEST" ]; then
echo "Copying docker-$VERSION to docker-latest"
s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
echo "Advertising $VERSION on $BUCKET as most recent version"
echo $VERSION | write_to_s3 s3://$BUCKET/latest
fi
}
# Upload a cross-compiled client binaries to S3
release_cross() {
[ -e bundles/$VERSION/cross ] || {
echo >&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