// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: extracttar.cc,v 1.8 2003/07/18 15:35:23 mdz Exp $
+// $Id: extracttar.cc,v 1.8.2.1 2004/01/16 18:58:50 mdz Exp $
/* ######################################################################
Extract a Tar - Tar Extractor
#ifdef __GNUG__
#pragma implementation "apt-pkg/extracttar.h"
#endif
-#include <apti18n.h>
#include <apt-pkg/extracttar.h>
#include <apt-pkg/error.h>
#include <signal.h>
#include <fcntl.h>
#include <iostream>
+#include <apti18n.h>
/*}}}*/
+
using namespace std;
// The on disk header for a tar file.
// ExtractTar::ExtractTar - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-ExtractTar::ExtractTar(FileFd &Fd,unsigned long Max) : File(Fd),
- MaxInSize(Max)
+ExtractTar::ExtractTar(FileFd &Fd,unsigned long Max,string DecompressionProgram) : File(Fd),
+ MaxInSize(Max), DecompressProg(DecompressionProgram)
{
GZPid = -1;
// Make sure we clean it up!
kill(GZPid,SIGINT);
- if (ExecWait(GZPid,_config->Find("dir::bin::gzip","/bin/gzip").c_str(),
+ string confvar = string("dir::bin::") + DecompressProg;
+ if (ExecWait(GZPid,_config->Find(confvar.c_str(),DecompressProg.c_str()).c_str(),
Force) == false)
{
GZPid = -1;
SetCloseExec(STDERR_FILENO,false);
const char *Args[3];
- Args[0] = _config->Find("dir::bin::gzip","/bin/gzip").c_str();
+ string confvar = string("dir::bin::") + DecompressProg;
+ Args[0] = _config->Find(confvar.c_str(),DecompressProg.c_str()).c_str();
Args[1] = "-d";
Args[2] = 0;
- execv(Args[0],(char **)Args);
+ execvp(Args[0],(char **)Args);
cerr << _("Failed to exec gzip ") << Args[0] << endl;
_exit(100);
}
return Done(true);
if (NewSum != CheckSum)
- return _error->Error(_("Tar Checksum failed, archive corrupted"));
+ return _error->Error(_("Tar checksum failed, archive corrupted"));
// Decode all of the fields
pkgDirStream::Item Itm;