2020-11-21 18:07:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DIR=$(dirname "$(readlink -f "$0")")
|
|
|
|
. "$DIR/../env.sh"
|
|
|
|
|
|
|
|
log "Setting up rust"
|
|
|
|
|
|
|
|
if in_china; then
|
|
|
|
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
|
|
|
|
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
|
|
|
|
|
2020-11-23 02:00:49 +00:00
|
|
|
if has_cmd fish >/dev/null; then
|
2020-11-21 18:07:26 +00:00
|
|
|
echo "
|
|
|
|
set -x RUSTUP_DIST_SERVER $RUSTUP_DIST_SERVER
|
|
|
|
set -x RUSTUP_UPDATE_ROOT $RUSTUP_UPDATE_ROOT
|
|
|
|
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/rustup.fish"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# setup cargo mirrors
|
2020-11-23 02:00:49 +00:00
|
|
|
if [ ! -f "$HOME/.cargo/config" ]; then
|
|
|
|
mkdir -p "$HOME/.cargo"
|
|
|
|
echo "
|
|
|
|
[source.crates-io]
|
|
|
|
replace-with = 'ustc'
|
2020-11-21 18:07:26 +00:00
|
|
|
|
2020-11-23 02:00:49 +00:00
|
|
|
[source.ustc]
|
|
|
|
registry = \"git://mirrors.ustc.edu.cn/crates.io-index\"
|
|
|
|
" | sed 's/^ *//' > "$HOME/.cargo/config"
|
|
|
|
fi
|
2020-11-21 18:07:26 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-23 02:00:49 +00:00
|
|
|
if [ ! -f "$HOME/.cargo/bin/rustup" ]; then
|
|
|
|
curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh
|
|
|
|
fi
|
2020-11-21 18:07:26 +00:00
|
|
|
|
2020-11-23 02:00:49 +00:00
|
|
|
if has_cmd fish; then
|
|
|
|
echo "
|
|
|
|
source $HOME/.cargo/env
|
|
|
|
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish"
|
|
|
|
fi
|