(Adding Tim Woodall in CC as he appears to have already started a patch
collection for ACNG.)
I think I have found the root cause preventing the import of packages
from the local file system.
When running a package import operation, ACNG computes cryptographic
hashes ("checksums") for each package encountered. In the current
(broken) version, it uses MD5, SHA1 and SHA512.
After computing these hashes, ACNG scans the index files. When
processing the content of Packages.xz, it keeps the last cryptographic
hash specified for each package record in that file. At present (Debian
Trixie), the cryptographic hashes found in Packages.xz are MD5 and
SHA256, with the SHA256 usually coming after the MD5 hash, so SHA256 is
the (only!) hash ACNG will remember for the given package.
Unfortunately, that means that there is no common cryptographic hash
ACNG could use to match a package from the local file system to a record
in Packages.xz, causing imports to fail.
This behavior was introduced when support for parsing SHA256 hashes was
added to the processing of Packages.xz files. In ACNG's GitLab
repository, the corresponding commit is ccdc24ae, "Part of #1026848
(SHA256 checksum support)" [1]. Prior to this commit, only the MD5 hash
would have been parsed from the Packages.xz file, which would ensure a
match with the hashes computed for the package files in the local file
system.
(I also got the impression that this change of adding SHA256 does not
really integrate nicely into the existing code base, which appears to
assume only a single cryptographic hash is present in each record from
Packages.xz. Support for multiple hashes should probably be implemented
in a slightly different way than commit ccdc24ae does - not overriding
the single hash with a new value, but creating a list of hash values or
similar.)
My current workaround, which allows me to use ACNG as documented, is to
add the calculation of an SHA256 hash when scanning local package files.
This appears to work well for my purposes (I was able to import a batch
of 3k packages using it); however, I think a proper fix allowing package
records to store all provided hash values (instead of just the last one
encountered) would be the better long-term fix.
I have attached the patch to this mail; in case it gets lost, the
important part of it is also reproduced below.
(Apologies in case the format of this mail's text is broken; I am
fighting with the settings of a new instance of Thunderbird, and cannot
get it to properly produce lines of limited length.)
---
--- apt-cacher-ng-3.7.5.orig/src/pkgimport.cc
+++ apt-cacher-ng-3.7.5/src/pkgimport.cc
@@ -73,7 +73,11 @@ bool pkgimport::ProcessRegular(const mst
if(m_precachedList.find(sPath)!=m_precachedList.end())
return true; // have that already, somewhere...
- for (CSTYPES ctp : { CSTYPE_MD5, CSTYPE_SHA1,
CSTYPE_SHA512 } )
+ // BUG: When scanning Packages.xz, we only keep the last
checksum encountered for
+ // a given package. At present, this is typically
SHA256. We therefore must
+ // include SHA256 checksums in the list here as
well, otherwise we will never
+ // see a successful hit.
+ for (CSTYPES ctp : { CSTYPE_MD5, CSTYPE_SHA1,
CSTYPE_SHA256, CSTYPE_SHA512 } )
{
// get the most likely requested contents id
Kind regards,
Alexander Schulze