中科大大法好

论如何切换各种镜像源

 

copy from LUG@USTC

Ubuntu镜像使用帮助

收录架构

ALL

收录版本

所有 Ubuntu 当前支持的版本,包括开发版,具体版本见 https://wiki.ubuntu.com/Releases

对于 Ubuntu 不再支持的版本,请参考 Ubuntu Old Releasehttp://mirrors.ustc.edu.cn/ubuntu-old-releases/

使用说明

软件包管理中心(推荐)

在软件包管理中心“软件源”中选择“中国的服务器”下mirrors.ustc.edu.cn即可自动使用。

手动更改配置文件

以 Utopic Unicorn (14.10) 为例, 编辑 /etc/apt/sources.list 文件 (需要使用 sudo), 在文件最前面添加以下条目(操作前请做好相应备份)

deb http://mirrors.ustc.edu.cn/ubuntu/ utopic main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ utopic-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ utopic-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ utopic-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ utopic-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ utopic main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ utopic-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ utopic-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ utopic-proposed main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ utopic-backports main restricted universe multiverse

如果您使用的是 Utopic (14.10) 以外的版本,或者希望选择 IPv4/IPv6、HTTP/FTP,请使用 snullp 大叔开发的 配置生成器

PyPI 镜像使用帮助

如何使用科大 mirrors 加速 pip?

编辑 ~/.pip/pip.conf 文件(如果没有则创建之),将 index-url 开头的一行修改为下面一行:

index-url = https://pypi.mirrors.ustc.edu.cn/simple

如果运行 pip 时, 提示如下错误

configparser.MissingSectionHeaderError: File contains no section headers.

请在 ~/.pip/pip.conf 最上方加上 [global] 这一 section header

同步方式

使用 bandersnatch,每4小时从 pypi.python.org 官方同步。

NPM镜像使用帮助

中科大镜像站的 npm 镜像是 https://registry.npmjs.org/ 的反代。

使用说明

编辑 ~/.npmrc,添加

registry=http://npmreg.mirrors.ustc.edu.cn/

若不想将本源设置为默认源,只想使用本源安装某个软件包,可在安装包时采用以下用法:

npm --registry http://npmreg.mirrors.ustc.edu.cn install <packagename>

中科大 npm 镜像支持 https 安全连接,如果您的网络运营商部署了缓存设备,或您对所处的网络环境不信任,请使用 https 替换上述 URL 中的 http

注意事项

不支持 publish,若出现错误,请将 ~/.npmrc 中的用户名密码部分注释掉,并删除缓存 (rm -rf ~/.npm) 重试。

 

Android 镜像使用帮助

按照 Google 官方教程 https://source.android.com/source/downloading.html

https://android.googlesource.com/platform/manifest 替换为 git://mirrors.ustc.edu.cn/aosp/platform/manifest

具体做法摘录如下(以防墙抽风):

首先下载 repo 工具。

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
## 如果上述 URL 不可访问,可以用下面的:
## curl https://storage-googleapis.lug.ustc.edu.cn/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

然后建立一个工作目录(名字任意)

mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY

初始化仓库:

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
## 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的:
## REPO_URL = 'https://gerrit-googlesource.lug.ustc.edu.cn/git-repo'

如果需要某个特定的 Android 版本(Android 版本列表):

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.0.1_r1

同步源码树(以后只需执行这条命令来同步):

repo sync

已有仓库如何改用科大源

如果您已经从官方同步了 AOSP 仓库,现在希望使用科大的 AOSP 仓库,请修改 .repo/manifests.git/config,将

url = https://android.googlesource.com/platform/manifest

修改成

url = git://mirrors.ustc.edu.cn/aosp/platform/manifest

即可。

通过 HTTP 协议同步(不推荐)

如果由于某种原因不能通过 git 协议同步,请修改 .repo/manifests.git/config,将

url = git://mirrors.ustc.edu.cn/aosp/platform/manifest

修改成

url = http://mirrors.ustc.edu.cn/aosp/platform/manifest

不推荐使用 HTTP 协议同步,因为 HTTP 服务器不支持 repo sync--depth 选项,可能导致部分仓库同步失败。

通过 HTTP 同步过程中可能提示 clone.bundle 404 错误,这是正常现象,可以忽略。

说明

  1. 本镜像每天凌晨 04:30 同步一次。同步可能需要较长时间,因此使用本镜像时建议避开凌晨 04:30~06:00 这段时间。
  2. 由于硬盘 I/O 资源有限,Git 服务器每 IP 限制 5 个并发连接。repo sync 命令默认使用 4 个并发连接,请勿使用 -j 参数增加并发连接数。

 

 

RPMFusion 使用说明

rpmfusion是为Fedora/RHEL提供额外rpm软件包的第三方软件源。

配置方式

使用下列命令,可以同时启用其freenonfree软件源:

Fedora 22+

su -c 'dnf install http://mirrors.ustc.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://mirrors.ustc.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'

Fedora 14 至 Fedora 21

su -c 'yum install --nogpgcheck http://mirrors.ustc.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://mirrors.ustc.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'

RHEL 5 或兼容系统

su -c 'rpm -Uvh http://mirrors.ustc.edu.cn/rpmfusion/free/el/updates/5/i386/rpmfusion-free-release-5-1.noarch.rpm http://mirrors.ustc.edu.cn/rpmfusion/nonfree/el/updates/5/i386/rpmfusion-nonfree-release-5-1.noarch.rpm'

RHEL 6 或兼容系统

su -c 'yum localinstall --nogpgcheck http://mirrors.ustc.edu.cn/rpmfusion/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm http://mirrors.ustc.edu.cn/rpmfusion/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm'

备注

安装好以上rpm(主要包括rpmfusion相应的repo文件)后,您可能需要再运行:

sudo yum makecache

以更新缓存。根据版本不同,可能需要将yum替换为dnf

在 RHEL 或兼容发行版上,您可能需要预先启用EPEL

未尽内容,请参阅官方配置指南(链接附后)。

相关链接

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注