1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/make/tgz
Brian Goff 9bb54f89ad
Add make install task
This installs docker and dockerd to `$DOCKER_MAKE_INSTALL_PREFIX/bin`, which
defaults to `/usr/local/bin`

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-06-03 12:08:33 +02:00

77 lines
2 KiB
Bash

#!/bin/bash
CROSS="$DEST/../cross"
set -e
if [ ! -d "$CROSS/linux/amd64" ]; then
echo >&2 'error: binary and cross must be run before tgz'
false
fi
(
for d in "$CROSS/"*/*; do
export GOARCH="$(basename "$d")"
export GOOS="$(basename "$(dirname "$d")")"
source "${MAKEDIR}/.binary-setup"
BINARY_NAME="${DOCKER_CLIENT_BINARY_NAME}-$VERSION"
DAEMON_BINARY_NAME="${DOCKER_DAEMON_BINARY_NAME}-$VERSION"
BINARY_EXTENSION="$(export GOOS && binary_extension)"
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
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
DAEMON_BINARY_FULLNAME="$DAEMON_BINARY_NAME$BINARY_EXTENSION"
mkdir -p "$DEST/$GOOS/$GOARCH"
TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME$BUNDLE_EXTENSION"
# The staging directory for the files in the tgz
BUILD_PATH="$DEST/build"
# 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_CLIENT_BINARY_NAME}${BINARY_EXTENSION}"
if [ -f "$d/$DAEMON_BINARY_FULLNAME" ]; then
cp -L "$d/$DAEMON_BINARY_FULLNAME" "$TAR_PATH/${DOCKER_DAEMON_BINARY_NAME}${BINARY_EXTENSION}"
fi
# copy over all the containerd binaries
copy_containerd $TAR_PATH
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
hash_files "$TGZ"
# cleanup after ourselves
rm -rf "$BUILD_PATH"
echo "Created tgz: $TGZ"
done
)