From 9a961efc5cedeb2b7439114df18e8d0201c83fcf Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 22 Feb 2011 22:06:31 +0100 Subject: add sha512 support to apt-ftparchive --- ftparchive/writer.cc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 9cdca8d3e..e7eff2045 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -311,6 +312,7 @@ PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string c DoMD5 = _config->FindB("APT::FTPArchive::MD5",true); DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true); DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true); + DoSHA256 = _config->FindB("APT::FTPArchive::SHA512",true); DoAlwaysStat = _config->FindB("APT::FTPArchive::AlwaysStat", false); DoContents = _config->FindB("APT::FTPArchive::Contents",true); NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false); @@ -365,7 +367,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; @@ -438,6 +440,7 @@ bool PackagesWriter::DoPackage(string FileName) SetTFRewriteData(Changes[End++], "MD5sum", Db.MD5Res.c_str()); SetTFRewriteData(Changes[End++], "SHA1", Db.SHA1Res.c_str()); SetTFRewriteData(Changes[End++], "SHA256", Db.SHA256Res.c_str()); + 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); @@ -613,8 +616,10 @@ bool SourcesWriter::DoPackage(string FileName) SHA1Summation SHA1; SHA256Summation SHA256; + SHA512Summation SHA512; SHA1.Add((unsigned char *)Start,BlkEnd - Start); SHA256.Add((unsigned char *)Start,BlkEnd - Start); + SHA512.Add((unsigned char *)Start,BlkEnd - Start); // Add an extra \n to the end, just in case *BlkEnd++ = '\n'; @@ -725,6 +730,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 && @@ -777,6 +788,7 @@ bool SourcesWriter::DoPackage(string FileName) SetTFRewriteData(Changes[End++],"Files",Files.c_str()); SetTFRewriteData(Changes[End++],"Checksums-Sha1",ChecksumsSha1.c_str()); SetTFRewriteData(Changes[End++],"Checksums-Sha256",ChecksumsSha256.c_str()); + SetTFRewriteData(Changes[End++],"Checksums-Sha512",ChecksumsSha512.c_str()); if (Directory != "./") SetTFRewriteData(Changes[End++],"Directory",Directory.c_str()); SetTFRewriteData(Changes[End++],"Priority",BestPrio.c_str()); @@ -1010,6 +1022,10 @@ bool ReleaseWriter::DoPackage(string FileName) SHA256.AddFD(fd.Fd(), fd.Size()); CheckSums[NewFileName].SHA256 = SHA256.Result(); + SHA256Summation SHA512; + SHA256.AddFD(fd.Fd(), fd.Size()); + CheckSums[NewFileName].SHA512 = SHA512.Result(); + fd.Close(); return true; @@ -1052,5 +1068,17 @@ void ReleaseWriter::Finish() (*I).second.size, (*I).first.c_str()); } + + fprintf(Output, "SHA512:\n"); + for(map::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()); + } + } -- cgit v1.2.3 From 84a0890e6ef49b5d41a0b9ff0b5a5fe95cca6f3e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Feb 2011 14:16:35 +0100 Subject: move sha512,256 into apt-pkg/sha2.{cc,h}, move gifford implementation to sha2_internal.{cc,h} --- ftparchive/writer.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index e7eff2045..98ab852ea 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -19,8 +19,7 @@ #include #include #include -#include -#include +#include #include #include -- cgit v1.2.3 From 8c4e1f97686c412f88bb57827a84b776626d9980 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Jul 2011 23:23:04 +0200 Subject: * ftparchive/writer.cc: - generate all checksums in one run over the file for Release --- ftparchive/writer.cc | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index c43e8f4b4..60db8b990 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -19,8 +19,7 @@ #include #include #include -#include -#include +#include #include #include @@ -1040,35 +1039,18 @@ bool ReleaseWriter::DoPackage(string FileName) CheckSums[NewFileName].size = fd.Size(); + Hashes hs; + hs.AddFD(fd.Fd(), 0, DoMD5, DoSHA1, DoSHA256, DoSHA512); if (DoMD5 == true) - { - MD5Summation MD5; - MD5.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].MD5 = MD5.Result(); - fd.Seek(0); - } + CheckSums[NewFileName].MD5 = hs.MD5.Result(); if (DoSHA1 == true) - { - SHA1Summation SHA1; - SHA1.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].SHA1 = SHA1.Result(); - fd.Seek(0); - } + CheckSums[NewFileName].SHA1 = hs.SHA1.Result(); if (DoSHA256 == true) - { - SHA256Summation SHA256; - SHA256.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].SHA256 = SHA256.Result(); - } - + CheckSums[NewFileName].SHA256 = hs.SHA256.Result(); if (DoSHA512 == true) - { - SHA512Summation SHA512; - SHA512.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].SHA512 = SHA512.Result(); - } + CheckSums[NewFileName].SHA512 = hs.SHA512.Result(); fd.Close(); - + return true; } -- cgit v1.2.3 From ea54214002c09eeb4dd498d97a564471ec9993c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 10:09:00 +0200 Subject: reorder includes: add if needed and include it at first --- ftparchive/writer.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 60db8b990..65269c6ae 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -11,9 +11,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "writer.h" - -#include +#include + #include #include #include @@ -30,10 +29,13 @@ #include #include #include - + +#include "writer.h" #include "cachedb.h" #include "apt-ftparchive.h" #include "multicompress.h" + +#include /*}}}*/ using namespace std; FTWScanner *FTWScanner::Owner; -- cgit v1.2.3 From 650faab01603caac04494d54cf6b10a65c00ea13 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 17:46:48 +0200 Subject: Support large files in the complete toolset. Indexes of this size are pretty unlikely for now, but we need it for deb packages which could become bigger than 4GB now (LP: #815895) --- ftparchive/writer.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 65269c6ae..c4e700b59 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -248,8 +248,8 @@ bool FTWScanner::LoadFileList(string const &Dir, string const &File) // --------------------------------------------------------------------- /* */ bool FTWScanner::Delink(string &FileName,const char *OriginalPath, - unsigned long &DeLinkBytes, - off_t const &FileSize) + unsigned long long &DeLinkBytes, + unsigned long long const &FileSize) { // See if this isn't an internaly prefix'd file name. if (InternalPrefix.empty() == false && @@ -379,7 +379,7 @@ bool PackagesWriter::DoPackage(string FileName) return false; } - off_t FileSize = Db.GetFileSize(); + unsigned long long FileSize = Db.GetFileSize(); if (Delink(FileName,OriginalPath,Stats.DeLinkBytes,FileSize) == false) return false; @@ -415,7 +415,7 @@ bool PackagesWriter::DoPackage(string FileName) } char Size[40]; - sprintf(Size,"%lu", (unsigned long) FileSize); + sprintf(Size,"%llu", (unsigned long long) FileSize); // Strip the DirStrip prefix from the FileName and add the PathPrefix string NewFileName; @@ -612,7 +612,7 @@ bool SourcesWriter::DoPackage(string FileName) if (St.st_size > 128*1024) return _error->Error("DSC file '%s' is too large!",FileName.c_str()); - if (BufSize < (unsigned)St.st_size+1) + if (BufSize < (unsigned long long)St.st_size+1) { BufSize = St.st_size+1; Buffer = (char *)realloc(Buffer,St.st_size+1); @@ -1067,7 +1067,7 @@ void ReleaseWriter::Finish() for(map::const_iterator I = CheckSums.begin(); I != CheckSums.end(); ++I) { - fprintf(Output, " %s %16ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.MD5.c_str(), (*I).second.size, (*I).first.c_str()); @@ -1079,7 +1079,7 @@ void ReleaseWriter::Finish() for(map::const_iterator I = CheckSums.begin(); I != CheckSums.end(); ++I) { - fprintf(Output, " %s %16ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.SHA1.c_str(), (*I).second.size, (*I).first.c_str()); @@ -1091,7 +1091,7 @@ void ReleaseWriter::Finish() for(map::const_iterator I = CheckSums.begin(); I != CheckSums.end(); ++I) { - fprintf(Output, " %s %16ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.SHA256.c_str(), (*I).second.size, (*I).first.c_str()); @@ -1103,7 +1103,7 @@ void ReleaseWriter::Finish() I != CheckSums.end(); ++I) { - fprintf(Output, " %s %32ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.SHA512.c_str(), (*I).second.size, (*I).first.c_str()); -- cgit v1.2.3 From 12d1f5b3e295c589371bf7de27b7918310d08480 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 14 Dec 2011 22:35:03 +0100 Subject: remove the second usage instance of ExecCompressor in ftparchive by again using the FileFd directly --- ftparchive/writer.cc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 27e53faf8..02777713c 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -889,22 +889,16 @@ bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompres MultiCompress Pkgs(PkgFile,PkgCompress,0,false); if (_error->PendingError() == true) return false; - + // Open the package file - int CompFd = -1; - pid_t Proc = -1; - if (Pkgs.OpenOld(CompFd,Proc) == false) + FileFd Fd; + if (Pkgs.OpenOld(Fd) == false) return false; - - // No auto-close FD - FileFd Fd(CompFd,false); + pkgTagFile Tags(&Fd); if (_error->PendingError() == true) - { - Pkgs.CloseOld(CompFd,Proc); return false; - } - + // Parse. pkgTagSection Section; while (Tags.Step(Section) == true) @@ -926,11 +920,10 @@ bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompres _error->DumpErrors(); } } - + // Tidy the compressor - if (Pkgs.CloseOld(CompFd,Proc) == false) - return false; - + Fd.Close(); + return true; } -- cgit v1.2.3 From 109eb1511d0cdfa4af3196105cada30bcbb77bc8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 17 Dec 2011 23:53:31 +0100 Subject: try to avoid direct usage of .Fd() if possible and do read()s and co on the FileFd instead --- ftparchive/writer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 02777713c..159772991 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -1035,7 +1035,7 @@ bool ReleaseWriter::DoPackage(string FileName) CheckSums[NewFileName].size = fd.Size(); Hashes hs; - hs.AddFD(fd.Fd(), 0, DoMD5, DoSHA1, DoSHA256, DoSHA512); + hs.AddFD(fd, 0, DoMD5, DoSHA1, DoSHA256, DoSHA512); if (DoMD5 == true) CheckSums[NewFileName].MD5 = hs.MD5.Result(); if (DoSHA1 == true) -- cgit v1.2.3 From 8e3900d0d7efc11d538b944ed1d9e4e3d5286ff6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 18 Feb 2012 19:40:13 +0100 Subject: * apt-pkg/acquire-item.cc: - drop support for i18n/Index file (introduced in 0.8.11) and use the Release file instead to get the Translations (Closes: #649314) * ftparchive/writer.cc: - add 'Translation-*' to the default patterns i18n/Index was never used outside debian - and even here it isn't used consistently as only 'main' has such a file. As the Release file now includes the Translation-* files we therefore drop support for i18n/Index. A version supporting it was never part of a debian release and still supporting it would mean that we get 99% of the time a 404 as response to the request anyway and confuse archive maintainers who want to provide all files APT tries to acquire. --- ftparchive/writer.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'ftparchive/writer.cc') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 159772991..d02919969 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -941,6 +941,7 @@ ReleaseWriter::ReleaseWriter(string const &DB) AddPattern("Packages.bz2"); AddPattern("Packages.lzma"); AddPattern("Packages.xz"); + AddPattern("Translation-*"); AddPattern("Sources"); AddPattern("Sources.gz"); AddPattern("Sources.bz2"); -- cgit v1.2.3