]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
add missing TransactionStageCopy() in pkgAcqDiffIndex::Done()
[apt.git] / apt-pkg / acquire-item.cc
index 54e99345865587a1fe725c4fb21bf244c59b8a52..975965e46d01048a1e08db427d6d053450c4115e 100644 (file)
@@ -212,6 +212,19 @@ bool pkgAcquire::Item::RenameOnError(pkgAcquire::Item::RenameOnErrorState const
    return false;
 }
                                                                        /*}}}*/
+void pkgAcquire::Item::SetActiveSubprocess(const std::string &subprocess)
+{
+      ActiveSubprocess = subprocess;
+#if __GNUC__ >= 4
+       #pragma GCC diagnostic push
+       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+        Mode = ActiveSubprocess.c_str();
+#if __GNUC__ >= 4
+       #pragma GCC diagnostic pop
+#endif
+}
+
 // Acquire::Item::ReportMirrorFailure                                  /*{{{*/
 // ---------------------------------------------------------------------
 void pkgAcquire::Item::ReportMirrorFailure(string FailCode)
@@ -269,12 +282,12 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
                                 HashStringList const &ExpectedHashes,
                                  indexRecords *MetaIndexParser)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHashes, 
-                     MetaIndexParser, Target->URI), 
-     PackagesFileReadyInPartial(false)
+                     MetaIndexParser), PackagesFileReadyInPartial(false)
 {
    
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
+   RealURI = Target->URI;
    Desc.Owner = this;
    Desc.Description = Target->Description + "/DiffIndex";
    Desc.ShortDesc = Target->ShortDesc;
@@ -542,21 +555,14 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,HashStringList
 
    }
 
+   if(!ParseDiffIndex(DestFile))
+      return Failed("", NULL);
+
+   // queue for final move
    string FinalFile;
    FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(RealURI);
-
-   // success in downloading the index
-   // rename the index
    FinalFile += string(".IndexDiff");
-   if(Debug)
-      std::clog << "Renaming: " << DestFile << " -> " << FinalFile 
-               << std::endl;
-   Rename(DestFile,FinalFile);
-   chmod(FinalFile.c_str(),0644);
-   DestFile = FinalFile;
-
-   if(!ParseDiffIndex(DestFile))
-      return Failed("", NULL);
+   TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
 
    Complete = true;
    Status = StatDone;
@@ -576,8 +582,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
                                    indexRecords *MetaIndexParser,
                                   string ServerSha1,
                                   vector<DiffInfo> diffs)
-   : pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHashes, 
-                     MetaIndexParser, Target->URI),
+   : pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHashes, MetaIndexParser),
      available_patches(diffs), ServerSha1(ServerSha1)
 {
    
@@ -586,6 +591,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
 
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
+   RealURI = Target->URI;
    Desc.Owner = this;
    Description = Target->Description;
    Desc.ShortDesc = Target->ShortDesc;
@@ -749,15 +755,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size, HashStringLi
       Local = true;
       Desc.URI = "rred:" + FinalFile;
       QueueURI(Desc);
-      ActiveSubprocess = "rred";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-      Mode = "rred";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+      SetActiveSubprocess("rred");
       return;
    } 
 
@@ -799,8 +797,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
                                              indexRecords *MetaIndexParser,
                                              DiffInfo const &patch,
                                              std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
-  : pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHashes, 
-                    MetaIndexParser, Target->URI),
+  : pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHashes, MetaIndexParser),
      patch(patch), allPatches(allPatches), State(StateFetchDiff)
 {
 
@@ -809,6 +806,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
 
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
+   RealURI = Target->URI;
    Desc.Owner = this;
    Description = Target->Description;
    Desc.ShortDesc = Target->ShortDesc;
@@ -882,15 +880,7 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStri
       Local = true;
       Desc.URI = "rred:" + FinalFile;
       QueueURI(Desc);
-      ActiveSubprocess = "rred";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-      Mode = "rred";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+      SetActiveSubprocess("rred");
       return;
    }
    // success in download/apply all diffs, clean up
