我们在http://ubuntu.wikimedia.org/ubuntu/ ( https://mirrors.wikimedia.org/debian/ ) 上有 Ubuntu (Debian) 的本地镜像。我想将客户端配置为更喜欢从这些镜像下载/仅下载软件包,而不是http://nova.clouds.archive.ubuntu.com/ubuntu/ ( http://httpredir.debian.org/debian/ )。我可以通过替换 中的 URL 来成功完成此操作/etc/apt/sources.list,但是我有兴趣在不进行更改的情况下执行此操作/etc/apt/sources.list,以便自定义很明显并且可以轻松恢复。
我创建的/etc/apt/sources.list.d/wikimedia-mirror.list内容为:
deb http://ubuntu.wikimedia.org/ubuntu/ trusty main universe
deb-src http://ubuntu.wikimedia.org/ubuntu/ trusty main universe
Run Code Online (Sandbox Code Playgroud)
与/etc/apt/preferences.d/wikimedia-mirror.pref:
Package: *
Pin: origin "ubuntu.wikimedia.org"
Pin-Priority: 501
Run Code Online (Sandbox Code Playgroud)
之后apt-get update,这将导致镜像中的包的优先级为 501,但apt-get仍会从原始源下载这些包:
scfc@toolsbeta-t68121-trusty:~$ apt-cache policy zsh-doc
zsh-doc:
Installed: (none)
Candidate: 5.0.2-3ubuntu6
Version table:
5.0.5-4ubuntu1~ubuntu14.04.1 0
100 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty-backports/main amd64 Packages
5.0.2-3ubuntu6 0
500 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
501 http://ubuntu.wikimedia.org/ubuntu/ trusty/main amd64 Packages
scfc@toolsbeta-t68121-trusty:~$ sudo apt-get install zsh-doc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
zsh-doc
0 upgraded, 1 newly installed, 0 to remove and 35 not upgraded.
Need to get 2,274 kB of archives.
After this operation, 5,856 kB of additional disk space will be used.
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty/main zsh-doc all 5.0.2-3ubuntu6 [2,274 kB]
Fetched 2,274 kB in 3s (631 kB/s)
Selecting previously unselected package zsh-doc.
(Reading database ... 38984 files and directories currently installed.)
Preparing to unpack .../zsh-doc_5.0.2-3ubuntu6_all.deb ...
Unpacking zsh-doc (5.0.2-3ubuntu6) ...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Setting up zsh-doc (5.0.2-3ubuntu6) ...
scfc@toolsbeta-t68121-trusty:~$
Run Code Online (Sandbox Code Playgroud)
此行为与以下文档一致apt_preferences(5):
当sources.list (5)` 文件包含对多个源的引用时,同一版本的包的多个实例可能可用。在这种情况下,apt-get下载在sources.list (5) 文件中最早列出的实例。APT 首选项不会影响实例的选择,只会影响版本的选择。
有没有什么方法可以在不改变的情况下更喜欢镜像而不是原始来源/etc/apt/sources.list?文件 in 可以/etc/apt/sources.list.d“早于” 吗/etc/apt/sources.list?是否有一个配置选项可以(滥用)用于“映射”URL?
| 归档时间: |
|
| 查看次数: |
817 次 |
| 最近记录: |