我有一个自动化脚本,除其他任务外,它还更新源代码,apt-get update
然后通过apt-get install
.
偶尔(10-20% 的时间)apt-get update
会失败并出现以下错误:
init[356]: W: 获取失败http://http.us.debian.org/debian/dists/jessie/main/source/Sources 404 Not Found
init[356]: E: 某些索引文件下载失败。它们已被忽略,或使用旧的。
事实上,浏览器显示引用的文件不存在:对应的目录仅包含以下文件:
Release
Sources.gz
Sources.xz
stdout
失败的原因如下apt-get update
:
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Ign http://http.us.debian.org jessie InRelease
Get:2 http://security.debian.org jessie/updates/main Sources [160 kB]
Get:3 http://http.us.debian.org jessie-updates InRelease [142 kB]
Get:4 http://security.debian.org jessie/updates/main amd64 Packages [302 kB]
Get:5 http://security.debian.org jessie/updates/main Translation-en [161 kB]
Hit http://http.us.debian.org jessie Release.gpg
Get:6 http://http.us.debian.org jessie-updates/main Sources [15.5 kB]
Get:7 http://http.us.debian.org jessie-updates/main amd64 Packages/DiffIndex [5,440 B]
Get:8 http://http.us.debian.org jessie-updates/main Translation-en/DiffIndex [2,704 B]
Hit http://http.us.debian.org jessie Release
Get:9 http://http.us.debian.org jessie/main amd64 Packages [6,761 kB]
Get:10 http://http.us.debian.org jessie/main Translation-en [4,580 kB]
Err http://http.us.debian.org jessie/main Sources
404 Not Found
Fetched 12.2 MB in 28s (433 kB/s)
最后两个 HTTP 请求是:
http://http.us.debian.org/debian/dists/jessie/main/i18n/Translation-en.bz2
http://http.us.debian.org/debian/dists/jessie/main/source/Sources
相比之下,这是apt-get update
在原始机器失败后从同一台机器手动运行的:
Ign http://http.us.debian.org jessie InRelease
Get:1 http://http.us.debian.org jessie-updates InRelease [142 kB]
Get:2 http://http.us.debian.org jessie Release.gpg [2,373 B]
Hit http://security.debian.org jessie/updates InRelease
Hit http://security.debian.org jessie/updates/main Sources
Hit http://security.debian.org jessie/updates/main amd64 Packages
Get:3 http://http.us.debian.org jessie-updates/main amd64 Packages/DiffIndex [5,440 B]
Hit http://security.debian.org jessie/updates/main Translation-en
Get:4 http://http.us.debian.org jessie-updates/main Translation-en/DiffIndex [2,704 B]
Get:5 http://http.us.debian.org jessie Release [148 kB]
Get:6 http://http.us.debian.org jessie-updates/main Sources [15.5 kB]
Get:7 http://http.us.debian.org jessie/main Sources [7,057 kB]
Get:8 http://http.us.debian.org jessie/main amd64 Packages [6,761 kB]
Get:9 http://http.us.debian.org jessie/main Translation-en [4,580 kB]
Fetched 18.7 MB in 12s (1,557 kB/s)
Reading package lists... Done
Get:7
以及对应于to 的三个 URI Get:9
:
http://http.us.debian.org/debian/dists/jessie/main/source/Sources.xz
http://http.us.debian.org/debian/dists/jessie/main/binary-amd64/Packages.xz
http://http.us.debian.org/debian/dists/jessie/main/i18n/Translation-en.bz2
为什么apt-get update
有时会发现应该下载Sources.xz
,而其他时候却试图获取丢失的内容Sources
?
答案1
从任何地方下载 xz(或 gz)压缩列表文件
echo 'Acquire::CompressionTypes::Order:: { "xz"; "gz"; };' > /etc/apt/apt.conf.d/47compress