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