~racb/ubuntu/quantal/apt/by_hash

« back to all changes in this revision

Viewing changes to apt-pkg/aptconfiguration.cc

  • Committer: Package Import Robot
  • Author(s): Steve Langasek, Michael Vogt, Steve Langasek
  • Date: 2012-06-11 22:36:16 UTC
  • mfrom: (1.4.47 sid)
  • Revision ID: package-import@ubuntu.com-20120611223616-1cctfc7qrxrx4vcu
Tags: 0.9.6ubuntu1
[ Michael Vogt ]
* merged from Debian, remaining changes:
  - use ubuntu keyring and ubuntu archive keyring in apt-key
  - run update-apt-xapian-index in apt.cron
  - support apt-key net-update and verify keys against master-keyring
  - run apt-key net-update in cron.daily
  - different example sources.list
  - APT::pkgPackageManager::MaxLoopCount set to 5000
  - apport pkgfailure handling
  - ubuntu changelog download handling
  - patch for apt cross-building, see http://bugs.debian.org/666772

[ Steve Langasek ]
* Drop upgrade handling for obsolete conffile /etc/apt/apt.conf.d/01ubuntu,
  removed in previous LTS.
* prepare-release: declare the packages needed as source build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        _config->CndSet("Acquire::CompressionTypes::gz","gzip");
48
48
 
49
49
        setDefaultConfigurationForCompressors();
 
50
        std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
50
51
 
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)
61
62
                        continue;
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)
64
66
                        continue;
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)
70
 
                                continue;
71
 
                }
 
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)
 
71
                        if (c->Name == app)
 
72
                                break;
 
73
                if (c == compressors.end())
 
74
                        continue;
72
75
                types.push_back(*o);
73
76
        }
74
77
 
84
87
                if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
85
88
                        continue;
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)
91
 
                                continue;
92
 
                }
 
90
                std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
 
91
                for (; c != compressors.end(); ++c)
 
92
                        if (c->Name == Types->Value)
 
93
                                break;
 
94
                if (c == compressors.end())
 
95
                        continue;
93
96
                types.push_back(Types->Tag);
94
97
        }
95
98
 
141
144
        if (D != 0) {
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") {
235
 
                        codes = environment;
236
 
                } else if (forceLang != "none")
237
 
                        codes.push_back(forceLang);
238
 
                else //if (forceLang == "none")
239
 
                        builtin.clear();
240
 
                allCodes = codes;
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") {
 
238
                        codes.clear();
 
239
                        allCodes.clear();
 
240
                        allCodes.push_back("none");
 
241
                } else {
 
242
                        if (forceLang == "environment")
 
243
                                codes = environment;
 
244
                        else
 
245
                                codes.push_back(forceLang);
 
246
                        allCodes = codes;
 
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);
 
251
                }
245
252
                if (All == true)
246
253
                        return allCodes;
247
254
                else
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!");
381
388
                        _exit(100);
382
389
                }
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())
 
404
                                                        archs.push_back(a);
396
405
                                        }
397
406
                                        arch = strtok(NULL, " ");
398
407
                                }
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");
 
450
                }
 
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");
 
454
                }
 
455
        } else {
 
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");
 
460
                }
 
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");
 
464
                }
 
465
        }
436
466
}
437
467
                                                                        /*}}}*/
438
468
// getCompressors - Return Vector of usbale compressors                 /*{{{*/
451
481
 
452
482
        setDefaultConfigurationForCompressors();
453
483
 
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));
 
487
#ifdef HAVE_ZLIB
 
488
        else
 
489
                compressors.push_back(Compressor("gzip",".gz","false", NULL, NULL, 2));
 
490
#endif
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));
 
493
#ifdef HAVE_BZ2
 
494
        else
 
495
                compressors.push_back(Compressor("bzip2",".bz2","false", NULL, NULL, 3));
 
496
#endif
 
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));
463
501
 
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);