summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 17:04:32 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 17:04:32 +0000
commitf7291f6215c1e52298d47438c297c3c319abca7e (patch)
treed65d7ac6acee7531ed7bdb7286fc3d46f1f881c3 /ftparchive
parentbbb55c6af6f691f2f4064ca472a40f8486ac8ca3 (diff)
Add SHA1 support to "apt-ftparchive release"
Author: mdz Date: 2003-12-26 20:50:01 GMT Add SHA1 support to "apt-ftparchive release"
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/apt-ftparchive.cc4
-rw-r--r--ftparchive/writer.cc44
-rw-r--r--ftparchive/writer.h19
3 files changed, 57 insertions, 10 deletions
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index c811343b6..02e98bae6 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-ftparchive.cc,v 1.9 2003/12/26 20:08:56 mdz Exp $
+// $Id: apt-ftparchive.cc,v 1.10 2003/12/26 20:50:01 mdz Exp $
/* ######################################################################
apt-scanpackages - Efficient work-alike for dpkg-scanpackages
@@ -684,6 +684,8 @@ bool SimpleGenRelease(CommandLine &CmdL)
if (Release.RecursiveScan(CmdL.FileList[1]) == false)
return false;
+ Release.Finish();
+
return true;
}
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 68fd85091..3b1cb69f5 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: writer.cc,v 1.8 2003/12/26 20:08:56 mdz Exp $
+// $Id: writer.cc,v 1.9 2003/12/26 20:50:01 mdz Exp $
/* ######################################################################
Writer
@@ -22,6 +22,7 @@
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
#include <apt-pkg/deblistparser.h>
#include <sys/types.h>
@@ -829,8 +830,6 @@ ReleaseWriter::ReleaseWriter(string DB)
fprintf(Output, "%s: %s\n", (*I).first.c_str(), Value.c_str());
}
-
- fprintf(Output, "MD5Sum:\n");
}
/*}}}*/
// ReleaseWriter::DoPackage - Process a single package /*{{{*/
@@ -856,14 +855,47 @@ bool ReleaseWriter::DoPackage(string FileName)
return false;
}
+ CheckSums[FileName].size = fd.Size();
+
MD5Summation MD5;
MD5.AddFD(fd.Fd(), fd.Size());
+ CheckSums[FileName].MD5 = MD5.Result();
- string MD5Sum = MD5.Result();
- fprintf(Output, " %s %16d %s\n",
- MD5Sum.c_str(), fd.Size(), FileName.c_str());
+ fd.Seek(0);
+ SHA1Summation SHA1;
+ SHA1.AddFD(fd.Fd(), fd.Size());
+ CheckSums[FileName].SHA1 = SHA1.Result();
fd.Close();
return true;
}
+
+ /*}}}*/
+// ReleaseWriter::Finish - Output the checksums /*{{{*/
+// ---------------------------------------------------------------------
+void ReleaseWriter::Finish()
+{
+ fprintf(Output, "MD5Sum:\n");
+ for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+ I != CheckSums.end();
+ ++I)
+ {
+ fprintf(Output, " %s %16ld %s\n",
+ (*I).second.MD5.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
+
+ fprintf(Output, "SHA1:\n");
+ for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+ I != CheckSums.end();
+ ++I)
+ {
+ fprintf(Output, " %s %16ld %s\n",
+ (*I).second.SHA1.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
+}
+
diff --git a/ftparchive/writer.h b/ftparchive/writer.h
index 6f728dd1b..f347ca3b3 100644
--- a/ftparchive/writer.h
+++ b/ftparchive/writer.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: writer.h,v 1.5 2003/12/26 20:08:56 mdz Exp $
+// $Id: writer.h,v 1.6 2003/12/26 20:50:01 mdz Exp $
/* ######################################################################
Writer
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <iostream>
#include <vector>
+#include <map>
#include "cachedb.h"
#include "override.h"
@@ -30,6 +31,7 @@ using std::string;
using std::cout;
using std::endl;
using std::vector;
+using std::map;
class FTWScanner
{
@@ -154,11 +156,22 @@ class ReleaseWriter : public FTWScanner
public:
ReleaseWriter(string DB);
virtual bool DoPackage(string FileName);
-protected:
+ void Finish();
+
+ FILE *Output;
// General options
string PathPrefix;
string DirStrip;
- FILE *Output;
+
+protected:
+ struct CheckSum
+ {
+ string MD5;
+ string SHA1;
+ // Limited by FileFd::Size()
+ unsigned long size;
+ };
+ map<string,struct CheckSum> CheckSums;
};
#endif