summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.cc
diff options
context:
space:
mode:
authorMatt Zimmerman <matt.zimmerman@canonical.com>2004-11-15 21:16:15 +0000
committerMatt Zimmerman <matt.zimmerman@canonical.com>2004-11-15 21:16:15 +0000
commitdebc84b22e6e841119036af7aee91db2b0989ab9 (patch)
treec0ac4f4466ab705a5d9f308e27ddf3efbfd17103 /apt-pkg/acquire-item.cc
parent50f349561d0f4f4403535ff60de0b6c8d8043f46 (diff)
Packages.bz2 support from Michael Vogt
First tries Packages.bz2, and if that fails, falls back to Packages.gz
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r--apt-pkg/acquire-item.cc32
1 files changed, 29 insertions, 3 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 27e98283f..bf19290c6 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -144,7 +144,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
DestFile += URItoFileName(URI);
// Create the item
- Desc.URI = URI + ".gz";
+ Desc.URI = URI + ".bz2";
Desc.Description = URIDesc;
Desc.Owner = this;
Desc.ShortDesc = ShortDesc;
@@ -167,6 +167,21 @@ string pkgAcqIndex::Custom600Headers()
return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
}
/*}}}*/
+
+void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+{
+ // no .bz2 found, retry with .gz
+ if(Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1) == "bz2") {
+ Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz";
+ QueueURI(Desc);
+ return;
+ }
+
+
+ Item::Failed(Message,Cnf);
+}
+
+
// AcqIndex::Done - Finished a fetch /*{{{*/
// ---------------------------------------------------------------------
/* This goes through a number of states.. On the initial fetch the
@@ -234,11 +249,22 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
else
Local = true;
+ string compExt = Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1);
+ char *decompProg;
+ if(compExt == "bz2")
+ decompProg = "bzip2";
+ else if(compExt == ".gz")
+ decompProg = "gzip";
+ else {
+ _error->Error("Unsupported extension: %s", compExt.c_str());
+ return;
+ }
+
Decompression = true;
DestFile += ".decomp";
- Desc.URI = "gzip:" + FileName;
+ Desc.URI = string(decompProg) + ":" + FileName;
QueueURI(Desc);
- Mode = "gzip";
+ Mode = decompProg;
}
/*}}}*/