]> git.saurik.com Git - apt.git/blobdiff - apt-inst/deb/debfile.cc
merged from debian-sid
[apt.git] / apt-inst / deb / debfile.cc
index edd78adbbb10cf95e061a4e3f3f605fc1d2953ba..4bd065cf8aa0dbb6f7a939b3034851529ef63c0a 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include<config.h>
+
+#include <apt-pkg/database.h>
 #include <apt-pkg/debfile.h>
 #include <apt-pkg/extracttar.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/debfile.h>
 #include <apt-pkg/extracttar.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/deblistparser.h>
+#include <apt-pkg/aptconfiguration.h>
 
 #include <sys/stat.h>
 #include <unistd.h>
 
 #include <sys/stat.h>
 #include <unistd.h>
@@ -104,8 +108,8 @@ bool debDebFile::ExtractControl(pkgDataBase &DB)
       return false;
    
    // Get into the temporary directory
       return false;
    
    // Get into the temporary directory
-   string Cwd = SafeGetCWD();
-   string Tmp;
+   std::string Cwd = SafeGetCWD();
+   std::string Tmp;
    if (DB.GetMetaTmp(Tmp) == false)
       return false;
    if (chdir(Tmp.c_str()) != 0)
    if (DB.GetMetaTmp(Tmp) == false)
       return false;
    if (chdir(Tmp.c_str()) != 0)
@@ -127,26 +131,35 @@ bool debDebFile::ExtractControl(pkgDataBase &DB)
 /* Simple wrapper around tar.. */
 bool debDebFile::ExtractArchive(pkgDirStream &Stream)
 {
 /* Simple wrapper around tar.. */
 bool debDebFile::ExtractArchive(pkgDirStream &Stream)
 {
-   // Get the archive member and positition the file 
-   const ARArchive::Member *Member = AR.FindMember("data.tar.gz");
-   const char *Compressor = "gzip";
-   if (Member == 0) {
-      Member = AR.FindMember("data.tar.bz2");
-      Compressor = "bzip2";
-   }
-   if (Member == 0) {
-      Member = AR.FindMember("data.tar.lzma");
-      Compressor = "lzma";
+   // Get the archive member
+   const ARArchive::Member *Member = NULL;
+   std::string Compressor;
+
+   std::string const data = "data.tar";
+   std::vector<APT::Configuration::Compressor> compressor = APT::Configuration::getCompressors();
+   for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
+       c != compressor.end(); ++c)
+   {
+      Member = AR.FindMember(std::string(data).append(c->Extension).c_str());
+      if (Member == NULL)
+        continue;
+      Compressor = c->Binary;
+      break;
    }
    }
-   if (Member == 0) {
-      Member = AR.FindMember("data.tar.xz");
-      Compressor = "xz";
+
+   if (Member == NULL)
+   {
+      std::string ext = "data.tar.{";
+      for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
+          c != compressor.end(); ++c)
+        ext.append(c->Extension.substr(1));
+      ext.append("}");
+      return _error->Error(_("Internal error, could not locate member %s"), ext.c_str());
    }
    }
-   if (Member == 0)
-      return _error->Error(_("Internal error, could not locate member"));   
+
    if (File.Seek(Member->Start) == false)
       return false;
    if (File.Seek(Member->Start) == false)
       return false;
-      
+
    // Prepare Tar
    ExtractTar Tar(File,Member->Size,Compressor);
    if (_error->PendingError() == true)
    // Prepare Tar
    ExtractTar Tar(File,Member->Size,Compressor);
    if (_error->PendingError() == true)
@@ -162,7 +175,7 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream)
 pkgCache::VerIterator debDebFile::MergeControl(pkgDataBase &DB)
 {
    // Open the control file
 pkgCache::VerIterator debDebFile::MergeControl(pkgDataBase &DB)
 {
    // Open the control file
-   string Tmp;
+   std::string Tmp;
    if (DB.GetMetaTmp(Tmp) == false)
       return pkgCache::VerIterator(DB.GetCache());
    FileFd Fd(Tmp + "control",FileFd::ReadOnly);
    if (DB.GetMetaTmp(Tmp) == false)
       return pkgCache::VerIterator(DB.GetCache());
    FileFd Fd(Tmp + "control",FileFd::ReadOnly);