github.com/ojongerius/docker@v1.11.2/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 BINARY_NAME="docker-$VERSION" 17 BINARY_EXTENSION="$(export GOOS && binary_extension)" 18 if [ "$GOOS" = 'windows' ]; then 19 # if windows use a zip, not tgz 20 BUNDLE_EXTENSION=".zip" 21 IS_TAR="false" 22 else 23 BUNDLE_EXTENSION=".tgz" 24 IS_TAR="true" 25 fi 26 BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" 27 mkdir -p "$DEST/$GOOS/$GOARCH" 28 TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME$BUNDLE_EXTENSION" 29 30 # The staging directory for the files in the tgz 31 BUILD_PATH="$DEST/build" 32 33 # The directory that is at the root of the tar file 34 TAR_BASE_DIRECTORY="docker" 35 36 # $DEST/build/docker 37 TAR_PATH="$BUILD_PATH/$TAR_BASE_DIRECTORY" 38 39 # Copy the correct docker binary 40 mkdir -p $TAR_PATH 41 cp -L "$d/$BINARY_FULLNAME" "$TAR_PATH/docker$BINARY_EXTENSION" 42 43 # copy over all the containerd binaries 44 copy_containerd $TAR_PATH 45 46 if [ "$IS_TAR" == "true" ]; then 47 echo "Creating tgz from $BUILD_PATH and naming it $TGZ" 48 tar --numeric-owner --owner 0 -C "$BUILD_PATH" -czf "$TGZ" $TAR_BASE_DIRECTORY 49 else 50 # ZIP needs to full absolute dir path, not the absolute path 51 ZIP=`pwd`"/$TGZ" 52 # keep track of where we are, for later. 53 pushd . 54 # go into the BUILD_PATH since zip does not have a -C equivalent. 55 cd $BUILD_PATH 56 echo "Creating zip from $BUILD_PATH and naming it $ZIP" 57 zip -q -r $ZIP $TAR_BASE_DIRECTORY 58 # go back to where we started 59 popd 60 fi 61 62 hash_files "$TGZ" 63 64 # cleanup after ourselves 65 rm -rf "$BUILD_PATH" 66 67 echo "Created tgz: $TGZ" 68 done 69 )