aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-30 20:49:15 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-30 20:49:15 +0000
commite359e585c2538b91910ccdeef282d3ca962ac820 (patch)
tree700dcd36a38f2bfb0b8c282f424364c6d1101565
parent82186ea6ebe1ae247fc10ee3fa07df723c4a0f73 (diff)
downloadpaludis-e359e585c2538b91910ccdeef282d3ca962ac820.tar.gz
paludis-e359e585c2538b91910ccdeef282d3ca962ac820.tar.xz
More PortageEnvironment work
-rw-r--r--paludis/environments/portage/portage_environment.cc39
-rw-r--r--paludis/environments/portage/portage_environment.hh2
2 files changed, 39 insertions, 2 deletions
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 992249d..6edaba5 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -33,6 +33,7 @@
#include <tr1/functional>
#include <functional>
#include <set>
+#include <map>
#include <vector>
using namespace paludis;
@@ -60,6 +61,7 @@ namespace paludis
std::set<std::string> use_with_expands;
std::set<std::string> use_expand;
std::set<std::string> accept_keywords;
+ std::multimap<std::string, std::string> mirrors;
PackageUse package_use;
PackageKeywords package_keywords;
@@ -207,6 +209,31 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
_load_lined_file(_imp->conf_dir / "portage" / "package.mask", std::back_inserter(_imp->package_mask));
_load_lined_file(_imp->conf_dir / "portage" / "package.unmask", std::back_inserter(_imp->package_unmask));
+
+ /* mirrors */
+ std::list<std::string> gentoo_mirrors;
+ WhitespaceTokeniser::get_instance()->tokenise(_imp->vars->get("GENTOO_MIRRORS"),
+ std::back_inserter(gentoo_mirrors));
+ for (std::list<std::string>::const_iterator m(gentoo_mirrors.begin()), m_end(gentoo_mirrors.end()) ;
+ m != m_end ; ++m)
+ _imp->mirrors.insert(std::make_pair("*", *m));
+
+ if ((_imp->conf_dir / "portage" / "mirrors").exists())
+ {
+ LineConfigFile mirrors(_imp->conf_dir / "portage" / "mirrors");
+ for (LineConfigFile::Iterator line(mirrors.begin()), line_end(mirrors.end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+ if (tokens.size() < 2)
+ continue;
+
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ _imp->mirrors.insert(std::make_pair(tokens.at(0), *t));
+ }
+ }
}
template<typename I_>
@@ -584,3 +611,15 @@ PortageEnvironment::bashrc_files() const
stringify(FSEntry(LIBEXECDIR) / "paludis" / "environments" / "portage" / "bashrc");
}
+PortageEnvironment::MirrorIterator
+PortageEnvironment::begin_mirrors(const std::string & m) const
+{
+ return MirrorIterator(_imp->mirrors.lower_bound(m));
+}
+
+PortageEnvironment::MirrorIterator
+PortageEnvironment::end_mirrors(const std::string & m) const
+{
+ return MirrorIterator(_imp->mirrors.upper_bound(m));
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index d653aeb..e567fea 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -82,13 +82,11 @@ namespace paludis
virtual void set_paludis_command(const std::string &);
-#if 0
virtual MirrorIterator begin_mirrors(const std::string & mirror) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual MirrorIterator end_mirrors(const std::string & mirror) const
PALUDIS_ATTRIBUTE((warn_unused_result));
-#endif
virtual FSEntry root() const
PALUDIS_ATTRIBUTE((warn_unused_result));