X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/df01b0d0d741eae61657b28a5111f40f05c215fe..856d3b06a6eb6a7f455294c69fc13604e099fd56:/apt-pkg/indexcopy.cc

diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index c9dded134..53eb11172 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -275,7 +275,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
       _error->Warning("No valid records were found.");
 
    if (NotFound + WrongSize > 10)
-      _error->Warning("Alot of entries were discarded, something may be wrong.\n");
+      _error->Warning("A lot of entries were discarded, something may be wrong.\n");
    
 
    return true;
@@ -522,35 +522,37 @@ bool SigVerify::Verify(string prefix, string file, indexRecords *MetaIndex)
 {
    const indexRecords::checkSum *Record = MetaIndex->Lookup(file);
 
+   // we skip non-existing files in the verifcation to support a cdrom
+   // with no Packages file (just a Package.gz), see LP: #255545
+   // (non-existing files are not considered a error)
+   if(!FileExists(prefix+file))
+   {
+      _error->Warning(_("Skipping nonexistent file %s"), string(prefix+file).c_str());
+      return true;
+   }
+
    if (!Record) 
    {
-      _error->Warning("Can't find authentication record for: %s",file.c_str());
+      _error->Warning(_("Can't find authentication record for: %s"), file.c_str());
       return false;
    }
 
-   MD5Summation sum;
-   FileFd Fd(prefix+file, FileFd::ReadOnly);
-   sum.AddFD(Fd.Fd(), Fd.Size());
-   Fd.Close();
-   string MD5 = (string)sum.Result();
-   
-   if (Record->MD5Hash != MD5)
+   if (!Record->Hash.VerifyFile(prefix+file))
    {
-      _error->Warning("MD5 mismatch for: %s",file.c_str());
+      _error->Warning(_("Hash mismatch for: %s"),file.c_str());
       return false;
    }
 
    if(_config->FindB("Debug::aptcdrom",false)) 
    {
       cout << "File: " << prefix+file << endl;
-      cout << "Expected MD5sum: " << Record->MD5Hash << endl;
-      cout << "got: " << MD5 << endl << endl;
+      cout << "Expected Hash " << Record->Hash.toStr() << endl;
    }
 
    return true;
 }
-
-bool SigVerify::CopyMetaIndex(string CDROM, string CDName, 
+									/*}}}*/
+bool SigVerify::CopyMetaIndex(string CDROM, string CDName,		/*{{{*/
 			      string prefix, string file)
 {
       char S[400];
@@ -570,8 +572,8 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName,
    
       return true;
 }
-
-bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
+									/*}}}*/
+bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,	/*{{{*/
 			      vector<string> PkgList,vector<string> SrcList)
 {
    if (SigList.size() == 0)
@@ -590,7 +592,10 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 
       // a Release.gpg without a Release should never happen
       if(!FileExists(*I+"Release"))
+      {
+	 delete MetaIndex;
 	 continue;
+      }
 
 
       // verify the gpg signature of "Release"
@@ -646,7 +651,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
       // Open the Release file and add it to the MetaIndex
       if(!MetaIndex->Load(*I+"Release"))
       {
-	 _error->Error(MetaIndex->ErrorText.c_str());
+	 _error->Error("%s",MetaIndex->ErrorText.c_str());
 	 return false;
       }
       
@@ -658,6 +663,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 	 if(!Verify(prefix,*I, MetaIndex)) {
 	    // something went wrong, don't copy the Release.gpg
 	    // FIXME: delete any existing gpg file?
+	    _error->Discard();
 	    continue;	 
 	 }
       }
@@ -672,10 +678,9 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 
    return true;
 }
-
-
-bool TranslationsCopy::CopyTranslations(string CDROM,string Name,vector<string> &List,
-			     pkgCdromStatus *log)
+									/*}}}*/
+bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
+				vector<string> &List, pkgCdromStatus *log)
 {
    OpProgress *Progress = NULL;
    if (List.size() == 0)
@@ -842,8 +847,9 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,vector<string>
       _error->Warning("No valid records were found.");
 
    if (NotFound + WrongSize > 10)
-      _error->Warning("Alot of entries were discarded, something may be wrong.\n");
+      _error->Warning("A lot of entries were discarded, something may be wrong.\n");
    
 
    return true;
 }
+									/*}}}*/