summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-item.cc47
-rw-r--r--apt-pkg/acquire-worker.cc6
-rw-r--r--apt-pkg/acquire.cc7
-rw-r--r--cmdline/apt-get.cc1
-rw-r--r--methods/debdelta.cc69
5 files changed, 93 insertions, 37 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index b85e5d19b..0f7f7c00e 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -2136,7 +2136,8 @@ pkgAcqDebdelta::pkgAcqDebdelta(pkgAcquire *Owner,pkgSourceList *Sources,
// priority than authenticated http:// uris
if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
Trusted = false;
- if (Debug) {
+ if (Debug)
+ {
std::cerr << "\n[Debdelta] pkgAcqDebdelta::pkgAcqDebdelta()" << std::endl;
std::cerr << " DebdeltaName : " << DebdeltaName << std::endl;
std::cerr << " StoreFilename: " << StoreFilename << std::endl;
@@ -2243,7 +2244,8 @@ bool pkgAcqDebdelta::QueueNext()
Desc.Description = "[Debdelta] " + Index->ArchiveInfo(Version);
Desc.Owner = this;
Desc.ShortDesc = "[Debdelta] " + string(Version.ParentPkg().Name());
- if (Debug) {
+ if (Debug)
+ {
std::cerr << "[Debdelta] pkgAcqDebdelta::QueueNext()" << std::endl;
std::cerr << " DestFile : " << DestFile << std::endl;
std::cerr << " Desc.URI : " << Desc.URI << std::endl;
@@ -2258,17 +2260,23 @@ bool pkgAcqDebdelta::QueueNext()
void pkgAcqDebdelta::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
{
- if (Debug) {
- std::cerr << "\n[Debdelta] Failed to download " << Desc.URI << std::endl;
- std::cerr << "[Debdelta] Message:\n" << Message << std::endl;
+ if (Debug)
+ {
+ std::cerr << "\n[Debdelta] Failed to fetch/patch " << DestFile
+ << " state: " << DebdeltaStatus << std::endl;
+ std::cerr << "[Debdelta] Message:\n=====================\n" << Message
+ << "\n=====================" << std::endl;
}
// TODO: find out what went wrong and display to the user
- new pkgAcqArchive(Owner, Sources, Recs, Version, StoreFilename);
- Complete = false;
- Status = StatError;
+ std::cerr << "\n[Debdelta] Queuing the regular deb for downloading..." << std::endl;
+
+ Complete = true; //false;
+ Status = pkgAcquire::Item::StatDone; //StatError;
DebdeltaStatus = FetchingFailure;
- Item::Failed(Message, Cnf);
+ //Item::Failed(Message, Cnf);
Dequeue();
+
+ new pkgAcqArchive(Owner, Sources, Recs, Version, StoreFilename);
}
void pkgAcqDebdelta::Done(string Message,unsigned long Size,string Hash,
@@ -2276,10 +2284,11 @@ void pkgAcqDebdelta::Done(string Message,unsigned long Size,string Hash,
{
// TODO: there must be two stages within this method.
// one for downloading debdelta. another for verifying the resulting .deb
- if (Debug) std::cerr << "[Debdelta] pkgAcqDebdelta::Done() state: " << DebdeltaStatus << std::endl;
+ if (Debug) std::cerr << "\n\n[Debdelta] pkgAcqDebdelta::Done() state: " << DebdeltaStatus << std::endl;
// Grab the output filename
string FileName = LookupTag(Message,"Filename");
- if (Debug) {
+ if (Debug)
+ {
std::cerr << " StoreFileName: " << StoreFilename
<< "\n DestFile : " << DestFile
<< "\n Desc.URI : " << Desc.URI
@@ -2288,22 +2297,28 @@ void pkgAcqDebdelta::Done(string Message,unsigned long Size,string Hash,
if (DebdeltaStatus == Patching)
{
if (Debug) std::cerr << "[Debdelta] Patching Done. Verifying "<< FileName << "..." << std::endl;
+ // check the hash. TODO: Is this handled by debpatch internally?
+ /*
if (ExpectedHash.toStr() != Hash)
{
Status = StatError;
ErrorText = _("[Debdelta] Hash Sum mismatch");
- if(FileExists(DestFile))
- if (!Local)
- Rename(DestFile, DestFile + ".FAILED");
- //return; // TODO: UNCOMMENT
+ // if(FileExists(DestFile))
+ // if (!Local)
+ // Rename(DestFile, DestFile + ".FAILED");
+ std::cerr << "[Debdelta] Hash Sum mismatch" << std::endl;
+ std::cerr << " expected: " << ExpectedHash.toStr() << std::endl;
+ std::cerr << " hash : " << Hash << std::endl;
+ // return; // TODO: UNCOMMENT
}
// Check the size
if (Size != Version->Size)
{
Status = StatError;
ErrorText = _("[Debdelta] Size mismatch");
+ std::cerr << "[Debdelta] Size mismatch" << std::endl;
//return; // TODO: UNCOMMEnT
- }
+ } */
DebdeltaStatus = Completed;
Complete = true;
Status = StatDone;
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 1a17dfa5c..6d430741f 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -332,7 +332,7 @@ bool pkgAcquire::Worker::RunMessages()
// 400 URI Failure
case 400:
{
- std::cerr <<" 400 URI Failure" << std::endl;
+ std::cerr <<" 400 URI Failure" << std::endl;
if (Itm == 0)
{
_error->Error("Method gave invalid 400 URI Failure message");
@@ -365,13 +365,13 @@ bool pkgAcquire::Worker::RunMessages()
// 401 General Failure
case 401:
- std::cerr <<" 401 General Failure" << std::endl;
+ std::cerr <<" 401 General Failure" << std::endl;
_error->Error("Method %s General failure: %s",Access.c_str(),LookupTag(Message,"Message").c_str());
break;
// 403 Media Change
case 403:
- std::cerr <<" 403 Media Change" << std::endl;
+ std::cerr <<" 403 Media Change" << std::endl;
MediaChange(Message);
break;
}
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 7596aa956..9478cdfb4 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -228,10 +228,9 @@ void pkgAcquire::Enqueue(ItemDesc &Item)
// Some trace stuff
if (Debug == true)
{
- clog << "pkgAcquire::Enqueue()" << endl;
- clog << " Fetching " << Item.URI << endl;
- clog << " to " << Item.Owner->DestFile << endl;
- clog << " Queue is: " << Name << endl;
+ clog << "Fetching " << Item.URI << endl;
+ clog << " to " << Item.Owner->DestFile << endl;
+ clog << " Queue is: " << Name << endl;
}
}
/*}}}*/
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 0da3965be..3292ae745 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -3226,7 +3226,6 @@ void SigWinch(int)
/*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
- std::cout << "Starting apt-get" << std::endl;
CommandLine::Args Args[] = {
{'h',"help","help",0},
{'v',"version","version",0},
diff --git a/methods/debdelta.cc b/methods/debdelta.cc
index 42d91a6dc..a8438a8e5 100644
--- a/methods/debdelta.cc
+++ b/methods/debdelta.cc
@@ -10,12 +10,18 @@
#include <sys/stat.h>
#include <sys/uio.h>
+#include <sys/wait.h>
#include <unistd.h>
#include <utime.h>
#include <stdio.h>
#include <errno.h>
#include <zlib.h>
#include <apti18n.h>
+#include <stdlib.h>
+
+#include <iostream>
+#include <fstream>
+using namespace std;
/*}}}*/
/** \brief DebdeltaMethod - TODO: say something about debdelta here!
@@ -25,6 +31,7 @@ class DebdeltaMethod : public pkgAcqMethod {
string DebdeltaFile;
string FromFile;
string ToFile;
+ string DebpatchOutput;
protected:
// the main(i.e. most important) method of the debdelta method.
virtual bool Fetch(FetchItem *Itm);
@@ -41,7 +48,7 @@ bool DebdeltaMethod::Fetch(FetchItem *Itm) /*{{{*/
//URIDone(ResTest);
//return true;
///
- Debug = _config->FindB("Debug::pkgAcquire::Debdelta", false);
+ Debug = true; //_config->FindB("Debug::pkgAcquire::Debdelta", false);
FromFile = Itm->DestFile;
URI U(Itm->Uri);
DebdeltaFile = U.Path;
@@ -49,15 +56,32 @@ bool DebdeltaMethod::Fetch(FetchItem *Itm) /*{{{*/
if (flExtension(FromFile) != "deb" || !FileExists(FromFile))
FromFile = "/";
if (!FileExists(DebdeltaFile))
- return _error->Error("[Debdelta] Could not find a debdelta file.");
+ return _error->Error("\n[Debdelta] Could not find a debdelta file.");
MakeToFile();
if (FileExists(ToFile))
- return _error->Error("[Debdelta] New .deb already exists.");
+ return _error->Error("\n[Debdelta] New .deb already exists.");
+
+ if (Debug == true)
+ {
+ std::cerr << "\n[Debdelta] FromFile: " << FromFile
+ << "\n ToFile: " << ToFile
+ << "\n DebdelatFile: " << DebdeltaFile << std::endl;
+ }
- pid_t Process = ExecFork();
+ int Fd[2];
+ if (pipe(Fd) != 0)
+ return _error->Error("[Debdelta] Could not create the pipe.");
+ pid_t Process = fork();
if (Process == 0)
{
- const char* Args[8] = {0};
+ // redirect debpatch's stdout,stderr to the pipe
+ close(Fd[0]);
+ close(1);
+ dup(Fd[1]);
+ close(2);
+ dup(Fd[1]);
+ // make the debpatch command and run it.
+ const char* Args[6] = {0};
Args[0] = "/usr/bin/debpatch";
if (!FileExists(Args[0]))
return _error->Error("[Debdelta] Could not find debpatch.");
@@ -65,21 +89,37 @@ bool DebdeltaMethod::Fetch(FetchItem *Itm) /*{{{*/
Args[2] = DebdeltaFile.c_str();
Args[3] = FromFile.c_str();
Args[4] = ToFile.c_str();
- Args[5] = "1>&2";
- Args[6] = "2>/dev/null";
if (Debug == true)
{
- std::cerr << "[Debdelta] Command:" << std::endl;
+ std::cerr << "\n[Debdelta] Command:" << std::endl;
std::cerr << Args[0] << " " << Args[1] << " " << Args[2] << " " << Args[3] << " "
<< Args[4] << std::endl;
}
- std::cerr << "[Debdelta] Patching " << ToFile << "...\r";
+ std::cerr << "\n\n[Debdelta] Patching " << ToFile << "..." << std::endl;
execv(Args[0], (char **)Args);
+ close(Fd[1]);
}
- if (ExecWait(Process, "debpatch", false))
+ else if (Process != -1)
{
+ int status;
+ int options = 0;
+ if (Process != waitpid(Process, &status, options))
+ return _error->Error("[Debdelta] debpatch did not return normally.");
+
+ // read the stderr,stdout outputs of debpatch
+ size_t LineSize = 1024;
+ char *Line = (char *)malloc(LineSize + 1);
+ close(Fd[1]);
+ //close(0);
+ //dup(Fd[0]);
+ FILE *fp = fdopen(Fd[0], "r");
+ DebpatchOutput = "";
+ while (getline(&Line, &LineSize, fp) != EOF)
+ DebpatchOutput += string(Line);
+ fclose(fp);
+
if (!FileExists(ToFile))
- return _error->Error("[Debdelta] Failed to patch %s", ToFile.c_str());
+ return _error->Error("\n[Debdelta] Failed to patch %s", ToFile.c_str());
// move the .deb to Dir::Cache::Archives
string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(ToFile);
Rename(ToFile, FinalFile);
@@ -90,9 +130,12 @@ bool DebdeltaMethod::Fetch(FetchItem *Itm) /*{{{*/
URIDone(Res);
else
std::cout << "Filename: " << Res.Filename << std::endl;
- return true;
}
- return false;
+ else
+ {
+ return _error->Error("[Debdelta] forking failed.");
+ }
+ return true;
}