]> git.saurik.com Git - apt.git/commitdiff
Merge remote-tracking branch 'donkult/feature/generalize-gzipindex' into debian/sid
authorMichael Vogt <mvo@ubuntu.com>
Fri, 26 Sep 2014 16:09:32 +0000 (18:09 +0200)
committerMichael Vogt <mvo@ubuntu.com>
Fri, 26 Sep 2014 16:09:32 +0000 (18:09 +0200)
1  2 
apt-pkg/acquire-item.cc

diff --combined apt-pkg/acquire-item.cc
index 36c0fa567a5f4c442467660a764288a3f6c2927d,da57f8d3b06e678078c87a0f7691f1597747a7e3..2401364a95b92dc56d428400f29ba23c65e3d5f1
@@@ -969,8 -969,10 +969,10 @@@ void pkgAcqIndex::Init(string const &UR
     std::string const comprExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
     if (comprExt == "uncompressed")
        Desc.URI = URI;
-    else
+    else {
        Desc.URI = URI + '.' + comprExt;
+       DestFile = DestFile + '.' + comprExt;
+    }
  
     Desc.Description = URIDesc;
     Desc.Owner = this;
  /* The only header we use is the last-modified header. */
  string pkgAcqIndex::Custom600Headers()
  {
+    std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
     string Final = _config->FindDir("Dir::State::lists");
     Final += URItoFileName(RealURI);
     if (_config->FindB("Acquire::GzipIndexes",false))
-       Final += ".gz";
+       Final += compExt;
     
     string msg = "\nIndex-File: true";
     // FIXME: this really should use "IndexTarget::IsOptional()" but that
@@@ -1027,8 -1030,8 +1030,8 @@@ std::string pkgAcqIndex::GetFinalFilena
  {
     std::string FinalFile = _config->FindDir("Dir::State::lists");
     FinalFile += URItoFileName(URI);
-    if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
-       FinalFile += ".gz";
+    if (_config->FindB("Acquire::GzipIndexes",false) == true)
+       FinalFile += '.' + compExt;
     return FinalFile;
  }
                                                                        /*}}}*/
  void pkgAcqIndex::ReverifyAfterIMS(std::string const &FileName)
  {
     std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
-    if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
-       DestFile += ".gz";
+    if (_config->FindB("Acquire::GzipIndexes",false) == true)
+       DestFile += compExt;
  
     string FinalFile = GetFinalFilename(RealURI, compExt);
     Rename(FinalFile, FileName);
@@@ -1080,7 -1083,7 +1083,7 @@@ void pkgAcqIndex::Done(string Message,u
        /* Always verify the index file for correctness (all indexes must
         * have a Package field) (LP: #346386) (Closes: #627642) 
         */
-       FileFd fd(DestFile, FileFd::ReadOnlyGzip);
+       FileFd fd(DestFile, FileFd::ReadOnly, FileFd::Extension);
        // Only test for correctness if the file is not empty (empty is ok)
        if (fd.Size() > 0)
        {
           will work OK */
        DestFile = _config->FindDir("Dir::State::lists") + "partial/";
        DestFile += URItoFileName(RealURI);
-       if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
-          DestFile += ".gz";
+       if (_config->FindB("Acquire::GzipIndexes",false))
+          DestFile += '.' + compExt;
  
        // Remove the compressed version.
        if (Erase == true)
     else
        Local = true;
  
 +   // do not reverify cdrom sources as apt-cdrom may rewrite the Packages
 +   // file when its doing the indexcopy
 +   if (RealURI.substr(0,6) == "cdrom:" &&
 +       StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
 +      return;
 +
     // The files timestamp matches, for non-local URLs reverify the local
     // file, for local file, uncompress again to ensure the hashsum is still
     // matching the Release file
     if (!Local && StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
     {
+       // set destfile to the final destfile
+       if(_config->FindB("Acquire::GzipIndexes",false) == false)
+       {
+          DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+          DestFile += URItoFileName(RealURI);
+       }
        ReverifyAfterIMS(FileName);
        return;
     }
     string decompProg;
  
     // If we enable compressed indexes, queue for hash verification
-    if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz" && !Local) 
+    if (_config->FindB("Acquire::GzipIndexes",false))
     {
        DestFile = _config->FindDir("Dir::State::lists");
-       DestFile += URItoFileName(RealURI) + ".gz";
+       DestFile += URItoFileName(RealURI) + '.' + compExt;
  
        Decompression = true;
        Desc.URI = "copy:" + FileName;
@@@ -1207,11 -1211,11 +1217,11 @@@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgA
  // ---------------------------------------------------------------------
  string pkgAcqIndexTrans::Custom600Headers()
  {
+    std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
     string Final = _config->FindDir("Dir::State::lists");
     Final += URItoFileName(RealURI);
     if (_config->FindB("Acquire::GzipIndexes",false))
-       Final += ".gz";
+       Final += compExt;
  
     struct stat Buf;
     if (stat(Final.c_str(),&Buf) != 0)
@@@ -1558,8 -1562,12 +1568,12 @@@ void pkgAcqMetaIndex::AuthDone(string M
              URItoFileName((*Target)->URI);
           unlink(index.c_str());
           // and also old gzipindexes
-          index += ".gz";
-          unlink(index.c_str());
+          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());
+          }
        }
     }