X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b7080ced608f012aee2566afc724c3727e75fc1b..0418949ebe9fc886e7794fa1de17c8b6c74e65ea:/apt-inst/deb/debfile.cc diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index edd78adbb..4bd065cf8 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -16,10 +16,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + +#include #include #include #include #include +#include #include #include @@ -104,8 +108,8 @@ bool debDebFile::ExtractControl(pkgDataBase &DB) 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) @@ -127,26 +131,35 @@ bool debDebFile::ExtractControl(pkgDataBase &DB) /* 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 compressor = APT::Configuration::getCompressors(); + for (std::vector::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::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; - + // 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 - string Tmp; + std::string Tmp; if (DB.GetMetaTmp(Tmp) == false) return pkgCache::VerIterator(DB.GetCache()); FileFd Fd(Tmp + "control",FileFd::ReadOnly);