X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b2e465d6d32d2dc884f58b94acb7e35f671a87fe..de6a3945e1211f6edf2069e11f6fbe522d6776d5:/apt-inst/deb/debfile.cc diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index c93ba88a8..cd7a88808 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.2 2001/02/20 07:03:17 jgg Exp $ +// $Id: debfile.cc,v 1.3.2.1 2004/01/16 18:58:50 mdz Exp $ /* ###################################################################### Debian Archive File (.deb) @@ -16,10 +16,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/debfile.h" -#endif - #include #include #include @@ -27,6 +23,7 @@ #include #include +#include /*}}}*/ // DebFile::debDebFile - Constructor /*{{{*/ @@ -36,12 +33,23 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File) { if (_error->PendingError() == true) return; - - // Check the members for validity - if (CheckMember("debian-binary") == false || - CheckMember("control.tar.gz") == false || - CheckMember("data.tar.gz") == false) + + if (!CheckMember("debian-binary")) { + _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "debian-binary"); return; + } + + if (!CheckMember("control.tar.gz")) { + _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar.gz"); + return; + } + + if (!CheckMember("data.tar.gz") && + !CheckMember("data.tar.bz2") && + !CheckMember("data.tar.lzma")) { + _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; + } } /*}}}*/ // DebFile::CheckMember - Check if a named member is in the archive /*{{{*/ @@ -51,7 +59,7 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File) bool debDebFile::CheckMember(const char *Name) { if (AR.FindMember(Name) == 0) - return _error->Error("This is not a valid DEB archive, missing '%s' member",Name); + return false; return true; } /*}}}*/ @@ -68,7 +76,6 @@ const ARArchive::Member *debDebFile::GotoMember(const char *Name) const ARArchive::Member *Member = AR.FindMember(Name); if (Member == 0) { - _error->Error("Internal Error, could not locate member %s",Name); return 0; } if (File.Seek(Member->Start) == false) @@ -90,7 +97,7 @@ bool debDebFile::ExtractControl(pkgDataBase &DB) // Prepare Tar ControlExtract Extract; - ExtractTar Tar(File,Member->Size); + ExtractTar Tar(File,Member->Size,"gzip"); if (_error->PendingError() == true) return false; @@ -100,7 +107,7 @@ bool debDebFile::ExtractControl(pkgDataBase &DB) if (DB.GetMetaTmp(Tmp) == false) return false; if (chdir(Tmp.c_str()) != 0) - return _error->Errno("chdir","Couldn't change to %s",Tmp.c_str()); + return _error->Errno("chdir",_("Couldn't change to %s"),Tmp.c_str()); // Do extraction if (Tar.Go(Extract) == false) @@ -120,13 +127,22 @@ 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"; + } if (Member == 0) - return _error->Error("Internal Error, could not locate member"); + return _error->Error(_("Internal error, could not locate member")); if (File.Seek(Member->Start) == false) return false; // Prepare Tar - ExtractTar Tar(File,Member->Size); + ExtractTar Tar(File,Member->Size,Compressor); if (_error->PendingError() == true) return false; return Tar.Go(Stream); @@ -154,7 +170,7 @@ pkgCache::VerIterator debDebFile::MergeControl(pkgDataBase &DB) return pkgCache::VerIterator(DB.GetCache()); if (Ver.end() == true) - _error->Error("Failed to locate a valid control file"); + _error->Error(_("Failed to locate a valid control file")); return Ver; } /*}}}*/ @@ -229,7 +245,7 @@ bool debDebFile::MemControlExtract::Read(debDebFile &Deb) return false; // Extract it. - ExtractTar Tar(Deb.GetFile(),Member->Size); + ExtractTar Tar(Deb.GetFile(),Member->Size,"gzip"); if (Tar.Go(*this) == false) return false; @@ -239,7 +255,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; } /*}}}*/