5

I'm trying to make apt-get use Acquire::By-Hash option, so it will download packages identifying them by cryptographic hash, not by package version. This should prevent race conditions and "Hash Sum Mismatch" errors happening sometimes while trying to apt-get install something.

I can't make apt-get use this method. I tried

  1. Putting Acquire::By-Hash "force"; to /etc/apt/apt.conf.d/51acquire_by_hash
  2. Changing sources.list: deb [by-hash=force] http://ftp.us.debian.org/debian/ buster main contrib non-free
  3. Using -o Acquire::by-hash=force apt-get option Neither works. apt-get still uses the old method (see the URLs it's requesting)
# 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) ...

The mirror supports By-Hash:

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

Any ideas how to make apt-get use that options? Thank you.

1 Answer 1

5

The manual for apt.conf(5) says, for Acquire::By-Hash:

Try to download indexes via an URI constructed from a hashsum of the expected file

(my emphasis)

In my testing the following worked as expected (after cleaning out /var/lib/apt/lists, which apt clean didn't seem to do a good job of). Since I have a local mirror I could verify the requested indexes from its log too:

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

so the manual is correct and accurate. Acquiring the packages themselves by hash is not supported, only the indexes.

1
  • Clean only clears archive files, not package lists.
    – Braiam
    Aug 9, 2020 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.