about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2022-06-23 16:32:15 -0700
committerEric Huss <eric@huss.org>2022-06-23 16:32:15 -0700
commit124557c05d25e4f7f6a4f549816e9be012e46d57 (patch)
tree065fbb2eb66ddd36ffd227448bcc45c06f86db7a
parent1d7c20c345b0042b8dd2eeda2892c872fc68b3ca (diff)
downloadrust-124557c05d25e4f7f6a4f549816e9be012e46d57.tar.gz
rust-124557c05d25e4f7f6a4f549816e9be012e46d57.zip
Move init_repo.sh to checkout-submodules.sh
checkout-submodules.sh is no longer serving any purpose other than to
run init_repo.
-rwxr-xr-xsrc/ci/init_repo.sh72
-rwxr-xr-xsrc/ci/scripts/checkout-submodules.sh69
2 files changed, 65 insertions, 76 deletions
diff --git a/src/ci/init_repo.sh b/src/ci/init_repo.sh
deleted file mode 100755
index 23c5ec559e4..00000000000
--- a/src/ci/init_repo.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errexit
-set -o pipefail
-set -o nounset
-
-ci_dir=$(cd $(dirname $0) && pwd)
-. "$ci_dir/shared.sh"
-
-REPO_DIR="$1"
-
-if [ ! -d "$REPO_DIR" -o ! -d "$REPO_DIR/.git" ]; then
-    echo "Error: $REPO_DIR does not exist or is not a git repo"
-    exit 1
-fi
-cd $REPO_DIR
-
-# On the beta channel we'll be automatically calculating the prerelease version
-# via the git history, so unshallow our shallow clone from CI.
-if [ "$(releaseChannel)" = "beta" ]; then
-  git fetch origin --unshallow beta master
-fi
-
-function fetch_github_commit_archive {
-    local module=$1
-    local cached="download-${module//\//-}.tar.gz"
-    retry sh -c "rm -f $cached && \
-        curl -f -sSL -o $cached $2"
-    mkdir $module
-    touch "$module/.git"
-    # On Windows, the default behavior is to emulate symlinks by copying
-    # files. However, that ends up being order-dependent while extracting,
-    # which can cause a failure if the symlink comes first. This env var
-    # causes tar to use real symlinks instead, which are allowed to dangle.
-    export MSYS=winsymlinks:nativestrict
-    tar -C $module --strip-components=1 -xf $cached
-    rm $cached
-}
-
-# Archive downloads are temporarily disabled due to sudden 504
-# gateway timeout errors.
-# included="src/llvm-project src/doc/book src/doc/rust-by-example"
-included=""
-modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
-modules=($modules)
-use_git=""
-urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
-urls=($urls)
-# shellcheck disable=SC2068
-for i in ${!modules[@]}; do
-    module=${modules[$i]}
-    if [[ " $included " = *" $module "* ]]; then
-        commit="$(git ls-tree HEAD $module | awk '{print $3}')"
-        git rm $module
-        url=${urls[$i]}
-        url=${url/\.git/}
-        fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
-        bg_pids[${i}]=$!
-        continue
-    else
-        use_git="$use_git $module"
-    fi
-done
-retry sh -c "git submodule deinit -f $use_git && \
-    git submodule sync && \
-    git submodule update -j 16 --init --recursive --depth 1 $use_git"
-# STATUS=0
-# for pid in ${bg_pids[*]}
-# do
-#     wait $pid || STATUS=1
-# done
-# exit ${STATUS}
diff --git a/src/ci/scripts/checkout-submodules.sh b/src/ci/scripts/checkout-submodules.sh
index 06cc5866f69..3eb4b8f9058 100755
--- a/src/ci/scripts/checkout-submodules.sh
+++ b/src/ci/scripts/checkout-submodules.sh
@@ -2,9 +2,70 @@
 # Check out all our submodules, but more quickly than using git by using one of
 # our custom scripts
 
-set -euo pipefail
-IFS=$'\n\t'
+set -o errexit
+set -o pipefail
+set -o nounset
 
-source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
+if [ ! -d ".git" ]; then
+    echo "Error: This must run in the root of the repository"
+    exit 1
+fi
 
-"$(cd "$(dirname "$0")" && pwd)/../init_repo.sh" .
+ci_dir=$(cd $(dirname $0) && pwd)/..
+. "$ci_dir/shared.sh"
+
+# On the beta channel we'll be automatically calculating the prerelease version
+# via the git history, so unshallow our shallow clone from CI.
+if [ "$(releaseChannel)" = "beta" ]; then
+  git fetch origin --unshallow beta master
+fi
+
+function fetch_github_commit_archive {
+    local module=$1
+    local cached="download-${module//\//-}.tar.gz"
+    retry sh -c "rm -f $cached && \
+        curl -f -sSL -o $cached $2"
+    mkdir $module
+    touch "$module/.git"
+    # On Windows, the default behavior is to emulate symlinks by copying
+    # files. However, that ends up being order-dependent while extracting,
+    # which can cause a failure if the symlink comes first. This env var
+    # causes tar to use real symlinks instead, which are allowed to dangle.
+    export MSYS=winsymlinks:nativestrict
+    tar -C $module --strip-components=1 -xf $cached
+    rm $cached
+}
+
+# Archive downloads are temporarily disabled due to sudden 504
+# gateway timeout errors.
+# included="src/llvm-project src/doc/book src/doc/rust-by-example"
+included=""
+modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
+modules=($modules)
+use_git=""
+urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
+urls=($urls)
+# shellcheck disable=SC2068
+for i in ${!modules[@]}; do
+    module=${modules[$i]}
+    if [[ " $included " = *" $module "* ]]; then
+        commit="$(git ls-tree HEAD $module | awk '{print $3}')"
+        git rm $module
+        url=${urls[$i]}
+        url=${url/\.git/}
+        fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
+        bg_pids[${i}]=$!
+        continue
+    else
+        use_git="$use_git $module"
+    fi
+done
+retry sh -c "git submodule deinit -f $use_git && \
+    git submodule sync && \
+    git submodule update -j 16 --init --recursive --depth 1 $use_git"
+# STATUS=0
+# for pid in ${bg_pids[*]}
+# do
+#     wait $pid || STATUS=1
+# done
+# exit ${STATUS}