[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#436055: apt: Add hash support to copy: method, so apt-get source works



Package: apt
Version: 0.7.6
Severity: normal
Tags: patch

Running apt-get source from a repository with the copy: method fails
with the error "Hash Sum mismatch".  Attached is a five-line patch to
add hash support to the copy: method, which makes it work.  (The patch
is against apt-0.7.6ubuntu1, but I'm assuming this code hasn't been
touched by anyone at Debian or Ubuntu recently.)

Example of problem:

deb-src copy:/afs/sipb.mit.edu/project/debathena/apt-new feisty debathena debathena-manual-config debathena-config

$ apt-get source debathena-discuss
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 200kB of source archives.
Get:1 copy: feisty/debathena debathena-discuss 9.4.30-0debathena3 (dsc) [659B]
Get:2 copy: feisty/debathena debathena-discuss 9.4.30-0debathena3 (tar) [195kB]
Get:3 copy: feisty/debathena debathena-discuss 9.4.30-0debathena3 (diff) [5131B]
Fetched 200kB in 0s (0B/s)         
Failed to fetch copy:/afs/sipb.mit.edu/project/debathena/apt-new/pool/debathena/d/debathena-discuss/debathena-discuss_9.4.30-0debathena3.dsc  Hash Sum mismatch
Failed to fetch copy:/afs/sipb.mit.edu/project/debathena/apt-new/pool/debathena/d/debathena-discuss/debathena-discuss_9.4.30.orig.tar.gz  Hash Sum mismatch
Failed to fetch copy:/afs/sipb.mit.edu/project/debathena/apt-new/pool/debathena/d/debathena-discuss/debathena-discuss_9.4.30-0debathena3.diff.gz  Hash Sum mismatch
E: Failed to fetch some archives.

diff -ur apt-0.7.6ubuntu1/methods/copy.cc apt-0.7.6ubuntu1andersk1/methods/copy.cc
--- apt-0.7.6ubuntu1/methods/copy.cc	2006-12-13 13:28:57.000000000 -0500
+++ apt-0.7.6ubuntu1andersk1/methods/copy.cc	2007-08-04 19:45:13.000000000 -0400
@@ -12,6 +12,7 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/hashes.h>
 
 #include <sys/stat.h>
 #include <utime.h>
@@ -79,6 +80,10 @@
       return _error->Errno("utime",_("Failed to set modification time"));
    }
    
+   Hashes Hash;
+   FileFd Fd(Res.Filename, FileFd::ReadOnly);
+   Hash.AddFD(Fd.Fd(), Fd.Size());
+   Res.TakeHashes(Hash);
    URIDone(Res);
    return true;
 }

Reply to: