Acquire::By-Hash apt 选项不起作用

Acquire::By-Hash apt 选项不起作用

我正在尝试使用 apt-getAcquire::By-Hash option,因此它将下载通过加密哈希而不是包版本来识别它们的包。这应该可以防止在尝试 apt-get 安装某些东西时有时发生竞争条件和“哈希和不匹配”错误。

我无法让 apt-get 使用这种方法。我试过

  1. 投入Acquire::By-Hash "force";/etc/apt/apt.conf.d/51acquire_by_hash
  2. 更改来源.列表: deb [by-hash=force] http://ftp.us.debian.org/debian/ buster main contrib non-free
  3. 使用-o Acquire::by-hash=forceapt-get 选项都不起作用。 apt-get 仍然使用旧方法(查看它请求的 URL)
# apt-get -o Acquire::by-hash=force -o Debug::Acquire::http=true install fortunes
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  fortunes
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,117 kB of archives.
After this operation, 2,611 kB of additional disk space will be used.
0% [Working]GET /debian/pool/main/f/fortune-mod/fortunes_1.99.1-7_all.deb HTTP/1.1
Host: ftp.us.debian.org
User-Agent: Debian APT-HTTP/1.3 (1.8.2.1)


0% [Waiting for headers]Answer for: http://ftp.us.debian.org/debian/pool/main/f/fortune-mod/fortunes_1.99.1-7_all.deb
HTTP/1.1 200 OK
Date: Sun, 09 Aug 2020 05:28:00 GMT
Server: Apache
Last-Modified: Thu, 15 Aug 2013 03:54:21 GMT
ETag: "110cf4-4e3f46de0807d"
Accept-Ranges: bytes
Content-Length: 1117428

Get:1 http://ftp.us.debian.org/debian buster/main amd64 fortunes all 1:1.99.1-7 [1,117 kB]
Fetched 1,117 kB in 18s (60.6 kB/s)                                                                                                              
Selecting previously unselected package fortunes.
(Reading database ... 159825 files and directories currently installed.)
Preparing to unpack .../fortunes_1%3a1.99.1-7_all.deb ...
Unpacking fortunes (1:1.99.1-7) ...
Setting up fortunes (1:1.99.1-7) ...

镜像支持By-Hash:

$ wget http://ftp.us.debian.org/debian/dists/buster/InRelease 2>/dev/null -O - | grep By-Hash
Acquire-By-Hash: yes

有什么想法如何让 apt-get 使用该选项吗?谢谢。

答案1

该手册用于apt.conf(5)说,对于Acquire::By-Hash

尝试下载索引通过由预期文件的哈希和构造的 URI

(我的重点)

在我的测试中,以下内容按预期工作(清理后/var/lib/apt/lists,这apt clean似乎做得不好)。由于我有一个本地镜像,我也可以从其日志中验证请求的索引:

apt{,-get} update -o Acquire::By-Hash="force" -o Debug::Acquire::http=true

所以该手册是正确和准确的。不支持通过哈希获取包本身,仅支持索引。

相关内容