aptly icon indicating copy to clipboard operation
aptly copied to clipboard

Apt Hash Sum Mismatch after publishing to s3 repo

Open l2ol33rt opened this issue 10 years ago • 6 comments

Recently attempted to publish a repo to s3 using aptly v0.9.7 and got the following error when trying to install any of the packages hosted in s3:

The following NEW packages will be installed:
  mypackage
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 14.8 MB of archives.
After this operation, 38.3 MB of additional disk space will be used.
Get:1 s3://debrepo.s3.amazonaws.com/dev/ubuntu/ precise/main mypackage amd64 1.9.7-00 [14.8 MB]
Failed to fetch s3://debrepo.s3.amazonaws.com/dev/ubuntu/pool/main/m/mypackage/mypackage_1.9.7-00_amd64.deb  Hash Sum mismatch
Fetched 14.8 MB in 0s (19.9 MB/s)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

I rolled my version of aptly back to v0.9.6 and its back to working as expected. What was weird was the hashes seemed to match for mypackage and what's in s3://debrepo.s3.amazonaws.com/dev/ubuntu/dists/precise/main/binary-amd64packages.

If you need any other information just let me know.

l2ol33rt avatar Apr 22 '16 22:04 l2ol33rt

@l2ol33rt could you please provide more info?

So the package contents are okay or damaged?

Hash sum matches package contents?

And same hash sum in Packages file?

smira avatar Apr 25 '16 13:04 smira

I get the same error. The hash in the Packages matches the correct hash. And the s3 transport method is downloading the deb correctly.

I'm not sure what is going on, but I'll keep digging.

pauldraper avatar Apr 26 '16 05:04 pauldraper

It was a bug with the APT S3 transport. I believe the transport is required to provide all the hashes that were in Packages (or maybe just SHA256 and SHA512...the documentation on the transport interface is very scarce).

The apt documentation says:

Clients may not use the MD5Sum and SHA1 fields for security purposes, and must require a SHA256 or a SHA512 field.

In any case, I authored https://github.com/lucidsoftware/apt-boto-s3, which works (and has several other IMO nice advantages).

pauldraper avatar Apr 26 '16 15:04 pauldraper

So most probably addition of SHA512 hashes between 0.9.6 and 0.9.7 is breaking it. I was afraid that is was related to S3 SDK change which was done recently is well.

smira avatar Apr 26 '16 15:04 smira

@pauldraper nice job on putting apt-boto-s3 together! very clean solution. I can confirm that I only see the new SHA512 in Packages on aptly 0.9.7 and the SHA512s in Packages match the .debs ive uploaded.

@smira I'm currently installing apt-transport-s3 version 1.2.1-1 from the jessie unstable repo. It was supposed to support SHA-512 with this commit: https://github.com/BashtonLtd/apt-transport-s3/pull/14 which is included in 1.2.1-1. So maybe there is an issue with the apt-transport-s3 implementation like @pauldraper was hinting at?

l2ol33rt avatar Apr 26 '16 22:04 l2ol33rt

@l2ol33rt yep, it could be all around SHA512

I've added SHA512 initially to support per-hash Packages indexes (so that we can avoid "hash sum mismatch" errors when apt-get is pulling while repo is being updated).

smira avatar Apr 26 '16 22:04 smira