我是否可以将多个替代存储库添加到 中的*.list
文件中/etc/apt/sources.list.d
,以便对于指定的包,如果第一个存储库不可用,apt-get
将尝试从列表中的下一个存储库下载相同的包?
例如,我可以创建一个/etc/apt/sources.list.d/games.list
包含以下内容的文件吗?...
deb http://archive.getdeb.net/ubuntu trusty-getdeb apps
deb http://mirrors.dotsrc.org/getdeb/ubuntu trusty-getdeb games
Run Code Online (Sandbox Code Playgroud)
...这样,如果http://archive.getdeb.net/ubuntu
关闭,将apt-get
自动尝试http://mirrors.dotsrc.org/getdeb/ubuntu
?
我相信我已经回答了我自己的问题:
apt-get 与 sources.list.d 的行为是从给定*.list
文件中列出的第一个可用存储库中检索包。
存储库archive.getdeb.net/ubuntu
今天很方便地关闭,因此我能够执行以下实验来验证这一点:
我创建了一个名为/etc/apt/sources.list.d/games.list
以下内容的文件:
deb http://archive.getdeb.net/ubuntu trusty-getdeb apps
Run Code Online (Sandbox Code Playgroud)然后我从源重新同步包索引文件:
$ sudo apt-get update | grep getdeb
Hit http://archive.getdeb.net trusty-getdeb InRelease
Hit http://archive.getdeb.net trusty-getdeb/apps amd64 Packages
Hit http://archive.getdeb.net trusty-getdeb/apps i386 Packages
Ign http://archive.getdeb.net trusty-getdeb/apps Translation-en_US
Ign http://archive.getdeb.net trusty-getdeb/apps Translation-en
Run Code Online (Sandbox Code Playgroud)
我注意到 apt-get 警告它忽略 ( Ign
) 存储库。这是因为 apt-get 收到 404 消息,表明 URL 不可用。
尝试模拟从该存储库安装软件包表明该存储库确实不可用。
$ sudo apt-get -s install warsow
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package warsow
Run Code Online (Sandbox Code Playgroud)然后我编辑/etc/apt/sources.list.d/games.list
,添加一个包含相同包的镜像存储库:
deb http://archive.getdeb.net/ubuntu trusty-getdeb apps
deb http://mirrors.dotsrc.org/getdeb/ubuntu trusty-getdeb games
Run Code Online (Sandbox Code Playgroud)和以前一样,我从源重新同步了包索引文件:
$ sudo apt-get update | grep getdeb
Get:1 http://mirrors.dotsrc.org trusty-getdeb InRelease [8,131 B]
Hit http://archive.getdeb.net trusty-getdeb InRelease
Get:2 http://mirrors.dotsrc.org trusty-getdeb/games amd64 Packages [69.8 kB]
Hit http://archive.getdeb.net trusty-getdeb/apps amd64 Packages
Hit http://archive.getdeb.net trusty-getdeb/apps i386 Packages
Get:3 http://mirrors.dotsrc.org trusty-getdeb/games i386 Packages [71.5 kB]
Ign http://archive.getdeb.net trusty-getdeb/apps Translation-en_US
Ign http://archive.getdeb.net trusty-getdeb/apps Translation-en
Ign http://mirrors.dotsrc.org trusty-getdeb/games Translation-en_US
Ign http://mirrors.dotsrc.org trusty-getdeb/games Translation-en
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是,apt-get 警告说它忽略了两个存储库!
一项小小的互联网研究表明,Ign
如果存储库不可用或包翻译不可用,apt-get 会显示警告。在 的情况下mirrors.dotsrc.org
,存储库已启动,但 apt-get 请求从英语翻译成英语,这显然不存在。因此,Ign
新存储库的消息毕竟不是错误。
当我尝试模拟安装与以前相同的包时,两个存储库都在/etc/apt/sources.list.d/games.list
.apt-get 中,但确实找到了该包。
$ sudo apt-get -s install warsow
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
warsow-data
The following NEW packages will be installed:
warsow warsow-data
0 upgraded, 2 newly installed, 0 to remove and 24 not upgraded.
Inst warsow-data (1.51-1~getdeb2 GetDeb:14.04/trusty-getdeb [all])
Inst warsow (1.51-1~getdeb1 GetDeb:14.04/trusty-getdeb [amd64])
Conf warsow-data (1.51-1~getdeb2 GetDeb:14.04/trusty-getdeb [all])
Conf warsow (1.51-1~getdeb1 GetDeb:14.04/trusty-getdeb [amd64])
Run Code Online (Sandbox Code Playgroud)因此,apt-get 与 sources.list.d 的行为是从给定*.list
文件中列出的第一个可用存储库中检索包。
归档时间: |
|
查看次数: |
3094 次 |
最近记录: |