2013-12-02 17:48:26 -05:00
|
|
|
#!/bin/bash
|
2013-11-17 22:24:49 -05:00
|
|
|
|
2013-12-24 01:31:53 -05:00
|
|
|
CROSS="$DEST/../cross"
|
2013-11-17 22:24:49 -05:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2013-12-24 01:31:53 -05:00
|
|
|
if [ ! -d "$CROSS/linux/amd64" ]; then
|
|
|
|
echo >&2 'error: binary and cross must be run before tgz'
|
2013-11-17 22:24:49 -05:00
|
|
|
false
|
|
|
|
fi
|
|
|
|
|
2016-03-22 17:12:29 -04:00
|
|
|
(
|
2013-12-24 01:31:53 -05:00
|
|
|
for d in "$CROSS/"*/*; do
|
2016-03-22 17:12:29 -04:00
|
|
|
export GOARCH="$(basename "$d")"
|
|
|
|
export GOOS="$(basename "$(dirname "$d")")"
|
2014-12-16 05:05:12 -05:00
|
|
|
BINARY_NAME="docker-$VERSION"
|
2016-04-23 18:26:05 -04:00
|
|
|
DAEMON_BINARY_NAME="dockerd-$VERSION"
|
2015-01-12 21:07:16 -05:00
|
|
|
BINARY_EXTENSION="$(export GOOS && binary_extension)"
|
2016-03-31 12:27:50 -04:00
|
|
|
if [ "$GOOS" = 'windows' ]; then
|
|
|
|
# if windows use a zip, not tgz
|
|
|
|
BUNDLE_EXTENSION=".zip"
|
|
|
|
IS_TAR="false"
|
|
|
|
else
|
|
|
|
BUNDLE_EXTENSION=".tgz"
|
|
|
|
IS_TAR="true"
|
|
|
|
fi
|
2014-12-16 05:05:12 -05:00
|
|
|
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
2016-04-23 18:26:05 -04:00
|
|
|
DAEMON_BINARY_FULLNAME="$DAEMON_BINARY_NAME$BINARY_EXTENSION"
|
2013-12-24 01:31:53 -05:00
|
|
|
mkdir -p "$DEST/$GOOS/$GOARCH"
|
2016-03-31 12:27:50 -04:00
|
|
|
TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME$BUNDLE_EXTENSION"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2016-03-29 14:39:28 -04:00
|
|
|
# The staging directory for the files in the tgz
|
|
|
|
BUILD_PATH="$DEST/build"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2016-03-29 14:39:28 -04:00
|
|
|
# The directory that is at the root of the tar file
|
|
|
|
TAR_BASE_DIRECTORY="docker"
|
|
|
|
|
|
|
|
# $DEST/build/docker
|
|
|
|
TAR_PATH="$BUILD_PATH/$TAR_BASE_DIRECTORY"
|
|
|
|
|
|
|
|
# Copy the correct docker binary
|
|
|
|
mkdir -p $TAR_PATH
|
|
|
|
cp -L "$d/$BINARY_FULLNAME" "$TAR_PATH/docker$BINARY_EXTENSION"
|
2016-04-23 18:26:05 -04:00
|
|
|
if [ -f "$d/$DAEMON_BINARY_FULLNAME" ]; then
|
|
|
|
cp -L "$d/$DAEMON_BINARY_FULLNAME" "$TAR_PATH/dockerd$BINARY_EXTENSION"
|
|
|
|
fi
|
2016-03-29 14:39:28 -04:00
|
|
|
|
|
|
|
# copy over all the containerd binaries
|
|
|
|
copy_containerd $TAR_PATH
|
|
|
|
|
2016-03-31 12:27:50 -04:00
|
|
|
if [ "$IS_TAR" == "true" ]; then
|
|
|
|
echo "Creating tgz from $BUILD_PATH and naming it $TGZ"
|
|
|
|
tar --numeric-owner --owner 0 -C "$BUILD_PATH" -czf "$TGZ" $TAR_BASE_DIRECTORY
|
|
|
|
else
|
|
|
|
# ZIP needs to full absolute dir path, not the absolute path
|
|
|
|
ZIP=`pwd`"/$TGZ"
|
|
|
|
# keep track of where we are, for later.
|
|
|
|
pushd .
|
|
|
|
# go into the BUILD_PATH since zip does not have a -C equivalent.
|
|
|
|
cd $BUILD_PATH
|
|
|
|
echo "Creating zip from $BUILD_PATH and naming it $ZIP"
|
|
|
|
zip -q -r $ZIP $TAR_BASE_DIRECTORY
|
|
|
|
# go back to where we started
|
|
|
|
popd
|
|
|
|
fi
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2014-03-19 21:58:39 -04:00
|
|
|
hash_files "$TGZ"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2016-03-29 14:39:28 -04:00
|
|
|
# cleanup after ourselves
|
|
|
|
rm -rf "$BUILD_PATH"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2013-12-24 01:31:53 -05:00
|
|
|
echo "Created tgz: $TGZ"
|
|
|
|
done
|
2016-03-22 17:12:29 -04:00
|
|
|
)
|