![14.04 根据区域 apt 存储库的不同结果不同](https://linux22.com/image/1086241/14.04%20%E6%A0%B9%E6%8D%AE%E5%8C%BA%E5%9F%9F%20apt%20%E5%AD%98%E5%82%A8%E5%BA%93%E7%9A%84%E4%B8%8D%E5%90%8C%E7%BB%93%E6%9E%9C%E4%B8%8D%E5%90%8C.png)
突然apt-get update
开始失败,在调查时我发现了一个奇怪的行为:
$ cat /etc/apt/sources.list
deb http://il.archive.ubuntu.com/ubuntu/ trusty main restricted
$ apt-get update
Ign http://il.archive.ubuntu.com trusty InRelease
Hit http://il.archive.ubuntu.com trusty Release.gpg
Hit http://il.archive.ubuntu.com trusty Release
Hit http://il.archive.ubuntu.com trusty/main amd64 Packages
Hit http://il.archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://il.archive.ubuntu.com trusty/main Translation-en
Hit http://il.archive.ubuntu.com trusty/restricted Translation-en
Ign http://il.archive.ubuntu.com trusty/main Translation-en_US
Ign http://il.archive.ubuntu.com trusty/restricted Translation-en_US
Reading package lists... Done
$ sed -i 's/il/us/g' /etc/apt/sources.list
$ cat /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
$ apt-get update
Ign http://us.archive.ubuntu.com trusty InRelease
Get:1 http://us.archive.ubuntu.com trusty Release.gpg [72 B]
Get:2 http://us.archive.ubuntu.com trusty Release [11.9 kB]
Get:3 http://us.archive.ubuntu.com trusty/main amd64 Packages [14 B]
Fetched 12.0 kB in 0s (20.6 kB/s)
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/trusty/Release Unable to find expected entry 'restricted/binary-amd64/Packages' in Release file (Wrong sources.list entry or malformed file)
E: Some index files failed to download. They have been ignored, or old ones used instead.
我认为前缀(il
或us
)仅表示使用哪个官方 ubuntu 存储库的 cdn。难道是官方的 ubuntu apt 存储库之间存在差异?
更新:
我前往ubuntu 源列表生成器重新生成 ubuntu 源列表(不包含“受限”分支),以验证 URL 是否正确——如下所示,唯一不同的是区域后缀,它与上面的代码片段相匹配。
$ curl -s https://repogen.simplylinux.ch/txt/sources_abed64b7b6ab23d5c4ffe668bbe70d3c37144a3a.txt | grep ^deb && curl -s https://repogen.simplylinux.ch/txt/sources_99dc7e2a260ff96dbe49910f005d2ab82862458e.txt | grep ^deb
deb http://il.archive.ubuntu.com/ubuntu/ trusty main
deb http://us.archive.ubuntu.com/ubuntu/ trusty main
更新2:
对我来说它是可重复的。应该告知谁?
更新 3:
以下是更多详细信息:
$ dpkg --print-architecture
amd64
$ wget -q -O- http://us.archive.ubuntu.com/ubuntu/dists/trusty/Release | grep 'restricted/binary-amd64/Packages'
$ echo $?
1
$ dig us.archive.ubuntu.com | grep IN
;us.archive.ubuntu.com. IN A
us.archive.ubuntu.com. 57 IN A 91.189.91.15
us.archive.ubuntu.com. 57 IN A 91.189.91.24
us.archive.ubuntu.com. 57 IN A 91.189.91.23
us.archive.ubuntu.com. 57 IN A 91.189.91.13
us.archive.ubuntu.com. 57 IN A 91.189.91.14
答案1
https://askubuntu.com/a/37754解决了我的问题。附上原始答案的一小段摘录:
文件顶部的内容
/etc/apt/sources.list
应该是让它根据您的地理位置自动为您选择镜像所需的全部内容。
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main restricted universe multiverse