X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/4fc6b7570c3e97b65c118b58cdf6729fa94c9b03..f903069c139df58d1ba855f7cf02c4a2d4e51dc3:/apt-pkg/indexcopy.cc diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 461aa4217..ca5c42cb7 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -19,18 +19,19 @@ #include #include #include -#include +#include #include #include #include +#include #include -#include #include #include #include #include #include +#include #include "indexcopy.h" #include @@ -89,7 +90,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, off_t const FileSize = Pkg.Size(); pkgTagFile Parser(&Pkg); - if (_error->PendingError() == true) + if (Pkg.IsOpen() == false || Pkg.Failed()) return false; // Open the output file @@ -106,7 +107,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, } else { Target.Open(TargetF,FileFd::WriteAtomic); } - if (_error->PendingError() == true) + if (Target.IsOpen() == false || Target.Failed()) return false; // Setup the progress meter @@ -206,7 +207,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, FinalF += URItoFileName(S); if (rename(TargetF.c_str(),FinalF.c_str()) != 0) return _error->Errno("rename","Failed to rename"); - ChangeOwnerAndPermissionOfFile("CopyPackages", FinalF.c_str(), "root", "root", 0644); + ChangeOwnerAndPermissionOfFile("CopyPackages", FinalF.c_str(), "root", ROOT_GROUP, 0644); } /* Mangle the source to be in the proper notation with @@ -424,7 +425,6 @@ bool PackageCopy::GetFile(string &File,unsigned long long &Size) // PackageCopy::RewriteEntry - Rewrite the entry with a new filename /*{{{*/ bool PackageCopy::RewriteEntry(FileFd &Target,string const &File) { - string const Dir(File,0,File.rfind('/')); std::vector Changes; Changes.push_back(pkgTagSection::Tag::Rewrite("Filename", File)); @@ -477,9 +477,9 @@ bool SourceCopy::RewriteEntry(FileFd &Target, std::string const &File) } /*}}}*/ // SigVerify::Verify - Verify a files md5sum against its metaindex /*{{{*/ -bool SigVerify::Verify(string prefix, string file, indexRecords *MetaIndex) +bool SigVerify::Verify(string prefix, string file, metaIndex *MetaIndex) { - const indexRecords::checkSum *Record = MetaIndex->Lookup(file); + const metaIndex::checkSum *Record = MetaIndex->Lookup(file); bool const Debug = _config->FindB("Debug::aptcdrom",false); // we skip non-existing files in the verifcation of the Release file @@ -531,7 +531,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/ Rel.Open(prefix + file,FileFd::ReadOnly); if (CopyFile(Rel,Target) == false || Target.Close() == false) return _error->Error("Copying of '%s' for '%s' from '%s' failed", file.c_str(), CDName.c_str(), prefix.c_str()); - ChangeOwnerAndPermissionOfFile("CopyPackages", TargetF.c_str(), "root", "root", 0644); + ChangeOwnerAndPermissionOfFile("CopyPackages", TargetF.c_str(), "root", ROOT_GROUP, 0644); return true; } @@ -546,11 +546,11 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, // Read all Release files for (vector::iterator I = SigList.begin(); I != SigList.end(); ++I) - { + { if(Debug) cout << "Signature verify for: " << *I << endl; - indexRecords *MetaIndex = new indexRecords; + metaIndex *MetaIndex = new debReleaseIndex("","", {}); string prefix = *I; string const releasegpg = *I+"Release.gpg"; @@ -592,12 +592,13 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, } // Open the Release file and add it to the MetaIndex - if(!MetaIndex->Load(release)) + std::string ErrorText; + if(MetaIndex->Load(release, &ErrorText) == false) { - _error->Error("%s",MetaIndex->ErrorText.c_str()); + _error->Error("%s", ErrorText.c_str()); return false; } - + // go over the Indexfiles and see if they verify // if so, remove them from our copy of the lists vector keys = MetaIndex->MetaKeys(); @@ -682,7 +683,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ off_t const FileSize = Pkg.Size(); pkgTagFile Parser(&Pkg); - if (_error->PendingError() == true) + if (Pkg.IsOpen() == false || Pkg.Failed()) return false; // Open the output file @@ -699,7 +700,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ } else { Target.Open(TargetF,FileFd::WriteAtomic); } - if (_error->PendingError() == true) + if (Pkg.IsOpen() == false || Pkg.Failed()) return false; // Setup the progress meter @@ -737,7 +738,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ FinalF += URItoFileName(S); if (rename(TargetF.c_str(),FinalF.c_str()) != 0) return _error->Errno("rename","Failed to rename"); - ChangeOwnerAndPermissionOfFile("CopyTranslations", FinalF.c_str(), "root", "root", 0644); + ChangeOwnerAndPermissionOfFile("CopyTranslations", FinalF.c_str(), "root", ROOT_GROUP, 0644); } CurrentSize += FileSize; @@ -770,4 +771,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ } /*}}}*/ +IndexCopy::IndexCopy() : d(nullptr), Section(nullptr) {} APT_CONST IndexCopy::~IndexCopy() {} + +PackageCopy::PackageCopy() : IndexCopy(), d(NULL) {} +APT_CONST PackageCopy::~PackageCopy() {} +SourceCopy::SourceCopy() : IndexCopy(), d(NULL) {} +APT_CONST SourceCopy::~SourceCopy() {} +TranslationsCopy::TranslationsCopy() : d(nullptr), Section(nullptr) {} +APT_CONST TranslationsCopy::~TranslationsCopy() {} +SigVerify::SigVerify() : d(NULL) {} +APT_CONST SigVerify::~SigVerify() {}