diff --git a/hack/vendor.sh b/hack/vendor.sh index f76b30bba1..3326d5b004 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -1,54 +1,52 @@ #!/bin/bash +set -e + +cd "$(dirname "$BASH_SOURCE")/.." # Downloads dependencies into vendor/ directory -if [[ ! -d vendor ]]; then - mkdir vendor -fi -vendor_dir=${PWD}/vendor +mkdir -p vendor +cd vendor -rm_pkg_dir () { - PKG=$1 - REV=$2 - ( - set -e - cd $vendor_dir - if [[ -d src/$PKG ]]; then - echo "src/$PKG already exists. Removing." - rm -fr src/$PKG - fi - ) +clone() { + vcs=$1 + pkg=$2 + rev=$3 + + pkg_url=https://$pkg + target_dir=src/$pkg + + echo -n "$pkg @ $rev: " + + if [ -d $target_dir ]; then + echo -n 'rm old, ' + rm -fr $target_dir + fi + + echo -n 'clone, ' + case $vcs in + git) + git clone --quiet --no-checkout $pkg_url $target_dir + ( cd $target_dir && git reset --quiet --hard $rev ) + ;; + hg) + hg clone --quiet --updaterev $rev $pkg_url $target_dir + ;; + esac + + echo -n 'rm VCS, ' + ( cd $target_dir && rm -rf .{git,hg} ) + + echo done } -git_clone () { - PKG=$1 - REV=$2 - ( - set -e - rm_pkg_dir $PKG $REV - cd $vendor_dir && git clone http://$PKG src/$PKG - cd src/$PKG && git checkout -f $REV && rm -fr .git - ) -} +clone git github.com/kr/pty 3b1f6487b -hg_clone () { - PKG=$1 - REV=$2 - ( - set -e - rm_pkg_dir $PKG $REV - cd $vendor_dir && hg clone http://$PKG src/$PKG - cd src/$PKG && hg checkout -r $REV && rm -fr .hg - ) -} +clone git github.com/gorilla/context 708054d61e5 -git_clone github.com/kr/pty 3b1f6487b +clone git github.com/gorilla/mux 9b36453141c -git_clone github.com/gorilla/context/ 708054d61e5 +clone git github.com/syndtr/gocapability 3454319be2 -git_clone github.com/gorilla/mux/ 9b36453141c +clone hg code.google.com/p/go.net 84a4013f96e0 -git_clone github.com/syndtr/gocapability 3454319be2 - -hg_clone code.google.com/p/go.net 84a4013f96e0 - -hg_clone code.google.com/p/gosqlite 74691fb6f837 +clone hg code.google.com/p/gosqlite 74691fb6f837