summaryrefslogtreecommitdiff
path: root/ftparchive/writer.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-06-29 12:45:30 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-06-29 12:45:30 +0100
commit9abccf4a63b6c887b213678d940fe912233f04c3 (patch)
tree8a22c910a0c8258f29784614aca9c0ebd2cc32d6 /ftparchive/writer.cc
parentc56c4b82dd77258da5640bf9f63a8db10424b59a (diff)
parent627e99b0328e05b13600134655253d36575f314d (diff)
merge lp:~mvo/apt/abi-break
Diffstat (limited to 'ftparchive/writer.cc')
-rw-r--r--ftparchive/writer.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 9f12cbf3d..c43e8f4b4 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -20,7 +20,7 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
-#include <apt-pkg/sha256.h>
+#include <apt-pkg/sha2.h>
#include <apt-pkg/deblistparser.h>
#include <sys/types.h>
@@ -64,6 +64,7 @@ FTWScanner::FTWScanner(string const &Arch): Arch(Arch)
DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
+ DoSHA512 = _config->FindB("APT::FTPArchive::SHA512",true);
}
/*}}}*/
// FTWScanner::Scanner - FTW Scanner /*{{{*/
@@ -316,6 +317,7 @@ PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string c
DoMD5 = _config->FindB("APT::FTPArchive::Packages::MD5",DoMD5);
DoSHA1 = _config->FindB("APT::FTPArchive::Packages::SHA1",DoSHA1);
DoSHA256 = _config->FindB("APT::FTPArchive::Packages::SHA256",DoSHA256);
+ DoSHA256 = _config->FindB("APT::FTPArchive::Packages::SHA512",true);
DoAlwaysStat = _config->FindB("APT::FTPArchive::AlwaysStat", false);
DoContents = _config->FindB("APT::FTPArchive::Contents",true);
NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
@@ -370,7 +372,7 @@ bool FTWScanner::SetExts(string const &Vals)
bool PackagesWriter::DoPackage(string FileName)
{
// Pull all the data we need form the DB
- if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoAlwaysStat)
+ if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoSHA512, DoAlwaysStat)
== false)
{
return false;
@@ -446,6 +448,8 @@ bool PackagesWriter::DoPackage(string FileName)
SetTFRewriteData(Changes[End++], "SHA1", Db.SHA1Res.c_str());
if (DoSHA256 == true)
SetTFRewriteData(Changes[End++], "SHA256", Db.SHA256Res.c_str());
+ if (DoSHA512 == true)
+ SetTFRewriteData(Changes[End++], "SHA512", Db.SHA512Res.c_str());
SetTFRewriteData(Changes[End++], "Filename", NewFileName.c_str());
SetTFRewriteData(Changes[End++], "Priority", OverItem->Priority.c_str());
SetTFRewriteData(Changes[End++], "Status", 0);
@@ -623,6 +627,7 @@ bool SourcesWriter::DoPackage(string FileName)
MD5Summation MD5;
SHA1Summation SHA1;
SHA256Summation SHA256;
+ SHA256Summation SHA512;
if (DoMD5 == true)
MD5.Add((unsigned char *)Start,BlkEnd - Start);
@@ -630,6 +635,8 @@ bool SourcesWriter::DoPackage(string FileName)
SHA1.Add((unsigned char *)Start,BlkEnd - Start);
if (DoSHA256 == true)
SHA256.Add((unsigned char *)Start,BlkEnd - Start);
+ if (DoSHA512 == true)
+ SHA512.Add((unsigned char *)Start,BlkEnd - Start);
// Add an extra \n to the end, just in case
*BlkEnd++ = '\n';
@@ -740,6 +747,12 @@ bool SourcesWriter::DoPackage(string FileName)
<< strippedName << "\n " << Tags.FindS("Checksums-Sha256");
string const ChecksumsSha256 = ostreamSha256.str();
+ std::ostringstream ostreamSha512;
+ if (Tags.Exists("Checksums-Sha512"))
+ ostreamSha512 << "\n " << string(SHA512.Result()) << " " << St.st_size << " "
+ << strippedName << "\n " << Tags.FindS("Checksums-Sha512");
+ string const ChecksumsSha512 = ostreamSha512.str();
+
// Strip the DirStrip prefix from the FileName and add the PathPrefix
string NewFileName;
if (DirStrip.empty() == false &&
@@ -795,6 +808,8 @@ bool SourcesWriter::DoPackage(string FileName)
SetTFRewriteData(Changes[End++],"Checksums-Sha1",ChecksumsSha1.c_str());
if (ChecksumsSha256.empty() == false)
SetTFRewriteData(Changes[End++],"Checksums-Sha256",ChecksumsSha256.c_str());
+ if (ChecksumsSha512.empty() == false)
+ SetTFRewriteData(Changes[End++],"Checksums-Sha512",ChecksumsSha512.c_str());
if (Directory != "./")
SetTFRewriteData(Changes[End++],"Directory",Directory.c_str());
SetTFRewriteData(Changes[End++],"Priority",BestPrio.c_str());
@@ -1046,6 +1061,12 @@ bool ReleaseWriter::DoPackage(string FileName)
CheckSums[NewFileName].SHA256 = SHA256.Result();
}
+ if (DoSHA512 == true)
+ {
+ SHA512Summation SHA512;
+ SHA512.AddFD(fd.Fd(), fd.Size());
+ CheckSums[NewFileName].SHA512 = SHA512.Result();
+ }
fd.Close();
return true;
@@ -1092,4 +1113,16 @@ void ReleaseWriter::Finish()
(*I).first.c_str());
}
}
+
+ fprintf(Output, "SHA512:\n");
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
+ I != CheckSums.end();
+ ++I)
+ {
+ fprintf(Output, " %s %32ld %s\n",
+ (*I).second.SHA512.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
+
}