--- apt-0.6.46.3/apt-pkg/acquire-item.cc 2006-07-27 01:30:51.000000000 +0300 +++ apt-0.6.46.3-compression_priority/apt-pkg/acquire-item.cc 2006-11-14 09:30:56.000000000 +0200 @@ -570,11 +570,23 @@ if(comprExt.empty()) { - // autoselect the compression method - if(FileExists("/bin/bzip2")) - CompressionExtension = ".bz2"; - else - CompressionExtension = ".gz"; + // get first element of Acquire::CompressionTypes + Configuration::Item const *Cpr = _config->Tree("Acquire::CompressionTypes"); + if (Cpr != 0 && Cpr->Child != 0) + { + CompressionExtension = Cpr->Child->Value; + } else { + // old behaviour: autoselect compression method + if(FileExists("/bin/bzip2")) + { + _config->Set("Acquire::CompressionTypes::", ".bz2"); + CompressionExtension = ".bz2"; + } else { + CompressionExtension = ".gz"; + } + // always fallback to .gz + _config->Set("Acquire::CompressionTypes::", ".gz"); + } } else { CompressionExtension = comprExt; } @@ -605,19 +617,31 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { - // 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"; - - // retry with a gzip one - new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, - ExpectedMD5, string(".gz")); + Configuration::Item const *Opts = _config->Tree("Acquire::CompressionTypes"); + string tmp, ext; + + if (Opts == 0 || Opts->Child == 0) + Item::Failed(Message,Cnf); + Opts = Opts->Child; + + // find the current extension from list and try the next one + for (; Opts != 0; Opts = Opts->Next) + { + tmp = Opts->Value; + if(Desc.URI.substr(Desc.URI.size()-tmp.size()) != tmp || Opts->Next == 0) + continue; + + // retry with the next extension + ext = Opts->Next->Value; + Desc.URI = Desc.URI.substr(0,Desc.URI.size()-tmp.size()) + ext; + + new pkgAcqIndex(Owner, RealURI, Desc.Description, Desc.ShortDesc, + ExpectedMD5, ext); Status = StatDone; Complete = false; Dequeue(); return; } - Item::Failed(Message,Cnf); }