From f79998f626801329580c782fd05e36cb2027f474 Mon Sep 17 00:00:00 2001 From: donjuanplatinum <113148619+donjuanplatinum@users.noreply.github.com> Date: Sat, 18 May 2024 00:22:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0rust=20sparse=E7=A8=80?= =?UTF-8?q?=E7=96=8F=E7=B4=A2=E5=BC=95=E9=80=89=E9=A1=B9=20(#826)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/change_rust_src.sh | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/change_rust_src.sh b/tools/change_rust_src.sh index 7e78a72e..53fae27d 100644 --- a/tools/change_rust_src.sh +++ b/tools/change_rust_src.sh @@ -1,8 +1,33 @@ -# 更换Rust镜像源 -echo -e "[source.crates-io] \n \ +echo "正在为rust换源" +echo "bash change_rust_src.sh --sparse以使用稀疏索引" +sparse="false" +while true; do + if [ -z "$1" ]; then + break; + fi + case "$1" in + "--sparse") + echo "使用稀疏索引" + sparse="" + ;; + esac + shift 1 + done +if [ -z ${sparse} ]; then + echo -e "[source.crates-io] \n \ +registry = \"https://github.com/rust-lang/crates.io-index\" \n \ +\n \ +replace-with = 'tuna' \n \ +[source.tuna] \n \ +registry = \"sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/\" \n \ +" > ~/.cargo/config +else + echo -e "[source.crates-io] \n \ registry = \"https://github.com/rust-lang/crates.io-index\" \n \ \n \ replace-with = 'tuna' \n \ [source.tuna] \n \ registry = \"https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git\" \n \ -" > ~/.cargo/config \ No newline at end of file +" > ~/.cargo/config + +fi