summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorIshan Jayawardena <udeshike@gmail.com>2011-06-13 15:16:14 +0530
committerIshan Jayawardena <udeshike@gmail.com>2011-06-13 15:16:14 +0530
commit9995c4a0bc2d8567ff9f11d338ad610754682372 (patch)
tree8c365793c339382270c998dcd8395dc3a4471943 /methods
parentb8b21ea0d77e70b08948a594c6741252a39a6ca2 (diff)
added support for downloading debdelta files and queuing successfully downloaded debdeltas for processing with the debdelta apt method, in apt-pkg/acquire-item.{cc,h} in pkgAcqArchive class. Currently, no index for deltas are used. Proper progress reporting and methods to verify the debdeltas are yet to be added.
Diffstat (limited to 'methods')
-rw-r--r--methods/debdelta.cc38
1 files changed, 23 insertions, 15 deletions
diff --git a/methods/debdelta.cc b/methods/debdelta.cc
index d908e2a51..81d9ed888 100644
--- a/methods/debdelta.cc
+++ b/methods/debdelta.cc
@@ -18,8 +18,7 @@
#include <apti18n.h>
/*}}}*/
-/** \brief DebdeltaMethod - This method is used to patch a new deb from
- * an input deb and a debdelta file.
+/** \brief DebdeltaMethod - TODO: say something about debdelta here!
* */
class DebdeltaMethod : public pkgAcqMethod {
bool Debug;
@@ -34,20 +33,25 @@ public:
bool DebdeltaMethod::Fetch(FetchItem *Itm) /*{{{*/
{
+ /// Testing only...
+ FetchResult ResTest;
+ ResTest.Filename = "/home/ishan/devel/apt/testrepo/binary/gcc-4.6-base_4.6.0-7_amd64.deb";
+ URIDone(ResTest);
+ return true;
+ ///
Debug = _config->FindB("Debug::pkgAcquire::RRed", false);
+ URI U(Itm->Uri);
string OldDebFile = Itm->DestFile;
- string DebDeltaFile = Itm->Uri;
-
- if (!FileExists(OldDebFile))
+ string DebDeltaFile = U.Path;
+ FetchResult Res;
+ if (flExtension(OldDebFile) != ".deb" || !FileExists(OldDebFile))
OldDebFile = "/";
-
if (!FileExists(DebDeltaFile))
- return _error->Error("Could not find a debdelta file.");
-
+ return _error->Error("[Debdelta] Could not find a debdelta file.");
string NewDeb = GetNewPackageName(DebDeltaFile);
Itm->DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + NewDeb;
if (FileExists(Itm->DestFile))
- return _error->Error("New .deb already exists.");
+ return _error->Error("[Debdelta] New .deb already exists.");
pid_t Process = ExecFork();
if (Process == 0)
@@ -55,30 +59,34 @@ bool DebdeltaMethod::Fetch(FetchItem *Itm) /*{{{*/
const char* Args[6] = {0};
Args[0] = "/usr/bin/debpatch";
if (!FileExists(Args[0]))
- return _error->Error("Could not find debpatch.");
+ return _error->Error("[Debdelta] Could not find debpatch.");
Args[1] = "-A";
Args[2] = DebDeltaFile.c_str();
Args[3] = OldDebFile.c_str();
Args[4] = Itm->DestFile.c_str();
if (Debug == true)
{
- std::cerr << "Debdelta command:" << std::endl;
- std::cerr << Args[0] << " " << Args[1] << " " << Args[2] << " " << Args[3] << " "
- << Args[4] << std::endl;
+ std::cerr << "[Debdelta] Command:" << std::endl;
+ std::cerr << Args[0] << " " << Args[1] << " " << Args[2] << " "
+ << Args[3] << " " << Args[4] << std::endl;
}
+ std::cerr << "[Debdelta] Patching " << NewDeb << "..." << std::endl;
execv(Args[0], (char **)Args);
}
if (ExecWait(Process, "debpatch"))
{
if (!FileExists(Itm->DestFile))
- return _error->Error("Failed to patch %s", Itm->DestFile.c_str());
+ return _error->Error("[Debdelta] Failed to patch %s", Itm->DestFile.c_str());
// move the .deb to Dir::Cache::Archives
OldDebFile = _config->FindDir("Dir::Cache::Archives") + NewDeb;
Rename(Itm->DestFile, OldDebFile);
Itm->DestFile = OldDebFile;
+ Res.Filename = Itm->DestFile;
+ URIDone(Res);
return true;
}
Itm->DestFile = OldDebFile;
+
return false;
}
@@ -118,7 +126,7 @@ public:
if (pkgInitConfig(*_config) == false ||
pkgInitSystem(*_config,_system) == false)
{
- std::cerr << "E: Could not initialize the system/configuration." << std::endl;
+ std::cerr << "[Debdelta] E: Could not initialize the system/configuration." << std::endl;
_error->DumpErrors();
return 100;
}