mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix a lot of the sha256 and md5 stuff to be more DRY and extendible, and on more things (specifically, the tgz files too)
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
parent
372b7282cb
commit
6b46a09186
5 changed files with 100 additions and 59 deletions
21
hack/make.sh
21
hack/make.sh
|
@ -149,6 +149,27 @@ find_dirs() {
|
||||||
\) -name "$1" -print0 | xargs -0n1 dirname | sort -u
|
\) -name "$1" -print0 | xargs -0n1 dirname | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hash_files() {
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
f="$1"
|
||||||
|
shift
|
||||||
|
dir="$(dirname "$f")"
|
||||||
|
base="$(basename "$f")"
|
||||||
|
for hashAlgo in md5 sha256; do
|
||||||
|
if command -v "${hashAlgo}sum" &> /dev/null; then
|
||||||
|
(
|
||||||
|
# subshell and cd so that we get output files like:
|
||||||
|
# $HASH docker-$VERSION
|
||||||
|
# instead of:
|
||||||
|
# $HASH /go/src/github.com/.../$VERSION/binary/docker-$VERSION
|
||||||
|
cd "$dir"
|
||||||
|
"${hashAlgo}sum" "$base" > "$base.$hashAlgo"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
bundle() {
|
bundle() {
|
||||||
bundlescript=$1
|
bundlescript=$1
|
||||||
bundle=$(basename $bundlescript)
|
bundle=$(basename $bundlescript)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
DEST=$1
|
DEST=$1
|
||||||
|
|
||||||
go build \
|
go build \
|
||||||
-o $DEST/docker-$VERSION \
|
-o "$DEST/docker-$VERSION" \
|
||||||
"${BUILDFLAGS[@]}" \
|
"${BUILDFLAGS[@]}" \
|
||||||
-ldflags "
|
-ldflags "
|
||||||
$LDFLAGS
|
$LDFLAGS
|
||||||
|
@ -12,9 +12,4 @@ go build \
|
||||||
./docker
|
./docker
|
||||||
echo "Created binary: $DEST/docker-$VERSION"
|
echo "Created binary: $DEST/docker-$VERSION"
|
||||||
|
|
||||||
if command -v md5sum &> /dev/null; then
|
hash_files "$DEST/docker-$VERSION"
|
||||||
md5sum "$DEST/docker-$VERSION" > "$DEST/docker-$VERSION.md5"
|
|
||||||
fi
|
|
||||||
if command -v sha256sum &> /dev/null; then
|
|
||||||
sha256sum "$DEST/docker-$VERSION" > "$DEST/docker-$VERSION.sha256"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ DEST=$1
|
||||||
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
||||||
# dockerinit still needs to be a static binary, even if docker is dynamic
|
# dockerinit still needs to be a static binary, even if docker is dynamic
|
||||||
go build \
|
go build \
|
||||||
-o $DEST/dockerinit-$VERSION \
|
-o "$DEST/dockerinit-$VERSION" \
|
||||||
"${BUILDFLAGS[@]}" \
|
"${BUILDFLAGS[@]}" \
|
||||||
-ldflags "
|
-ldflags "
|
||||||
$LDFLAGS
|
$LDFLAGS
|
||||||
|
@ -14,7 +14,9 @@ if [ -z "$DOCKER_CLIENTONLY" ]; then
|
||||||
" \
|
" \
|
||||||
./dockerinit
|
./dockerinit
|
||||||
echo "Created binary: $DEST/dockerinit-$VERSION"
|
echo "Created binary: $DEST/dockerinit-$VERSION"
|
||||||
ln -sf dockerinit-$VERSION $DEST/dockerinit
|
ln -sf "dockerinit-$VERSION" "$DEST/dockerinit"
|
||||||
|
|
||||||
|
hash_files "$DEST/dockerinit-$VERSION"
|
||||||
|
|
||||||
sha1sum=
|
sha1sum=
|
||||||
if command -v sha1sum &> /dev/null; then
|
if command -v sha1sum &> /dev/null; then
|
||||||
|
|
|
@ -23,6 +23,8 @@ for d in "$CROSS/"*/*; do
|
||||||
|
|
||||||
tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr
|
tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr
|
||||||
|
|
||||||
|
hash_files "$TGZ"
|
||||||
|
|
||||||
rm -rf "$DEST/build"
|
rm -rf "$DEST/build"
|
||||||
|
|
||||||
echo "Created tgz: $TGZ"
|
echo "Created tgz: $TGZ"
|
||||||
|
|
121
hack/release.sh
121
hack/release.sh
|
@ -122,91 +122,113 @@ build_all() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upload_release_build() {
|
||||||
|
src="$1"
|
||||||
|
dst="$2"
|
||||||
|
latest="$3"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Uploading $src"
|
||||||
|
echo " to $dst"
|
||||||
|
echo
|
||||||
|
s3cmd --follow-symlinks --preserve --acl-public put "$src" "$dst"
|
||||||
|
if [ "$latest" ]; then
|
||||||
|
echo
|
||||||
|
echo "Copying to $latest"
|
||||||
|
echo
|
||||||
|
s3cmd --acl-public cp "$dst" "$latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get hash files too (see hash_files() in hack/make.sh)
|
||||||
|
for hashAlgo in md5 sha256; do
|
||||||
|
if [ -e "$src.$hashAlgo" ]; then
|
||||||
|
echo
|
||||||
|
echo "Uploading $src.$hashAlgo"
|
||||||
|
echo " to $dst.$hashAlgo"
|
||||||
|
echo
|
||||||
|
s3cmd --follow-symlinks --preserve --acl-public --mime-type='text/plain' put "$src.$hashAlgo" "$dst.$hashAlgo"
|
||||||
|
if [ "$latest" ]; then
|
||||||
|
echo
|
||||||
|
echo "Copying to $latest.$hashAlgo"
|
||||||
|
echo
|
||||||
|
s3cmd --acl-public cp "$dst.$hashAlgo" "$latest.$hashAlgo"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
release_build() {
|
release_build() {
|
||||||
GOOS=$1
|
GOOS=$1
|
||||||
GOARCH=$2
|
GOARCH=$2
|
||||||
|
|
||||||
SOURCE_DIR=bundles/$VERSION/cross/$GOOS/$GOARCH
|
binDir=bundles/$VERSION/cross/$GOOS/$GOARCH
|
||||||
BINARY=docker-$VERSION
|
tgzDir=bundles/$VERSION/tgz/$GOOS/$GOARCH
|
||||||
BINARY_MD5=docker-$VERSION.md5
|
binary=docker-$VERSION
|
||||||
BINARY_SHA256=docker-$VERSION.sha256
|
tgz=docker-$VERSION.tgz
|
||||||
TGZ=docker-$VERSION.tgz
|
|
||||||
|
latestBase=
|
||||||
|
if [ -z "$NOLATEST" ]; then
|
||||||
|
latestBase=docker-latest
|
||||||
|
fi
|
||||||
|
|
||||||
# we need to map our GOOS and GOARCH to uname values
|
# we need to map our GOOS and GOARCH to uname values
|
||||||
# see https://en.wikipedia.org/wiki/Uname
|
# see https://en.wikipedia.org/wiki/Uname
|
||||||
# ie, GOOS=linux -> "uname -s"=Linux
|
# ie, GOOS=linux -> "uname -s"=Linux
|
||||||
|
|
||||||
S3OS=$GOOS
|
s3Os=$GOOS
|
||||||
case "$S3OS" in
|
case "$s3Os" in
|
||||||
darwin)
|
darwin)
|
||||||
S3OS=Darwin
|
s3Os=Darwin
|
||||||
;;
|
;;
|
||||||
freebsd)
|
freebsd)
|
||||||
S3OS=FreeBSD
|
s3Os=FreeBSD
|
||||||
;;
|
;;
|
||||||
linux)
|
linux)
|
||||||
S3OS=Linux
|
s3Os=Linux
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo >&2 "error: can't convert $S3OS to an appropriate value for 'uname -s'"
|
echo >&2 "error: can't convert $s3Os to an appropriate value for 'uname -s'"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
S3ARCH=$GOARCH
|
s3Arch=$GOARCH
|
||||||
case "$S3ARCH" in
|
case "$s3Arch" in
|
||||||
amd64)
|
amd64)
|
||||||
S3ARCH=x86_64
|
s3Arch=x86_64
|
||||||
;;
|
;;
|
||||||
386)
|
386)
|
||||||
S3ARCH=i386
|
s3Arch=i386
|
||||||
;;
|
;;
|
||||||
arm)
|
arm)
|
||||||
S3ARCH=armel
|
s3Arch=armel
|
||||||
# someday, we might potentially support mutliple GOARM values, in which case we might get armhf here too
|
# someday, we might potentially support mutliple GOARM values, in which case we might get armhf here too
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo >&2 "error: can't convert $S3ARCH to an appropriate value for 'uname -m'"
|
echo >&2 "error: can't convert $s3Arch to an appropriate value for 'uname -m'"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
S3DIR=s3://$BUCKET/builds/$S3OS/$S3ARCH
|
s3Dir=s3://$BUCKET/builds/$s3Os/$s3Arch
|
||||||
|
latest=
|
||||||
|
latestTgz=
|
||||||
|
if [ "$latestBase" ]; then
|
||||||
|
latest="$s3Dir/$latestBase"
|
||||||
|
latestTgz="$s3Dir/$latestBase.tgz"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -x "$SOURCE_DIR/$BINARY" ]; then
|
if [ ! -x "$binDir/$binary" ]; then
|
||||||
echo >&2 "error: can't find $SOURCE_DIR/$BINARY - was it compiled properly?"
|
echo >&2 "error: can't find $binDir/$binary - was it compiled properly?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$TGZ" ]; then
|
if [ ! -f "$tgzDir/$tgz" ]; then
|
||||||
echo >&2 "error: can't find $TGZ - was it packaged properly?"
|
echo >&2 "error: can't find $tgzDir/$tgz - was it packaged properly?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Uploading $BINARY to $S3OS/$S3ARCH/docker-$VERSION"
|
upload_release_build "$binDir/$binary" "$s3Dir/$binary" "$latest"
|
||||||
s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$BINARY $S3DIR/$BINARY
|
upload_release_build "$tgzDir/$tgz" "$s3Dir/$tgz" "$latestTgz"
|
||||||
|
|
||||||
echo "Uploading $BINARY_MD5 to $S3OS/$S3ARCH/docker-$VERSION.md5"
|
|
||||||
s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$BINARY_MD5 $S3DIR/$BINARY_MD5
|
|
||||||
|
|
||||||
echo "Uploading $BINARY_SHA256 to $S3OS/$S3ARCH/docker-$VERSION.sha256"
|
|
||||||
s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$BINARY_SHA256 $S3DIR/$BINARY_SHA256
|
|
||||||
|
|
||||||
echo "Uploading $TGZ to $S3OS/$S3ARCH/docker-$VERSION.tgz"
|
|
||||||
s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$TGZ $S3DIR/$TGZ
|
|
||||||
|
|
||||||
if [ -z "$NOLATEST" ]; then
|
|
||||||
echo "Copying $S3DIR/$BINARY to $S3DIR/docker-latest"
|
|
||||||
s3cmd --acl-public cp $S3DIR/$BINARY $S3DIR/docker-latest
|
|
||||||
|
|
||||||
echo "Copying $S3DIR/$BINARY_MD5 to $S3DIR/docker-latest.md5"
|
|
||||||
s3cmd --acl-public cp $S3DIR/$BINARY_MD5 $S3DIR/docker-latest.md5
|
|
||||||
|
|
||||||
echo "Copying $S3DIR/$BINARY_SHA256 to $S3DIR/docker-latest.sha256"
|
|
||||||
s3cmd --acl-public cp $S3DIR/$BINARY_SHA256 $S3DIR/docker-latest.sha256
|
|
||||||
|
|
||||||
echo "Copying $S3DIR/$TGZ $S3DIR/docker-latest.tgz"
|
|
||||||
s3cmd --acl-public cp $S3DIR/$TGZ $S3DIR/docker-latest.tgz
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Upload the 'ubuntu' bundle to S3:
|
# Upload the 'ubuntu' bundle to S3:
|
||||||
|
@ -218,8 +240,6 @@ release_ubuntu() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true
|
|
||||||
|
|
||||||
# Sign our packages
|
# Sign our packages
|
||||||
dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
|
dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
|
||||||
--sign builder bundles/$VERSION/ubuntu/*.deb
|
--sign builder bundles/$VERSION/ubuntu/*.deb
|
||||||
|
@ -318,10 +338,11 @@ release_test() {
|
||||||
setup_gpg() {
|
setup_gpg() {
|
||||||
# Make sure that we have our keys
|
# Make sure that we have our keys
|
||||||
mkdir -p /.gnupg/
|
mkdir -p /.gnupg/
|
||||||
|
s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true
|
||||||
gpg --list-keys releasedocker >/dev/null || {
|
gpg --list-keys releasedocker >/dev/null || {
|
||||||
gpg --gen-key --batch <<EOF
|
gpg --gen-key --batch <<EOF
|
||||||
Key-Type: RSA
|
Key-Type: RSA
|
||||||
Key-Length: 2048
|
Key-Length: 4096
|
||||||
Passphrase: $GPG_PASSPHRASE
|
Passphrase: $GPG_PASSPHRASE
|
||||||
Name-Real: Docker Release Tool
|
Name-Real: Docker Release Tool
|
||||||
Name-Email: docker@dotcloud.com
|
Name-Email: docker@dotcloud.com
|
||||||
|
|
Loading…
Add table
Reference in a new issue