Author: jgg
Date: 2001-03-11 22:37:35 GMT
Alfredos bzip2 stuff
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: gzip.cc,v 1.13 2001/03/11 05:30:20 jgg Exp $
+// $Id: gzip.cc,v 1.14 2001/03/11 22:37:35 jgg Exp $
/* ######################################################################
GZip method - Take a file URI in and decompress it into the target
/* ######################################################################
GZip method - Take a file URI in and decompress it into the target
#include <errno.h>
/*}}}*/
#include <errno.h>
/*}}}*/
class GzipMethod : public pkgAcqMethod
{
virtual bool Fetch(FetchItem *Itm);
class GzipMethod : public pkgAcqMethod
{
virtual bool Fetch(FetchItem *Itm);
// GzipMethod::Fetch - Decompress the passed URI /*{{{*/
// ---------------------------------------------------------------------
// GzipMethod::Fetch - Decompress the passed URI /*{{{*/
// ---------------------------------------------------------------------
-/* This forks gzip and hashes the resulting decompressed output as it
- flows to the destination file */
bool GzipMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
string Path = Get.Host + Get.Path; // To account for relative paths
bool GzipMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
string Path = Get.Host + Get.Path; // To account for relative paths
+ string GzPathOption = "Dir::bin::"+string(Prog);
+
FetchResult Res;
Res.Filename = Itm->DestFile;
URIStart(Res);
FetchResult Res;
Res.Filename = Itm->DestFile;
URIStart(Res);
int GzOut[2];
if (pipe(GzOut) < 0)
int GzOut[2];
if (pipe(GzOut) < 0)
- return _error->Errno("pipe","Couldn't open pipe for gzip");
+ return _error->Errno("pipe","Couldn't open pipe for %s",Prog);
// Fork gzip
int Process = ExecFork();
// Fork gzip
int Process = ExecFork();
SetCloseExec(STDOUT_FILENO,false);
const char *Args[3];
SetCloseExec(STDOUT_FILENO,false);
const char *Args[3];
- Args[0] = _config->Find("Dir::bin::gzip","gzip").c_str();
+ Args[0] = _config->Find(GzPathOption,Prog).c_str();
Args[1] = "-d";
Args[2] = 0;
execvp(Args[0],(char **)Args);
Args[1] = "-d";
Args[2] = 0;
execvp(Args[0],(char **)Args);
- _error->Errno("read", "Read error from gzip process");
+ _error->Errno("read", "Read error from %s process",Prog);
Hash.Add(Buffer,Count);
if (To.Write(Buffer,Count) == false)
Hash.Add(Buffer,Count);
if (To.Write(Buffer,Count) == false)
}
// Wait for gzip to finish
}
// Wait for gzip to finish
- if (ExecWait(Process,_config->Find("Dir::bin::gzip","gzip").c_str(),false) == false)
+ if (ExecWait(Process,_config->Find(GzPathOption,Prog).c_str(),false) == false)
{
To.OpFail();
return false;
{
To.OpFail();
return false;
+int main(int argc, char *argv[])
+
+ Prog = strrchr(argv[0],'/');
+ Prog++;
+
SOURCE = rsh.cc
include $(PROGRAM_H)
SOURCE = rsh.cc
include $(PROGRAM_H)
-# SSH method symlink
-all: $(BIN)/ssh
-veryclean: clean-$(BIN)/ssh
+# SSH and vzip2 method symlink
+all: $(BIN)/ssh $(BIN)/bzip2
+veryclean: clean-$(BIN)/ssh clean-$(BIN)/bzip2
$(BIN)/ssh:
echo "Installing ssh method link"
ln -fs rsh $(BIN)/ssh
clean-$(BIN)/ssh:
$(BIN)/ssh:
echo "Installing ssh method link"
ln -fs rsh $(BIN)/ssh
clean-$(BIN)/ssh:
+ -rm $(BIN)/ssh
+
+$(BIN)/bzip2:
+ echo "Installing bzip2 method link"
+ ln -fs gzip $(BIN)/bzip2
+clean-$(BIN)/bzip2:
+ -rm $(BIN)/bzip2