]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
add gzip test and todo
[apt.git] / apt-pkg / acquire-item.cc
index 31dc2073d591a558691b196b810db5462edd8b62..c75ef36a9b5d2340a9b8892174cfadc625040b39 100644 (file)
@@ -954,32 +954,16 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                         HashStringList const  &ExpectedHash, string comprExt)
    : pkgAcqBaseIndex(Owner, 0, NULL, ExpectedHash, NULL), RealURI(URI)
 {
-   if(comprExt.empty() == true)
-   {
-      // autoselect the compression method
-      std::vector<std::string> types = APT::Configuration::getCompressionTypes();
-      for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
-        comprExt.append(*t).append(" ");
-      if (comprExt.empty() == false)
-        comprExt.erase(comprExt.end()-1);
-   }
-   CompressionExtension = comprExt;
-
-   Init(URI, URIDesc, ShortDesc);
-}
-#if 0
-pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
-                        HashStringList const &ExpectedHash, 
-                         indexRecords *MetaIndexParser)
-   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser), 
-     RealURI(Target->URI)
-{
-   // autoselect the compression method
    AutoSelectCompression();
-   Init(Target->URI, Target->Description, Target->ShortDesc);
+   Init(URI, URIDesc, ShortDesc);
+
+   if(_config->FindB("Debug::Acquire::Transaction", false) == true)
+      std::clog << "New pkgIndex with TransactionID "
+                << TransactionID << std::endl;
 }
-#endif
                                                                        /*}}}*/
+// AcqIndex::AcqIndex - Constructor                                    /*{{{*/
+// ---------------------------------------------------------------------
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                          unsigned long TransactionID,
                          IndexTarget const *Target,
@@ -997,6 +981,8 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                 << TransactionID << std::endl;
 }
                                                                        /*}}}*/
+// AcqIndex::AutoSelectCompression - Select compression                        /*{{{*/
+// ---------------------------------------------------------------------
 void pkgAcqIndex::AutoSelectCompression()
 {
    std::vector<std::string> types = APT::Configuration::getCompressionTypes();
@@ -1024,7 +1010,6 @@ void pkgAcqIndex::Init(string const &URI, string const &URIDesc, string const &S
    DestFile += URItoFileName(URI);
 
    std::string const comprExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
-   std::string MetaKey;
    if (comprExt == "uncompressed")
    {
       Desc.URI = URI;
@@ -1193,6 +1178,20 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
         unlink(DestFile.c_str());
 #endif
       return;
+   } else {
+      // FIXME: use the same method to find 
+      // check the compressed hash too
+      if(MetaKey != "" && Hashes.size() > 0)
+      {
+         indexRecords::checkSum *Record = MetaIndexParser->Lookup(MetaKey);
+         if(Record && Record->Hashes.usable() && Hashes != Record->Hashes)
+         {
+            RenameOnError(HashSumMismatch);
+            printHashSumComparision(RealURI, Record->Hashes, Hashes);
+            Failed(Message, Cfg);
+            return;
+         }
+      }
    }
 
    Erase = false;
@@ -1846,24 +1845,19 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message)                      /*{{{*/
 // pkgAcqMetaIndex::Failed - no Release file present or no signature file present      /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgAcqMetaIndex::Failed(string /*Message*/,
+void pkgAcqMetaIndex::Failed(string Message,
                              pkgAcquire::MethodConfig * /*Cnf*/)
 {
-#if 0
    if (AuthPass == true)
    {
       // gpgv method failed, if we have a good signature 
-      string LastGoodSigFile = _config->FindDir("Dir::State::lists").append("partial/").append(URItoFileName(RealURI));
+      string LastGoodSigFile = _config->FindDir("Dir::State::lists");
+      LastGoodSigFile += URItoFileName(RealURI);
       if (DestFile != SigFile)
         LastGoodSigFile.append(".gpg");
-      LastGoodSigFile.append(".reverify");
 
       if(FileExists(LastGoodSigFile))
       {
-        string VerifiedSigFile = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
-        if (DestFile != SigFile)
-           VerifiedSigFile.append(".gpg");
-        Rename(LastGoodSigFile, VerifiedSigFile);
         Status = StatTransientNetworkError;
         _error->Warning(_("An error occurred during the signature "
                           "verification. The repository is not updated "
@@ -1878,6 +1872,7 @@ void pkgAcqMetaIndex::Failed(string /*Message*/,
         _error->Error(_("GPG error: %s: %s"),
                         Desc.Description.c_str(),
                         LookupTag(Message,"Message").c_str());
+         Status = StatError;
         return;
       } else {
         _error->Warning(_("GPG error: %s: %s"),
@@ -1887,7 +1882,7 @@ void pkgAcqMetaIndex::Failed(string /*Message*/,
       // gpgv method failed 
       ReportMirrorFailure("GPGFailure");
    }
-#endif
+
    /* Always move the meta index, even if gpgv failed. This ensures
     * that PackageFile objects are correctly filled in */
    if (FileExists(DestFile)) {
@@ -1902,9 +1897,9 @@ void pkgAcqMetaIndex::Failed(string /*Message*/,
                                       "Release");
         SigFile = FinalFile;
       }
-      Rename(DestFile,FinalFile);
-      chmod(FinalFile.c_str(),0644);
 
+      // Done, queue for rename on transaction finished
+      PartialFile = DestFile;
       DestFile = FinalFile;
    }