1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Clean and simplify vendor.sh while making it easier to maintain as well

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
Tianon Gravi 2014-01-15 22:16:23 -07:00
parent 20f36f088c
commit 40b40cffb1

View file

@ -1,54 +1,52 @@
#!/bin/bash #!/bin/bash
set -e
cd "$(dirname "$BASH_SOURCE")/.."
# Downloads dependencies into vendor/ directory # Downloads dependencies into vendor/ directory
if [[ ! -d vendor ]]; then mkdir -p vendor
mkdir vendor cd vendor
fi
vendor_dir=${PWD}/vendor
rm_pkg_dir () { clone() {
PKG=$1 vcs=$1
REV=$2 pkg=$2
( rev=$3
set -e
cd $vendor_dir pkg_url=https://$pkg
if [[ -d src/$PKG ]]; then target_dir=src/$pkg
echo "src/$PKG already exists. Removing."
rm -fr src/$PKG echo -n "$pkg @ $rev: "
fi
) 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 () { clone git github.com/kr/pty 3b1f6487b
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
)
}
hg_clone () { clone git github.com/gorilla/context 708054d61e5
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
)
}
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 clone hg code.google.com/p/gosqlite 74691fb6f837
hg_clone code.google.com/p/go.net 84a4013f96e0
hg_clone code.google.com/p/gosqlite 74691fb6f837