Merge branch 'pr-385'

Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
This commit is contained in:
Miao Wang 2023-08-21 15:57:10 +08:00
commit 5d9eef4b3c
No known key found for this signature in database
GPG Key ID: B031E3CA7BFED96E
3 changed files with 63 additions and 8 deletions

View File

@ -11,7 +11,7 @@ mirrorid: crates.io-index.git
<form class="form-inline">
<div class="form-group">
<label>是否使用 HTTPS</label>
<select id="http-select" class="form-control content-select" data-target="#content-0">
<select id="http-select" class="form-control content-select" data-target="#content-0,#content-1">
<option data-http_protocol="https://" selected></option>
<option data-http_protocol="http://"></option>
</select>
@ -22,7 +22,7 @@ mirrorid: crates.io-index.git
<form class="form-inline">
<div class="form-group">
<label>是否使用 sudo</label>
<select id="sudo-select" class="form-control content-select" data-target="#content-0">
<select id="sudo-select" class="form-control content-select" data-target="#content-0,#content-1">
<option data-sudo="sudo " data-sudoE="sudo -E " selected></option>
<option data-sudo="" data-sudoE=""></option>
</select>
@ -31,7 +31,7 @@ mirrorid: crates.io-index.git
编辑 `~/.cargo/config` 文件,添加以下内容:
编辑 `$CARGO_HOME/config` 文件,添加以下内容:
@ -53,5 +53,33 @@ registry = "{{http_protocol}}{{mirror}}"
</pre>
注:`$CARGO_HOME`:在 Windows 系统默认为:`%USERPROFILE%\.cargo`,在类 Unix 系统默认为:`$HOME/.cargo`
在 Linux 环境可以使用下面的命令完成:
{% raw %}
<script id="template-1" type="x-tmpl-markup">
mkdir -vp ${CARGO_HOME:-$HOME/.cargo}
cat << EOF | tee -a ${CARGO_HOME:-$HOME/.cargo}/config
[source.crates-io]
replace-with = 'mirror'
[source.mirror]
registry = "{{http_protocol}}{{mirror}}"
EOF
</script>
{% endraw %}
<p></p>
<pre>
<code id="content-1" class="language-bash" data-template="#template-1" data-select="#http-select,#sudo-select">
</code>
</pre>
在可能的情况下推荐使用 [Rust crates.io 稀疏索引镜像](/help/crates.io-index)

View File

@ -61,8 +61,7 @@ curl https://packages.gitlab.com/gpg.key 2> /dev/null | {{sudo}}apt-key add - &>
<div class="form-group">
<label>发行版:</label>
<select id="select-1-0" class="form-control content-select" data-target="#content-1">
<option data-os_name="debian" data-release_name="bookworm" selected>Debian 12</option>
<option data-os_name="debian" data-release_name="bullseye">Debian 11</option>
<option data-os_name="debian" data-release_name="bullseye" selected>Debian 11</option>
<option data-os_name="debian" data-release_name="buster">Debian 10</option>
<option data-os_name="debian" data-release_name="stretch">Debian 9</option>
<option data-os_name="debian" data-release_name="jessie">Debian 8</option>

View File

@ -11,7 +11,7 @@ mirrorid: crates.io-index
<form class="form-inline">
<div class="form-group">
<label>是否使用 HTTPS</label>
<select id="http-select" class="form-control content-select" data-target="#content-0">
<select id="http-select" class="form-control content-select" data-target="#content-0,#content-1">
<option data-http_protocol="https://" selected></option>
<option data-http_protocol="http://"></option>
</select>
@ -22,7 +22,7 @@ mirrorid: crates.io-index
<form class="form-inline">
<div class="form-group">
<label>是否使用 sudo</label>
<select id="sudo-select" class="form-control content-select" data-target="#content-0">
<select id="sudo-select" class="form-control content-select" data-target="#content-0,#content-1">
<option data-sudo="sudo " data-sudoE="sudo -E " selected></option>
<option data-sudo="" data-sudoE=""></option>
</select>
@ -31,7 +31,7 @@ mirrorid: crates.io-index
编辑 `~/.cargo/config` 文件,添加以下内容:
编辑 `$CARGO_HOME/config` 文件,添加以下内容:
@ -55,6 +55,34 @@ registry = "sparse+{{http_protocol}}{{mirror}}/"
注:`sparse+` 表示在使用稀疏索引,链接末尾的 `/` 不能缺少。
注:`$CARGO_HOME`:在 Windows 系统默认为:`%USERPROFILE%\.cargo`,在类 Unix 系统默认为:`$HOME/.cargo`
在 Linux 环境可以使用下面的命令完成:
{% raw %}
<script id="template-1" type="x-tmpl-markup">
mkdir -vp ${CARGO_HOME:-$HOME/.cargo}
cat << EOF | tee -a ${CARGO_HOME:-$HOME/.cargo}/config
[source.crates-io]
replace-with = 'mirror'
[source.mirror]
registry = "sparse+{{http_protocol}}{{mirror}}/"
EOF
</script>
{% endraw %}
<p></p>
<pre>
<code id="content-1" class="language-bash" data-template="#template-1" data-select="#http-select,#sudo-select">
</code>
</pre>
截至目前,可以通过 `cargo +nightly -Z sparse-registry update` 使用稀疏索引。
cargo 1.68 版本开始支持稀疏索引:不再需要完整克隆 crates.io-index 仓库,可以加快获取包的速度。如果您的 cargo 版本大于等于 1.68,可以直接使用而不需要开启 nightly。