mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
Add help for CPAN
This commit is contained in:
parent
6fda32b468
commit
0fc2b36025
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
category: help
|
||||
layout: help
|
||||
mirrorid: CPAN
|
||||
---
|
||||
|
||||
CPAN 镜像使用帮助
|
||||
===================
|
||||
|
||||
[CPAN](https://www.cpan.org/) (The Comprehensive Perl Archive Network) 镜像源的配置文件为 `MyConfig.pm`(一般位于 `~/.cpan/CPAN/MyConfig.pm`),可使用包管理脚本 `cpan` 进行修改。
|
||||
|
||||
首先需确保 MyConfig.pm 配置文件存在,在命令行中执行:
|
||||
|
||||
```bash
|
||||
# 确保 MyConfig.pm 配置文件存在,如不存在则自动生成
|
||||
PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'mkmyconfig'
|
||||
|
||||
# 不使用默认配置,手动确认各个配置选项
|
||||
perl -MCPAN -e 'mkmyconfig'
|
||||
```
|
||||
|
||||
### 在 CPAN Shell 中手动设置镜像
|
||||
|
||||
在命令行中执行 `cpan` 进入 cpan shell:
|
||||
|
||||
```
|
||||
cpan shell -- CPAN exploration and modules installation
|
||||
Enter 'h' for help.
|
||||
|
||||
# 列出当前的镜像设置
|
||||
cpan[1]> o conf urllist
|
||||
|
||||
# 将本站镜像加入镜像列表顶部
|
||||
cpan[2]> o conf urllist unshift https://{{ site.hostname }}/CPAN/
|
||||
|
||||
# 或替换镜像列表,仅保留本站
|
||||
cpan[3]> o conf urllist https://{{ site.hostname }}/CPAN/
|
||||
|
||||
# 保存配置至 MyConfig.pm
|
||||
cpan[4]> o conf commit
|
||||
|
||||
# 退出 cpan shell
|
||||
cpan[5]> quit
|
||||
```
|
||||
|
||||
将本镜像加入到镜像列表的顶部
|
||||
|
||||
### 自动设置
|
||||
|
||||
在命令行中执行:
|
||||
|
||||
```bash
|
||||
# 若本站不在镜像列表中则将其加入列表顶部
|
||||
if ! (
|
||||
perl -MCPAN -e 'CPAN::HandleConfig->load();' \
|
||||
-e 'CPAN::HandleConfig->prettyprint("urllist")' |
|
||||
grep -qF 'https://{{ site.hostname }}/CPAN/'
|
||||
); then
|
||||
perl -MCPAN -e 'CPAN::HandleConfig->load();' \
|
||||
-e 'CPAN::HandleConfig->edit("urllist", "unshift", "https://{{ site.hostname }}/CPAN/");' \
|
||||
-e 'CPAN::HandleConfig->commit()'
|
||||
fi
|
||||
```
|
||||
Loading…
Reference in New Issue