47
47
_config->CndSet("Acquire::CompressionTypes::gz","gzip");
49
49
setDefaultConfigurationForCompressors();
50
std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
51
52
// accept non-list order as override setting for config settings on commandline
52
53
std::string const overrideOrder = _config->Find("Acquire::CompressionTypes::Order","");
60
61
if ((*o).empty() == true)
62
63
// ignore types we have no method ready to use
63
if (_config->Exists(std::string("Acquire::CompressionTypes::").append(*o)) == false)
64
std::string const method = std::string("Acquire::CompressionTypes::").append(*o);
65
if (_config->Exists(method) == false)
65
67
// ignore types we have no app ready to use
66
std::string const appsetting = std::string("Dir::Bin::").append(*o);
67
if (_config->Exists(appsetting) == true) {
68
std::string const app = _config->FindFile(appsetting.c_str(), "");
69
if (app.empty() == false && FileExists(app) == false)
68
std::string const app = _config->Find(method);
69
std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
70
for (; c != compressors.end(); ++c)
73
if (c == compressors.end())
72
75
types.push_back(*o);
84
87
if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
86
89
// ignore types we have no app ready to use
87
std::string const appsetting = std::string("Dir::Bin::").append(Types->Value);
88
if (appsetting.empty() == false && _config->Exists(appsetting) == true) {
89
std::string const app = _config->FindFile(appsetting.c_str(), "");
90
if (app.empty() == false && FileExists(app) == false)
90
std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
91
for (; c != compressors.end(); ++c)
92
if (c->Name == Types->Value)
94
if (c == compressors.end())
93
96
types.push_back(Types->Tag);
142
145
builtin.push_back("none");
143
146
for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
144
string const name = Ent->d_name;
147
string const name = SubstVar(Ent->d_name, "%5f", "_");
145
148
size_t const foundDash = name.rfind("-");
146
149
size_t const foundUnderscore = name.rfind("_", foundDash);
147
150
if (foundDash == string::npos || foundUnderscore == string::npos ||
231
234
// override the configuration settings vector of languages.
232
235
string const forceLang = _config->Find("Acquire::Languages","");
233
236
if (forceLang.empty() == false) {
234
if (forceLang == "environment") {
236
} else if (forceLang != "none")
237
codes.push_back(forceLang);
238
else //if (forceLang == "none")
241
for (std::vector<string>::const_iterator b = builtin.begin();
242
b != builtin.end(); ++b)
243
if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
244
allCodes.push_back(*b);
237
if (forceLang == "none") {
240
allCodes.push_back("none");
242
if (forceLang == "environment")
245
codes.push_back(forceLang);
247
for (std::vector<string>::const_iterator b = builtin.begin();
248
b != builtin.end(); ++b)
249
if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
250
allCodes.push_back(*b);
376
383
dup2(nullfd, STDIN_FILENO);
377
384
dup2(external[1], STDOUT_FILENO);
378
385
dup2(nullfd, STDERR_FILENO);
379
execv(Args[0], (char**) &Args[0]);
386
execvp(Args[0], (char**) &Args[0]);
380
387
_error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!");
392
399
if (arch[0] != '\0') {
393
400
char const* archend = arch;
394
401
for (; isspace(*archend) == 0 && *archend != '\0'; ++archend);
395
archs.push_back(string(arch, (archend - arch)));
402
string a(arch, (archend - arch));
403
if (std::find(archs.begin(), archs.end(), a) == archs.end())
397
406
arch = strtok(NULL, " ");
430
439
// setDefaultConfigurationForCompressors /*{{{*/
431
440
void Configuration::setDefaultConfigurationForCompressors() {
432
441
// Set default application paths to check for optional compression types
433
_config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
442
_config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
434
443
_config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
435
_config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
444
if (FileExists(_config->FindFile("Dir::Bin::xz")) == true) {
445
_config->Clear("Dir::Bin::lzma");
446
_config->Set("APT::Compressor::lzma::Binary", "xz");
447
if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
448
_config->Set("APT::Compressor::lzma::CompressArg::", "--format=lzma");
449
_config->Set("APT::Compressor::lzma::CompressArg::", "-9");
451
if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
452
_config->Set("APT::Compressor::lzma::UncompressArg::", "--format=lzma");
453
_config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
456
_config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
457
if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
458
_config->Set("APT::Compressor::lzma::CompressArg::", "--suffix=");
459
_config->Set("APT::Compressor::lzma::CompressArg::", "-9");
461
if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
462
_config->Set("APT::Compressor::lzma::UncompressArg::", "--suffix=");
463
_config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
438
468
// getCompressors - Return Vector of usbale compressors /*{{{*/
452
482
setDefaultConfigurationForCompressors();
454
compressors.push_back(Compressor(".", "", "", "", "", 1));
484
compressors.push_back(Compressor(".", "", "", NULL, NULL, 1));
455
485
if (_config->Exists("Dir::Bin::gzip") == false || FileExists(_config->FindFile("Dir::Bin::gzip")) == true)
456
486
compressors.push_back(Compressor("gzip",".gz","gzip","-9n","-d",2));
489
compressors.push_back(Compressor("gzip",".gz","false", NULL, NULL, 2));
457
491
if (_config->Exists("Dir::Bin::bzip2") == false || FileExists(_config->FindFile("Dir::Bin::bzip2")) == true)
458
492
compressors.push_back(Compressor("bzip2",".bz2","bzip2","-9","-d",3));
495
compressors.push_back(Compressor("bzip2",".bz2","false", NULL, NULL, 3));
497
if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
498
compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
459
499
if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
460
compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",4));
461
if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
462
compressors.push_back(Compressor("xz",".xz","xz","-6","-d",5));
500
compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5));
464
502
std::vector<std::string> const comp = _config->FindVector("APT::Compressor");
465
503
for (std::vector<std::string>::const_iterator c = comp.begin();
492
530
char const *binary,
493
531
char const *compressArg, char const *uncompressArg,
494
532
unsigned short const cost) {
495
std::string const config = std::string("APT:Compressor::").append(name).append("::");
533
std::string const config = std::string("APT::Compressor::").append(name).append("::");
496
534
Name = _config->Find(std::string(config).append("Name"), name);
497
535
Extension = _config->Find(std::string(config).append("Extension"), extension);
498
536
Binary = _config->Find(std::string(config).append("Binary"), binary);