xref: /DragonOS/tools/change_rust_src.sh (revision 59a6bcf6aee15a11a16431bdf875905c5ecf9157)
1echo "正在为rust换源"
2echo "bash change_rust_src.sh --sparse以使用稀疏索引"
3sparse="false"
4while true; do
5    if [ -z "$1" ]; then
6	break;
7    fi
8    case "$1" in
9	"--sparse")
10	    echo "使用稀疏索引"
11	    sparse=""
12	    ;;
13    esac
14    shift 1
15    done
16if [ -z ${sparse} ]; then
17    echo -e "[source.crates-io]   \n \
18registry = \"https://github.com/rust-lang/crates.io-index\"  \n \
19\n \
20replace-with = 'tuna' \n \
21[source.tuna] \n \
22registry = \"sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/\"	 \n \
23" > ~/.cargo/config.toml
24else
25        echo -e "[source.crates-io]   \n \
26registry = \"https://github.com/rust-lang/crates.io-index\"  \n \
27\n \
28replace-with = 'tuna' \n \
29[source.tuna] \n \
30registry = \"https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git\"	 \n \
31" > ~/.cargo/config.toml
32
33fi
34