From b46c15e7728875b851d1d6a87dac8e3699737232 Mon Sep 17 00:00:00 2001 From: Mike Dougherty Date: Tue, 25 Aug 2015 12:18:04 -0700 Subject: [PATCH] Add support for longer S3 bucket paths Signed-off-by: Mike Dougherty --- hack/release.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/hack/release.sh b/hack/release.sh index 5765a12d4a..959b64831a 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -18,8 +18,8 @@ usage() { To run, I need: - to be in a container generated by the Dockerfile at the top of the Docker repository; -- to be provided with the name of an S3 bucket, in environment variable - AWS_S3_BUCKET; +- to be provided with the location of an S3 bucket and path, in + environment variables AWS_S3_BUCKET and AWS_S3_BUCKET_PATH (default: ''); - to be provided with AWS credentials for this S3 bucket, in environment variables AWS_ACCESS_KEY and AWS_SECRET_KEY; - the passphrase to unlock the GPG key which will sign the deb packages @@ -62,6 +62,8 @@ fi VERSION=$(< VERSION) BUCKET=$AWS_S3_BUCKET +BUCKET_PATH=$BUCKET +[[ -n "$AWS_S3_BUCKET_PATH" ]] && BUCKET_PATH+=/$AWS_S3_BUCKET_PATH # These are the 2 keys we've used to sign the deb's # release (get.docker.com) @@ -94,10 +96,15 @@ write_to_s3() { s3_url() { case "$BUCKET" in get.docker.com|test.docker.com|experimental.docker.com) - echo "https://$BUCKET" + echo "https://$BUCKET_PATH" ;; *) - s3cmd ws-info s3://$BUCKET | awk -v 'FS=: +' '/http:\/\/'$BUCKET'/ { gsub(/\/+$/, "", $2); print $2 }' + BASE_URL=$( s3cmd ws-info s3://$BUCKET | awk -v 'FS=: +' '/http:\/\/'$BUCKET'/ { gsub(/\/+$/, "", $2); print $2 }' ) + if [[ -n "$AWS_S3_BUCKET_PATH" ]] ; then + echo "$BASE_URL/$AWS_S3_BUCKET_PATH" + else + echo "$BASE_URL" + fi ;; esac } @@ -224,7 +231,7 @@ release_build() { ;; esac - s3Dir=s3://$BUCKET/builds/$s3Os/$s3Arch + s3Dir="s3://$BUCKET_PATH/builds/$s3Os/$s3Arch" latest= latestTgz= if [ "$latestBase" ]; then @@ -323,7 +330,7 @@ release_binaries() { # TODO create redirect from builds/*/i686 to builds/*/i386 - cat <