updatedep.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env bash
  2. # A script for updating godep dependencies for the vendored directory /cmd/
  3. # without pulling in etcd itself as a dependency.
  4. #
  5. # update depedency
  6. # 1. edit glide.yaml with version, git SHA
  7. # 2. run ./scripts/updatedep.sh
  8. # 3. it automatically detects new git SHA, and vendors updates to cmd/vendor directory
  9. #
  10. # add depedency
  11. # 1. run ./scripts/updatedep.sh github.com/USER/PROJECT#^1.0.0
  12. # OR
  13. # ./scripts/updatedep.sh github.com/USER/PROJECT#9b772b54b3bf0be1eec083c9669766a56332559a
  14. # 2. make sure glide.yaml and glide.lock are updated
  15. if ! [[ "$0" =~ "scripts/updatedep.sh" ]]; then
  16. echo "must be run from repository root"
  17. exit 255
  18. fi
  19. rm -rf vendor
  20. mv cmd/vendor vendor
  21. # TODO: glide doesn't play well with symlink
  22. echo "manually deleting etcd-repo symlink in vendor"
  23. rm -f vendor/github.com/coreos/etcd
  24. GLIDE_ROOT="$GOPATH/src/github.com/Masterminds/glide"
  25. GLIDE_SHA=21ff6d397ccca910873d8eaabab6a941c364cc70
  26. go get -d -u github.com/Masterminds/glide
  27. pushd "${GLIDE_ROOT}"
  28. git reset --hard ${GLIDE_SHA}
  29. go install
  30. popd
  31. GLIDE_VC_ROOT="$GOPATH/src/github.com/sgotti/glide-vc"
  32. GLIDE_VC_SHA=d96375d23c85287e80296cdf48f9d21c227fa40a
  33. go get -d -u github.com/sgotti/glide-vc
  34. pushd "${GLIDE_VC_ROOT}"
  35. git reset --hard ${GLIDE_VC_SHA}
  36. go install
  37. popd
  38. if [ -n "$1" ]; then
  39. echo "glide get on $(echo $1)"
  40. matches=`grep "name: $1" glide.lock`
  41. if [ ! -z "$matches" ]; then
  42. echo "glide update on $1"
  43. glide update --strip-vendor $1
  44. else
  45. echo "glide get on $1"
  46. glide get --strip-vendor $1
  47. fi
  48. else
  49. echo "glide update on *"
  50. glide update --strip-vendor
  51. fi;
  52. # TODO: workaround to keep 'github.com/stretchr/testify/assert' in v2 tests
  53. # TODO: remove this after dropping v2
  54. echo "copying github.com/stretchr/testify/assert"
  55. cp -rf vendor/github.com/stretchr/testify/assert ./temp-assert
  56. echo "removing test files"
  57. glide vc --only-code --no-tests
  58. # TODO: remove this after dropping v2
  59. mkdir -p vendor/github.com/stretchr/testify
  60. mv ./temp-assert vendor/github.com/stretchr/testify/assert
  61. mv vendor cmd/
  62. echo "recreating symlink to etcd"
  63. ln -s ../../../../ cmd/vendor/github.com/coreos/etcd
  64. echo "done"