@@ -957,8 +947,10 @@ bool pkgAcqBaseIndex::VerifyHashByMetaKey(HashStringList const &Hashes)
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                         string URI,string URIDesc,string ShortDesc,
                         HashStringList const  &ExpectedHash)
-   : pkgAcqBaseIndex(Owner, 0, NULL, ExpectedHash, NULL, RealURI)
+   : pkgAcqBaseIndex(Owner, 0, NULL, ExpectedHash, NULL)
 {
+   RealURI = URI;
+
    AutoSelectCompression();
    Init(URI, URIDesc, ShortDesc);
 
@@ -975,8 +967,10 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                         HashStringList const &ExpectedHash, 
                          indexRecords *MetaIndexParser)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHash, 
-                     MetaIndexParser, Target->URI)
+                     MetaIndexParser)
 {
+   RealURI = Target->URI;
+
    // autoselect the compression method
    AutoSelectCompression();
    Init(Target->URI, Target->Description, Target->ShortDesc);
@@ -1237,15 +1231,7 @@ void pkgAcqIndex::StageDownloadDone(string Message,
       DestFile += ".decomp";
       Desc.URI = "copy:" + FileName;
       QueueURI(Desc);
-      ActiveSubprocess = "copy";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-      Mode = "copy";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+      SetActiveSubprocess("copy");
       return;
    }
 
@@ -1309,15 +1295,7 @@ void pkgAcqIndex::StageDownloadDone(string Message,
    Desc.URI = decompProg + ":" + FileName;
    QueueURI(Desc);
 
-   ActiveSubprocess = decompProg;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-      Mode = ActiveSubprocess.c_str();
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+   SetActiveSubprocess(decompProg);
 }
                                                                         /*}}}*/
 // pkgAcqIndex::StageDecompressDone - Final verification               /*{{{*/
@@ -1413,12 +1391,17 @@ void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    Item::Failed(Message,Cnf);
 }
                                                                        /*}}}*/
-
+// AcqMetaBase::Add - Add a item to the current Transaction            /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 void pkgAcqMetaBase::Add(Item *I)
 {
    Transaction.push_back(I);
 }
-
+                                                                       /*}}}*/
+// AcqMetaBase::AbortTransaction - Abort the current Transaction       /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 void pkgAcqMetaBase::AbortTransaction()
 {
    if(_config->FindB("Debug::Acquire::Transaction", false) == true)
@@ -1443,6 +1426,9 @@ void pkgAcqMetaBase::AbortTransaction()
    }
 }
                                                                        /*}}}*/
+// AcqMetaBase::TransactionHasError - Check for errors in Transaction          /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 bool pkgAcqMetaBase::TransactionHasError()
 {
    for (pkgAcquire::ItemIterator I = Transaction.begin();
@@ -1453,7 +1439,10 @@ bool pkgAcqMetaBase::TransactionHasError()
 
    return false;
 }
-// Acquire::CommitTransaction - Commit a transaction                   /*{{{*/
+                                                                       /*}}}*/
+// AcqMetaBase::CommitTransaction - Commit a transaction               /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 void pkgAcqMetaBase::CommitTransaction()
 {
    if(_config->FindB("Debug::Acquire::Transaction", false) == true)
@@ -1487,7 +1476,10 @@ void pkgAcqMetaBase::CommitTransaction()
       (*I)->TransactionManager = 0;
    }
 }
-
+                                                                       /*}}}*/
+// AcqMetaBase::TransactionStageCopy - Stage a file for copying                /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 void pkgAcqMetaBase::TransactionStageCopy(Item *I,
                                           const std::string &From,
                                           const std::string &To)
@@ -1495,16 +1487,21 @@ void pkgAcqMetaBase::TransactionStageCopy(Item *I,
    I->PartialFile = From;
    I->DestFile = To;
 }
-
+                                                                       /*}}}*/
+// AcqMetaBase::TransactionStageRemoval - Sage a file for removal      /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 void pkgAcqMetaBase::TransactionStageRemoval(Item *I,
                                              const std::string &FinalFile)
 {
    I->PartialFile = "";
    I->DestFile = FinalFile; 
 }
-
-
+                                                                       /*}}}*/
                                                                        /*{{{*/
