diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-03-02 19:57:34 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-03-02 19:58:05 +0800 |
commit | de95eb255b0fbf5b4ec0e60d95967e7cac13637c (patch) | |
tree | ecfa5c1bd74f4d6bbf4e8618f08a3b5b9bfe77a9 | |
parent | ebf3cbb4b101b50cba20931fa822486510a2a6d9 (diff) | |
download | aptitude-de95eb255b0fbf5b4ec0e60d95967e7cac13637c.tar.gz |
Move code for reading Top Sections to apt.cc
-rw-r--r-- | src/generic/apt/apt.cc | 24 | ||||
-rw-r--r-- | src/generic/apt/apt.h | 8 | ||||
-rw-r--r-- | src/pkg_grouppolicy.cc | 10 |
3 files changed, 34 insertions, 8 deletions
diff --git a/src/generic/apt/apt.cc b/src/generic/apt/apt.cc index c535dcfe..e1167e93 100644 --- a/src/generic/apt/apt.cc +++ b/src/generic/apt/apt.cc @@ -1309,5 +1309,29 @@ namespace aptitude return true; } + + const std::vector<std::string> get_top_sections(const bool cached) + { + static std::vector<std::string> top_sections; + + if(top_sections.empty() == false) + { + if(cached == true) + return top_sections; + else + top_sections.clear(); + } + + top_sections = aptcfg->FindVector(PACKAGE "::Sections::Top-Sections"); + if(top_sections.empty() == true) + { + top_sections.push_back("main"); + top_sections.push_back("contrib"); + top_sections.push_back("non-free"); + top_sections.push_back("non-US"); + } + + return top_sections; + } } } diff --git a/src/generic/apt/apt.h b/src/generic/apt/apt.h index fc6fb64a..a052fb7e 100644 --- a/src/generic/apt/apt.h +++ b/src/generic/apt/apt.h @@ -29,6 +29,7 @@ #include <boost/shared_ptr.hpp> #include <utility> +#include <vector> /** \brief Central repository for apt structures * @@ -436,6 +437,13 @@ namespace aptitude * version aren't considered; should they be? */ bool is_full_replacement(const pkgCache::DepIterator &dep); + + /** \return an ordered vector of the Top Sections + * + * From the configuration item Aptitude::Sections::Top-Sections + * or a builtin list of defaults. + */ + const std::vector<std::string> get_top_sections(const bool cached=true); } } diff --git a/src/pkg_grouppolicy.cc b/src/pkg_grouppolicy.cc index 50343a4d..fa69c9ae 100644 --- a/src/pkg_grouppolicy.cc +++ b/src/pkg_grouppolicy.cc @@ -360,14 +360,8 @@ void pkg_grouppolicy_section::add_package(const pkgCache::PkgIterator &pkg, int order = -1; { // get an ordered list of top-sections - vector<string> topSections = aptcfg->FindVector(PACKAGE "::Sections::Top-Sections"); - if (topSections.empty()) { - // provide some sensible defaults - topSections.push_back("main"); - topSections.push_back("contrib"); - topSections.push_back("non-free"); - topSections.push_back("non-US"); - } + const vector<string> topSections = aptitude::apt::get_top_sections(); + // get the order of the top-section (the lower the number, // the higher the priority) for (size_t i = 0; i < topSections.size(); ++i) { |