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

所以手冊是正確和準確的。不支援透過哈希獲取包本身,僅支援索引。

相關內容