diff options
Diffstat (limited to 'apt-inst')
-rw-r--r-- | apt-inst/contrib/extracttar.cc | 2 | ||||
-rw-r--r-- | apt-inst/deb/debfile.cc | 42 | ||||
-rw-r--r-- | apt-inst/dirstream.cc | 14 | ||||
-rw-r--r-- | apt-inst/makefile | 2 |
4 files changed, 41 insertions, 19 deletions
diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index 1a358d57e..01b6b3836 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -336,7 +336,7 @@ bool ExtractTar::Go(pkgDirStream &Stream) } // And finish up - if (Itm.Size >= 0 && BadRecord == false) + if (BadRecord == false) if (Stream.FinishedFile(Itm,Fd) == false) return false; diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index cd7a88808..a40cd1ae8 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -20,6 +20,7 @@ #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> @@ -46,7 +47,9 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File) if (!CheckMember("data.tar.gz") && !CheckMember("data.tar.bz2") && - !CheckMember("data.tar.lzma")) { + !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; } @@ -125,22 +128,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<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.lzma"); - Compressor = "lzma"; + + 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; - + // Prepare Tar ExtractTar Tar(File,Member->Size,Compressor); if (_error->PendingError() == true) diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc index 586bbf739..9b6a56848 100644 --- a/apt-inst/dirstream.cc +++ b/apt-inst/dirstream.cc @@ -43,11 +43,17 @@ bool pkgDirStream::DoItem(Item &Itm,int &Fd) // fchmod deals with umask and fchown sets the ownership if (fchmod(iFd,Itm.Mode) != 0) - return _error->Errno("fchmod",_("Failed to write file %s"), - Itm.Name); + { + _error->Errno("fchmod",_("Failed to write file %s"), Itm.Name); + close(iFd); + return false; + } if (fchown(iFd,Itm.UID,Itm.GID) != 0 && errno != EPERM) - return _error->Errno("fchown",_("Failed to write file %s"), - Itm.Name); + { + return _error->Errno("fchown",_("Failed to write file %s"), Itm.Name); + close(iFd); + return false; + } Fd = iFd; return true; } diff --git a/apt-inst/makefile b/apt-inst/makefile index 785dc62ba..32d231240 100644 --- a/apt-inst/makefile +++ b/apt-inst/makefile @@ -14,7 +14,7 @@ include ../buildlib/libversion.mak # The library name LIBRARY=apt-inst -MAJOR=1.2 +MAJOR=1.3 MINOR=0 SLIBS=$(PTHREADLIB) -lapt-pkg APT_DOMAIN:=libapt-inst$(MAJOR) |