Skip to content

Commit 495b216

Browse files
committed
Auto merge of rust-lang#98439 - ehuss:cleanup-ci-script, r=Mark-Simulacrum
Clean up submodule checkout scripts This is just some small cleanup: * Removed unused CACHE_DIR stuff * Removed duplicate fetch_github_commit_archive function which is no longer used * Combined init_repo.sh and checkout-submodules.sh, as checkout-submodules.sh was doing nothing but calling init_repo.sh
2 parents 0e21a27 + 124557c commit 495b216

File tree

3 files changed

+63
-104
lines changed

3 files changed

+63
-104
lines changed

src/ci/docker/host-x86_64/dist-various-2/shared.sh

-12
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,3 @@ function retry {
3333
}
3434
done
3535
}
36-
37-
# Copied from ../../init_repo.sh
38-
function fetch_github_commit_archive {
39-
local module=$1
40-
local cached="download-${module//\//-}.tar.gz"
41-
retry sh -c "rm -f $cached && \
42-
curl -f -sSL -o $cached $2"
43-
mkdir $module
44-
touch "$module/.git"
45-
tar -C $module --strip-components=1 -xf $cached
46-
rm $cached
47-
}

src/ci/init_repo.sh

-83
This file was deleted.

src/ci/scripts/checkout-submodules.sh

+63-9
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,70 @@
22
# Check out all our submodules, but more quickly than using git by using one of
33
# our custom scripts
44

5-
set -euo pipefail
6-
IFS=$'\n\t'
5+
set -o errexit
6+
set -o pipefail
7+
set -o nounset
78

8-
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
9+
if [ ! -d ".git" ]; then
10+
echo "Error: This must run in the root of the repository"
11+
exit 1
12+
fi
13+
14+
ci_dir=$(cd $(dirname $0) && pwd)/..
15+
. "$ci_dir/shared.sh"
916

10-
if isWindows; then
11-
path="/c/cache/rustsrc"
12-
else
13-
path="${HOME}/rustsrc"
17+
# On the beta channel we'll be automatically calculating the prerelease version
18+
# via the git history, so unshallow our shallow clone from CI.
19+
if [ "$(releaseChannel)" = "beta" ]; then
20+
git fetch origin --unshallow beta master
1421
fi
1522

16-
mkdir -p "${path}"
17-
"$(cd "$(dirname "$0")" && pwd)/../init_repo.sh" . "${path}"
23+
function fetch_github_commit_archive {
24+
local module=$1
25+
local cached="download-${module//\//-}.tar.gz"
26+
retry sh -c "rm -f $cached && \
27+
curl -f -sSL -o $cached $2"
28+
mkdir $module
29+
touch "$module/.git"
30+
# On Windows, the default behavior is to emulate symlinks by copying
31+
# files. However, that ends up being order-dependent while extracting,
32+
# which can cause a failure if the symlink comes first. This env var
33+
# causes tar to use real symlinks instead, which are allowed to dangle.
34+
export MSYS=winsymlinks:nativestrict
35+
tar -C $module --strip-components=1 -xf $cached
36+
rm $cached
37+
}
38+
39+
# Archive downloads are temporarily disabled due to sudden 504
40+
# gateway timeout errors.
41+
# included="src/llvm-project src/doc/book src/doc/rust-by-example"
42+
included=""
43+
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
44+
modules=($modules)
45+
use_git=""
46+
urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
47+
urls=($urls)
48+
# shellcheck disable=SC2068
49+
for i in ${!modules[@]}; do
50+
module=${modules[$i]}
51+
if [[ " $included " = *" $module "* ]]; then
52+
commit="$(git ls-tree HEAD $module | awk '{print $3}')"
53+
git rm $module
54+
url=${urls[$i]}
55+
url=${url/\.git/}
56+
fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
57+
bg_pids[${i}]=$!
58+
continue
59+
else
60+
use_git="$use_git $module"
61+
fi
62+
done
63+
retry sh -c "git submodule deinit -f $use_git && \
64+
git submodule sync && \
65+
git submodule update -j 16 --init --recursive --depth 1 $use_git"
66+
# STATUS=0
67+
# for pid in ${bg_pids[*]}
68+
# do
69+
# wait $pid || STATUS=1
70+
# done
71+
# exit ${STATUS}

0 commit comments

Comments
 (0)