tgz 2.5 KB

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