github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/hack/make/tgz (about) 1 #!/bin/bash 2 3 CROSS="$DEST/../cross" 4 5 set -e 6 7 if [ ! -d "$CROSS/linux/amd64" ]; then 8 echo >&2 'error: binary and cross must be run before tgz' 9 false 10 fi 11 12 ( 13 for d in "$CROSS/"*/*; do 14 export GOARCH="$(basename "$d")" 15 export GOOS="$(basename "$(dirname "$d")")" 16 17 source "${MAKEDIR}/.binary-setup" 18 19 BINARY_NAME="${DOCKER_CLIENT_BINARY_NAME}-$VERSION" 20 DAEMON_BINARY_NAME="${DOCKER_DAEMON_BINARY_NAME}-$VERSION" 21 PROXY_BINARY_NAME="${DOCKER_PROXY_BINARY_NAME}-$VERSION" 22 BINARY_EXTENSION="$(export GOOS && binary_extension)" 23 if [ "$GOOS" = 'windows' ]; then 24 # if windows use a zip, not tgz 25 BUNDLE_EXTENSION=".zip" 26 IS_TAR="false" 27 else 28 BUNDLE_EXTENSION=".tgz" 29 IS_TAR="true" 30 fi 31 BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" 32 DAEMON_BINARY_FULLNAME="$DAEMON_BINARY_NAME$BINARY_EXTENSION" 33 PROXY_BINARY_FULLNAME="$PROXY_BINARY_NAME$BINARY_EXTENSION" 34 mkdir -p "$DEST/$GOOS/$GOARCH" 35 TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME$BUNDLE_EXTENSION" 36 37 # The staging directory for the files in the tgz 38 BUILD_PATH="$DEST/build" 39 40 # The directory that is at the root of the tar file 41 TAR_BASE_DIRECTORY="docker" 42 43 # $DEST/build/docker 44 TAR_PATH="$BUILD_PATH/$TAR_BASE_DIRECTORY" 45 46 # Copy the correct docker binary 47 mkdir -p $TAR_PATH 48 cp -L "$d/$BINARY_FULLNAME" "$TAR_PATH/${DOCKER_CLIENT_BINARY_NAME}${BINARY_EXTENSION}" 49 if [ -f "$d/$DAEMON_BINARY_FULLNAME" ]; then 50 cp -L "$d/$DAEMON_BINARY_FULLNAME" "$TAR_PATH/${DOCKER_DAEMON_BINARY_NAME}${BINARY_EXTENSION}" 51 fi 52 if [ -f "$d/$PROXY_BINARY_FULLNAME" ]; then 53 cp -L "$d/$PROXY_BINARY_FULLNAME" "$TAR_PATH/${DOCKER_PROXY_BINARY_NAME}${BINARY_EXTENSION}" 54 fi 55 56 # copy over all the containerd binaries 57 copy_containerd $TAR_PATH 58 59 if [ "$IS_TAR" == "true" ]; then 60 echo "Creating tgz from $BUILD_PATH and naming it $TGZ" 61 tar --numeric-owner --owner 0 -C "$BUILD_PATH" -czf "$TGZ" $TAR_BASE_DIRECTORY 62 else 63 # ZIP needs to full absolute dir path, not the absolute path 64 ZIP=`pwd`"/$TGZ" 65 # keep track of where we are, for later. 66 pushd . 67 # go into the BUILD_PATH since zip does not have a -C equivalent. 68 cd $BUILD_PATH 69 echo "Creating zip from $BUILD_PATH and naming it $ZIP" 70 zip -q -r $ZIP $TAR_BASE_DIRECTORY 71 # go back to where we started 72 popd 73 fi 74 75 hash_files "$TGZ" 76 77 # cleanup after ourselves 78 rm -rf "$BUILD_PATH" 79 80 echo "Created tgz: $TGZ" 81 done 82 )