X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b21c043804b1be7f4d79ac3f5a6615dc96f26a42..0418949ebe9fc886e7794fa1de17c8b6c74e65ea:/apt-inst/deb/debfile.cc diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index b838185d8..4bd065cf8 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: debfile.cc,v 1.4 2004/01/07 20:39:37 mdz Exp $ +// $Id: debfile.cc,v 1.3.2.1 2004/01/16 18:58:50 mdz Exp $ /* ###################################################################### Debian Archive File (.deb) @@ -16,14 +16,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/debfile.h" -#endif +#include +#include #include #include #include #include +#include #include #include @@ -48,8 +48,12 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File) return; } - if (!CheckMember("data.tar.gz") && !CheckMember("data.tar.bz2")) { - _error->Error(_("This is not a valid DEB archive, it has no '%s' or '%s' member"), "data.tar.gz", "data.tar.bz2"); + if (!CheckMember("data.tar.gz") && + !CheckMember("data.tar.bz2") && + !CheckMember("data.tar.lzma") && + !CheckMember("data.tar.xz")) { + // FIXME: add data.tar.xz here - adding it now would require a Translation round for a very small gain + _error->Error(_("This is not a valid DEB archive, it has no '%s', '%s' or '%s' member"), "data.tar.gz", "data.tar.bz2", "data.tar.lzma"); return; } } @@ -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,18 +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"; + // 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) - return _error->Error(_("Internal Error, could not locate member")); + + 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 (File.Seek(Member->Start) == false) return false; - + // Prepare Tar ExtractTar Tar(File,Member->Size,Compressor); if (_error->PendingError() == true) @@ -154,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); @@ -253,7 +274,7 @@ bool debDebFile::MemControlExtract::Read(debDebFile &Deb) Control[Length] = '\n'; Control[Length+1] = '\n'; if (Section.Scan(Control,Length+2) == false) - return _error->Error(_("Unparsible control file")); + return _error->Error(_("Unparsable control file")); return true; } /*}}}*/