+// AcqMetaBase::GenerateAuthWarning - Check gpg authentication error   /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 bool pkgAcqMetaBase::GenerateAuthWarning(const std::string &RealURI,
                                          const std::string &Message)
 {
@@ -1538,9 +1535,10 @@ bool pkgAcqMetaBase::GenerateAuthWarning(const std::string &RealURI,
    return false;
 }
                                                                        /*}}}*/
-
-
-pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,                        /*{{{*/
+// AcqMetaSig::AcqMetaSig - Constructor                                /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
                              pkgAcqMetaBase *TransactionManager,
                             string URI,string URIDesc,string ShortDesc,
                              string MetaIndexFile,
@@ -1552,7 +1550,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,                   /*{{{*/
    ShortDesc(ShortDesc)
 {
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
-   DestFile += URItoFileName(URI);
+   DestFile += URItoFileName(RealURI);
 
    // remove any partial downloaded sig-file in partial/. 
    // it may confuse proxies and is too small to warrant a 
@@ -1591,74 +1589,37 @@ string pkgAcqMetaSig::Custom600Headers() const
 
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
-
-void pkgAcqMetaSig::Done(string Message,unsigned long long Size, HashStringList const &Hashes,
+                                                                       /*}}}*/
+// pkgAcqMetaSig::Done - The signature was downloaded/verified         /*{{{*/
+// ---------------------------------------------------------------------
+/* The only header we use is the last-modified header. */
+void pkgAcqMetaSig::Done(string Message,unsigned long long Size,
+                         HashStringList const &Hashes,
                         pkgAcquire::MethodConfig *Cfg)
 {
    Item::Done(Message, Size, Hashes, Cfg);
 
-   string FileName = LookupTag(Message,"Filename");
-   if (FileName.empty() == true)
-   {
-      Status = StatError;
-      ErrorText = "Method gave a blank filename";
-      return;
-   }
-
-   if (FileName != DestFile)
-   {
-      // We have to copy it into place
-      Local = true;
-      Desc.URI = "copy:" + FileName;
-      QueueURI(Desc);
-      return;
-   }
-
-   if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
-      IMSHit = true;
-
-   // adjust paths if its a ims-hit
-   if(IMSHit)
-   {
-      string FinalFile = _config->FindDir("Dir::State::lists");
-      FinalFile += URItoFileName(RealURI);
-         
-      TransactionManager->TransactionStageCopy(this, FinalFile, FinalFile);
-   }
-
-   // queue for verify
    if(AuthPass == false)
    {
-      AuthPass = true;
-      Desc.URI = "gpgv:" + DestFile;
-      DestFile = MetaIndexFile;
-      QueueURI(Desc);
+      if(CheckDownloadDone(Message, RealURI) == true)
+      {
+         // destfile will be modified to point to MetaIndexFile for the
+         // gpgv method, so we need to save it here
+         MetaIndexFileSignature = DestFile;
+         QueueForSignatureVerify(MetaIndexFile, MetaIndexFileSignature);
+      }
       return;
    }
-
-   // queue to copy the file in place if it was not a ims hit, on ims
-   // hit the file is already at the right place
-   if(IMSHit == false)
+   else 
    {
-      PartialFile = _config->FindDir("Dir::State::lists") + "partial/";
-      PartialFile += URItoFileName(RealURI);
-      
-      std::string FinalFile = _config->FindDir("Dir::State::lists");
-      FinalFile += URItoFileName(RealURI);
-
-      TransactionManager->TransactionStageCopy(this, PartialFile, FinalFile);
-   }
+      if(AuthDone(Message, RealURI) == true)
+      {
+         std::string FinalFile = _config->FindDir("Dir::State::lists");
+         FinalFile += URItoFileName(RealURI);
 
-   // we parse the MetaIndexFile here because at this point we can
-   // trust the data
-   if(AuthPass == true)
-   {
-      // load indexes and queue further downloads
-      MetaIndexParser->Load(MetaIndexFile);
-      QueueIndexes(true);
+         TransactionManager->TransactionStageCopy(this, MetaIndexFileSignature, FinalFile);
+      }
    }
-
-   Complete = true;
 }
                                                                        /*}}}*/
 void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
@@ -1790,65 +1751,78 @@ string pkgAcqMetaIndex::Custom600Headers() const
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
                                                                        /*}}}*/
-void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,HashStringList const &Hashes,        /*{{{*/
+void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,     /*{{{*/
+                           HashStringList const &Hashes,
                           pkgAcquire::MethodConfig *Cfg)
 {
    Item::Done(Message,Size,Hashes,Cfg);
 
-   // MetaIndexes are done in two passes: one to download the
-   // metaindex with an appropriate method, and a second to verify it
-   // with the gpgv method
-
-   if (AuthPass == true)
+   if(CheckDownloadDone(Message, RealURI))
    {
-      AuthDone(Message);
+      // we have a Release file, now download the Signature, all further
+      // verify/queue for additional downloads will be done in the
+      // pkgAcqMetaSig::Done() code
+      std::string MetaIndexFile = DestFile;
+      new pkgAcqMetaSig(Owner, TransactionManager, 
+                        MetaIndexSigURI, MetaIndexSigURIDesc,
+                        MetaIndexSigShortDesc, MetaIndexFile, IndexTargets, 
+                        MetaIndexParser);
 
-      // all cool, move Release file into place
-      Complete = true;
+      string FinalFile = _config->FindDir("Dir::State::lists");
+      FinalFile += URItoFileName(RealURI);
+      TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
    }
-   else
-   {
-      RetrievalDone(Message);
-      if (!Complete)
-         // Still more retrieving to do
-         return;
+}
+                                                                       /*}}}*/
+bool pkgAcqMetaBase::AuthDone(string Message, const string &RealURI)   /*{{{*/
+{
+   // At this point, the gpgv method has succeeded, so there is a
+   // valid signature from a key in the trusted keyring.  We
+   // perform additional verification of its contents, and use them
+   // to verify the indexes we are about to download
 
-      if (SigFile != "")
-      {
-         // There was a signature file, so pass it to gpgv for
-         // verification
-         if (_config->FindB("Debug::pkgAcquire::Auth", false))
-            std::cerr << "Metaindex acquired, queueing gpg verification ("
-                      << SigFile << "," << DestFile << ")\n";
-         AuthPass = true;
-         Desc.URI = "gpgv:" + SigFile;
-         QueueURI(Desc);
-        ActiveSubprocess = "gpgv";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-        Mode = "gpgv";
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
-        return;
-      }
+   if (!MetaIndexParser->Load(DestFile))
+   {
+      Status = StatAuthError;
+      ErrorText = MetaIndexParser->ErrorText;
+      return false;
    }
 
-   if (Complete == true)
+   if (!VerifyVendor(Message, RealURI))
    {
-      string FinalFile = _config->FindDir("Dir::State::lists");
-      FinalFile += URItoFileName(RealURI);
-      if (SigFile == DestFile)
-        SigFile = FinalFile;
-
-      // queue for copy in place
-      TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
+      return false;
    }
+
+   if (_config->FindB("Debug::pkgAcquire::Auth", false))
+      std::cerr << "Signature verification succeeded: "
+                << DestFile << std::endl;
+
+   // Download further indexes with verification 
+   //
+   // it would be really nice if we could simply do
+   //    if (IMSHit == false) QueueIndexes(true)
+   // and skip the download if the Release file has not changed
+   // - but right now the list cleaner will needs to be tricked
+   //   to not delete all our packages/source indexes in this case
+   QueueIndexes(true);
+
+   return true;
+}
+                                                                       /*}}}*/
+                                                                       /*{{{*/
+void pkgAcqMetaBase::QueueForSignatureVerify(const std::string &MetaIndexFile,
+                                    const std::string &MetaIndexFileSignature)
+{
+   AuthPass = true;
+   Desc.URI = "gpgv:" + MetaIndexFileSignature;
+   DestFile = MetaIndexFile;
+   QueueURI(Desc);
+   SetActiveSubprocess("gpgv");
 }
                                                                        /*}}}*/
-void pkgAcqMetaIndex::RetrievalDone(string Message)                    /*{{{*/
+                                                                       /*{{{*/
+bool pkgAcqMetaBase::CheckDownloadDone(const std::string &Message,
+                                       const std::string &RealURI)
 {
    // We have just finished downloading a Release file (it is not
    // verified yet)
@@ -1858,7 +1832,7 @@ void pkgAcqMetaIndex::RetrievalDone(string Message)                       /*{{{*/
    {
       Status = StatError;
       ErrorText = "Method gave a blank filename";
-      return;
+      return false;
    }
 
    if (FileName != DestFile)
@@ -1866,7 +1840,7 @@ void pkgAcqMetaIndex::RetrievalDone(string Message)                       /*{{{*/
       Local = true;
       Desc.URI = "copy:" + FileName;
       QueueURI(Desc);
-      return;
+      return false;
    }
 
    // make sure to verify against the right file on I-M-S hit
@@ -1875,101 +1849,13 @@ void pkgAcqMetaIndex::RetrievalDone(string Message)                    /*{{{*/
    {
       string FinalFile = _config->FindDir("Dir::State::lists");
       FinalFile += URItoFileName(RealURI);
-      if (SigFile == DestFile)
-      {
-        SigFile = FinalFile;
-#if 0
-        // constructor of pkgAcqMetaClearSig moved it out of the way,
-        // now move it back in on IMS hit for the 'old' file
-        string const OldClearSig = DestFile + ".reverify";
-        if (RealFileExists(OldClearSig) == true)
-           Rename(OldClearSig, FinalFile);
-#endif
-      }
       DestFile = FinalFile;
    }
 
-   // queue a signature
-   if(SigFile != DestFile)
-      new pkgAcqMetaSig(Owner, TransactionManager, 
-                        MetaIndexSigURI, MetaIndexSigURIDesc,
-                        MetaIndexSigShortDesc, DestFile, IndexTargets, 
-                        MetaIndexParser);
-
+   // set Item to complete as the remaining work is all local (verify etc)
    Complete = true;
-}
-                                                                       /*}}}*/
-void pkgAcqMetaIndex::AuthDone(string Message)                         /*{{{*/
-{
-   // At this point, the gpgv method has succeeded, so there is a
-   // valid signature from a key in the trusted keyring.  We
-   // perform additional verification of its contents, and use them
-   // to verify the indexes we are about to download
-
-   if (!MetaIndexParser->Load(DestFile))
-   {
-      Status = StatAuthError;
-      ErrorText = MetaIndexParser->ErrorText;
-      return;
-   }
-
-   if (!VerifyVendor(Message))
-   {
-      return;
-   }
-
-   if (_config->FindB("Debug::pkgAcquire::Auth", false))
-      std::cerr << "Signature verification succeeded: "
-                << DestFile << std::endl;
-
-// we ensure this by other means
-#if 0 
-   // do not trust any previously unverified content that we may have
-   string LastGoodSigFile = _config->FindDir("Dir::State::lists").append("partial/").append(URItoFileName(RealURI));
-   if (DestFile != SigFile)
-      LastGoodSigFile.append(".gpg");
-   LastGoodSigFile.append(".reverify");
-   if(IMSHit == false && RealFileExists(LastGoodSigFile) == false)
-   {
-      for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin();
-           Target != IndexTargets->end();
-           ++Target)
-      {
-         // remove old indexes
-         std::string index = _config->FindDir("Dir::State::lists") +
-            URItoFileName((*Target)->URI);
-         unlink(index.c_str());
-         // and also old gzipindexes
-         std::vector<std::string> types = APT::Configuration::getCompressionTypes();
-         for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
-         {
-            index += '.' + (*t);
-            unlink(index.c_str());
-         }
-      }
-   }
-#endif
-
-   // Download further indexes with verification 
-   //
-   // it would be really nice if we could simply do
-   //    if (IMSHit == false) QueueIndexes(true)
-   // and skip the download if the Release file has not changed
-   // - but right now the list cleaner will needs to be tricked
-   //   to not delete all our packages/source indexes in this case
-   QueueIndexes(true);
 
-#if 0
-   // is it a clearsigned MetaIndex file?
-   if (DestFile == SigFile)
-      return;
-
-   // Done, move signature file into position
-   string VerifiedSigFile = _config->FindDir("Dir::State::lists") +
-      URItoFileName(RealURI) + ".gpg";
-   Rename(SigFile,VerifiedSigFile);
-   chmod(VerifiedSigFile.c_str(),0644);
-#endif
+   return true;
 }
                                                                        /*}}}*/
 void pkgAcqMetaBase::QueueIndexes(bool verify)                         /*{{{*/
@@ -2058,7 +1944,7 @@ void pkgAcqMetaBase::QueueIndexes(bool verify)                            /*{{{*/
    }
 }
                                                                        /*}}}*/
