7 ci_dir=$(cd $(dirname $0) && pwd)
10 travis_fold start init_repo
16 cache_src_dir="$CACHE_DIR/src"
18 if [ ! -d "$REPO_DIR" -o ! -d "$REPO_DIR/.git" ]; then
19 echo "Error: $REPO_DIR does not exist or is not a git repo"
23 if [ ! -d "$CACHE_DIR" ]; then
24 echo "Error: $CACHE_DIR does not exist or is not an absolute path"
31 # On the beta channel we'll be automatically calculating the prerelease version
32 # via the git history, so unshallow our shallow clone from CI.
33 if grep -q RUST_RELEASE_CHANNEL=beta src/ci/run.sh; then
34 git fetch origin --unshallow beta master
37 function fetch_submodule {
39 local cached="download-${module//\//-}.tar.gz"
40 retry sh -c "rm -f $cached && \
41 curl -sSL -o $cached $2"
44 tar -C $module --strip-components=1 -xf $cached
48 included="src/llvm-project src/llvm-emscripten src/doc/book src/doc/rust-by-example"
49 modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
52 urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
54 for i in ${!modules[@]}; do
56 if [[ " $included " = *" $module "* ]]; then
57 commit="$(git ls-tree HEAD $module | awk '{print $3}')"
61 fetch_submodule $module "$url/archive/$commit.tar.gz" &
64 use_git="$use_git $module"
67 retry sh -c "git submodule deinit -f $use_git && \
68 git submodule sync && \
69 git submodule update -j 16 --init --recursive $use_git"
71 travis_fold end init_repo