- 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);
+ Configuration::Item const *Opts = _config->Tree("Acquire::CompressionTypes");
+ if (Opts != 0)
+ Opts = Opts->Child;
+
+ const char dirBin[] = "Dir::Bin::";
+ for (; Opts != 0; Opts = Opts->Next)
+ {
+ if (Opts->Tag.empty() == true || Opts->Value.empty() == true)
+ continue;
+
+ // jump over all already checked compression types
+ const unsigned int nameLen = Desc.URI.size() - Opts->Tag.size();
+ if(Desc.URI.substr(nameLen) != Opts->Tag || Opts->Next == 0)
+ continue;
+
+ // check if we need an external binary for this compression type
+ const string bin = _config->FindFile(string(dirBin).append(Opts->Next->Value).c_str(),"");
+ if (bin != "" && !FileExists(bin))
+ continue;
+
+ // retry with the next extension
+ Desc.URI = Desc.URI.substr(0, nameLen) + Opts->Next->Tag;
+
+ new pkgAcqIndex(Owner, RealURI, Desc.Description, Desc.ShortDesc,
+ ExpectedHash, string(".").append(Opts->Next->Tag));