-bool pkgAcqMetaIndex::VerifyVendor(string Message)                     /*{{{*/
+bool pkgAcqMetaBase::VerifyVendor(string Message, const string &RealURI)/*{{{*/
 {
    string::size_type pos;
 
@@ -2150,26 +2036,6 @@ void pkgAcqMetaIndex::Failed(string Message,
          return;
    }
 
-   /* Always move the meta index, even if gpgv failed. This ensures
-    * that PackageFile objects are correctly filled in */
-   if (FileExists(DestFile)) 
-   {
-      string FinalFile = _config->FindDir("Dir::State::lists");
-      FinalFile += URItoFileName(RealURI);
-      /* InRelease files become Release files, otherwise
-       * they would be considered as trusted later on */
-      if (SigFile == DestFile) {
-        RealURI = RealURI.replace(RealURI.rfind("InRelease"), 9,
-                                      "Release");
-        FinalFile = FinalFile.replace(FinalFile.rfind("InRelease"), 9,
-                                      "Release");
-        SigFile = FinalFile;
-      }
-
-      // Done, queue for rename on transaction finished
-      TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
-   }
-
    _error->Warning(_("The data from '%s' is not signed. Packages "
                      "from that repository can not be authenticated."),
                    URIDesc.c_str());
@@ -2179,11 +2045,35 @@ void pkgAcqMetaIndex::Failed(string Message,
    // only allow going further if the users explicitely wants it
    if(_config->FindB("Acquire::AllowInsecureRepositories") == true)
    {
+      /* Always move the meta index, even if gpgv failed. This ensures
+       * that PackageFile objects are correctly filled in */
+      if (FileExists(DestFile)) 
+      {
+         string FinalFile = _config->FindDir("Dir::State::lists");
+         FinalFile += URItoFileName(RealURI);
+         /* InRelease files become Release files, otherwise
+          * they would be considered as trusted later on */
+         if (SigFile == DestFile) {
+            RealURI = RealURI.replace(RealURI.rfind("InRelease"), 9,
+                                      "Release");
+            FinalFile = FinalFile.replace(FinalFile.rfind("InRelease"), 9,
+                                          "Release");
+            SigFile = FinalFile;
+         }
+
+         // Done, queue for rename on transaction finished
+         TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
+      }
+
       QueueIndexes(false);
    } else {
       // warn if the repository is unsinged
       _error->Warning("Use --allow-insecure-repositories to force the update");
+      TransactionManager->AbortTransaction();
+      Status = StatError;
+      return;
    } 
+
 }
                                                                        /*}}}*/
 
@@ -2271,7 +2161,24 @@ void pkgAcqMetaClearSig::Done(std::string Message,unsigned long long Size,
       TransactionManager->AbortTransaction();
       return;
    }
-   pkgAcqMetaIndex::Done(Message, Size, Hashes, Cnf);
+
+   if(AuthPass == false)
+   {
+      if(CheckDownloadDone(Message, RealURI) == true)
+         QueueForSignatureVerify(DestFile, DestFile);
+      return;
+   }
+   else
+   {
+      if(AuthDone(Message, RealURI) == true)
+      {
+         string FinalFile = _config->FindDir("Dir::State::lists");
+         FinalFile += URItoFileName(RealURI);
+
+         // queue for copy in place
+         TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
+      }
+   }
 }
                                                                        /*}}}*/
 void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/