7 ci_dir=$(cd $(dirname $0) && pwd)
13 cache_src_dir="$CACHE_DIR/src"
15 if [ ! -d "$REPO_DIR" -o ! -d "$REPO_DIR/.git" ]; then
16 echo "Error: $REPO_DIR does not exist or is not a git repo"
20 if [ ! -d "$CACHE_DIR" ]; then
21 echo "Error: $CACHE_DIR does not exist or is not an absolute path"
28 # On the beta channel we'll be automatically calculating the prerelease version
29 # via the git history, so unshallow our shallow clone from CI.
30 if [ "$(releaseChannel)" = "beta" ]; then
31 git fetch origin --unshallow beta master
34 # Duplicated in docker/dist-various-2/shared.sh
35 function fetch_github_commit_archive {
37 local cached="download-${module//\//-}.tar.gz"
38 retry sh -c "rm -f $cached && \
39 curl -f -sSL -o $cached $2"
42 # On Windows, the default behavior is to emulate symlinks by copying
43 # files. However, that ends up being order-dependent while extracting,
44 # which can cause a failure if the symlink comes first. This env var
45 # causes tar to use real symlinks instead, which are allowed to dangle.
46 export MSYS=winsymlinks:nativestrict
47 tar -C $module --strip-components=1 -xf $cached
51 # Archive downloads are temporarily disabled due to sudden 504
52 # gateway timeout errors.
53 # included="src/llvm-project src/doc/book src/doc/rust-by-example"
55 modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
58 urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
60 # shellcheck disable=SC2068
61 for i in ${!modules[@]}; do
63 if [[ " $included " = *" $module "* ]]; then
64 commit="$(git ls-tree HEAD $module | awk '{print $3}')"
68 fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
72 use_git="$use_git $module"
75 retry sh -c "git submodule deinit -f $use_git && \
76 git submodule sync && \
77 git submodule update -j 16 --init --recursive --depth 1 $use_git"
79 # for pid in ${bg_pids[*]}
81 # wait $pid || STATUS=1