summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r--apt-pkg/acquire-item.cc73
1 files changed, 39 insertions, 34 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 39ae327cb..94341c81a 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -15,6 +15,7 @@
// Include Files /*{{{*/
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/vendorlist.h>
#include <apt-pkg/error.h>
@@ -551,13 +552,14 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
if(comprExt.empty())
{
// autoselect the compression method
- if(FileExists("/bin/bzip2"))
- CompressionExtension = ".bz2";
- else
- CompressionExtension = ".gz";
- } else {
- CompressionExtension = (comprExt == "plain" ? "" : comprExt);
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
+ if (types.empty() == true)
+ comprExt = "plain";
+ else
+ comprExt = "." + types[0];
}
+ CompressionExtension = ((comprExt == "plain" || comprExt == ".") ? "" : comprExt);
+
Desc.URI = URI + CompressionExtension;
Desc.Description = URIDesc;
@@ -584,28 +586,31 @@ string pkgAcqIndex::Custom600Headers()
/*}}}*/
void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/
{
- bool descChanged = false;
- // no .bz2 found, retry with .gz
- if(Desc.URI.substr(Desc.URI.size()-3) == "bz2") {
- Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz";
-
- new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc,
- ExpectedHash, string(".gz"));
- descChanged = true;
- }
- // no .gz found, retry with uncompressed
- else if(Desc.URI.substr(Desc.URI.size()-2) == "gz") {
- Desc.URI = Desc.URI.substr(0,Desc.URI.size()-2);
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc,
- ExpectedHash, string("plain"));
- descChanged = true;
- }
- if (descChanged) {
- Status = StatDone;
- Complete = false;
- Dequeue();
- return;
+ for (std::vector<std::string>::const_iterator t = types.begin();
+ t != types.end(); t++)
+ {
+ // jump over all already tried compression types
+ const unsigned int nameLen = Desc.URI.size() - (*t).size();
+ if(Desc.URI.substr(nameLen) != *t)
+ continue;
+
+ // we want to try it with the next extension
+ t++;
+
+ if (t != types.end())
+ {
+ Desc.URI = Desc.URI.substr(0, nameLen) + *t;
+
+ new pkgAcqIndex(Owner, RealURI, Desc.Description, Desc.ShortDesc,
+ ExpectedHash, string(".").append(*t));
+
+ Status = StatDone;
+ Complete = false;
+ Dequeue();
+ return;
+ }
}
// on decompression failure, remove bad versions in partial/
@@ -698,11 +703,11 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
Local = true;
string compExt = flExtension(flNotDir(URI(Desc.URI).Path));
- const char *decompProg;
- if(compExt == "bz2")
- decompProg = "bzip2";
- else if(compExt == "gz")
- decompProg = "gzip";
+ string decompProg;
+
+ // get the binary name for your used compression type
+ decompProg = _config->Find(string("Acquire::CompressionTypes::").append(compExt),"");
+ if(decompProg.empty() == false);
// flExtensions returns the full name if no extension is found
// this is why we have this complicated compare operation here
// FIMXE: add a new flJustExtension() that return "" if no
@@ -717,9 +722,9 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
Decompression = true;
DestFile += ".decomp";
- Desc.URI = string(decompProg) + ":" + FileName;
+ Desc.URI = decompProg + ":" + FileName;
QueueURI(Desc);
- Mode = decompProg;
+ Mode = decompProg.c_str();
}
/*}}}*/
// AcqIndexTrans::pkgAcqIndexTrans - Constructor /*{{{*/