aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-22 22:24:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-22 22:24:11 +0000
commitb2a3de9c4942c25e1158624840b0bf8277d9fcef (patch)
tree9c5d7db74b8b85d67b5ebefb7c68277ece7f1c6b
parentcc414d7a78a9d20617048199ca1f64733e07e604 (diff)
downloadpaludis-b2a3de9c4942c25e1158624840b0bf8277d9fcef.tar.gz
paludis-b2a3de9c4942c25e1158624840b0bf8277d9fcef.tar.xz
Support a mirrors.conf file, with the same format as thirdpartymirrors, in the config directory
-rw-r--r--paludis/default_config.cc28
-rw-r--r--paludis/default_config.hh14
-rw-r--r--paludis/default_environment.cc12
-rw-r--r--paludis/default_environment.hh4
-rw-r--r--paludis/environment.hh15
-rw-r--r--paludis/portage_repository.cc15
-rw-r--r--paludis/test_environment.hh13
7 files changed, 101 insertions, 0 deletions
diff --git a/paludis/default_config.cc b/paludis/default_config.cc
index 2afdb88..51239da 100644
--- a/paludis/default_config.cc
+++ b/paludis/default_config.cc
@@ -335,6 +335,34 @@ DefaultConfig::DefaultConfig() :
"contain an entry in the form '* keyword')");
}
+ /* mirrors */
+ {
+ std::list<FSEntry> files;
+ files.push_back(config_dir / "mirrors.conf");
+
+ for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
+ file != file_end ; ++file)
+ {
+ Context local_context("When reading mirrors file '" + stringify(*file) + "':");
+
+ if (! file->is_regular_file())
+ continue;
+
+ LineConfigFile f(*file);
+ for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> m;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(m));
+ if (m.size() < 2)
+ continue;
+ for (std::vector<std::string>::const_iterator mm(next(m.begin())),
+ mm_end(m.end()) ; mm != mm_end ; ++mm)
+ _mirrors.insert(std::make_pair(m.at(0), *mm));
+ }
+ }
+ }
+
_bashrc_files = stringify(config_dir / "bashrc");
}
diff --git a/paludis/default_config.hh b/paludis/default_config.hh
index 25feafa..107bf03 100644
--- a/paludis/default_config.hh
+++ b/paludis/default_config.hh
@@ -183,6 +183,8 @@ namespace paludis
std::vector<std::pair<UseFlagName, UseFlagState> > _default_use;
+ std::multimap<std::string, std::string> _mirrors;
+
public:
/**
* Set config suffix. Must be called before we do anything, or not
@@ -501,6 +503,18 @@ namespace paludis
{
return _config_dir;
}
+
+ typedef std::multimap<std::string, std::string>::const_iterator MirrorIterator;
+
+ MirrorIterator begin_mirrors(const std::string & m) const
+ {
+ return _mirrors.lower_bound(m);
+ }
+
+ MirrorIterator end_mirrors(const std::string & m) const
+ {
+ return _mirrors.upper_bound(m);
+ }
};
}
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index 5217472..8dc8245 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -491,3 +491,15 @@ DefaultEnvironment::local_package_set(const std::string & s) const
return DepAtom::Pointer(0);
}
+DefaultEnvironment::MirrorIterator
+DefaultEnvironment::begin_mirrors(const std::string & mirror) const
+{
+ return DefaultConfig::get_instance()->begin_mirrors(mirror);
+}
+
+DefaultEnvironment::MirrorIterator
+DefaultEnvironment::end_mirrors(const std::string & mirror) const
+{
+ return DefaultConfig::get_instance()->end_mirrors(mirror);
+}
+
diff --git a/paludis/default_environment.hh b/paludis/default_environment.hh
index 510c5d5..c40efc1 100644
--- a/paludis/default_environment.hh
+++ b/paludis/default_environment.hh
@@ -72,6 +72,10 @@ namespace paludis
const std::string & prefix, const PackageDatabaseEntry *) const;
virtual void perform_hook(const Hook & hook) const;
+
+ virtual MirrorIterator begin_mirrors(const std::string & mirror) const;
+
+ virtual MirrorIterator end_mirrors(const std::string & mirror) const;
};
}
#endif
diff --git a/paludis/environment.hh b/paludis/environment.hh
index bb7ff06..0d06040 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -183,6 +183,21 @@ namespace paludis
ProvideMapIterator end_provide_map() const;
/**
+ * Iterator over named mirror entries.
+ */
+ typedef std::multimap<std::string, std::string>::const_iterator MirrorIterator;
+
+ /**
+ * Iterator to the start of our mirrors.
+ */
+ virtual MirrorIterator begin_mirrors(const std::string & mirror) const = 0;
+
+ /**
+ * Iterator to past the end of our mirrors.
+ */
+ virtual MirrorIterator end_mirrors(const std::string & mirror) const = 0;
+
+ /**
* Fetch a named package set.
*/
DepAtom::Pointer package_set(const std::string &) const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index dfe523b..9098bcb 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -1393,13 +1393,22 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
{
std::string mirror((*ff)->text().substr(9));
std::string::size_type q(mirror.find('/'));
+
if (std::string::npos == q)
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' since SRC_URI is broken");
+
if (! is_mirror(mirror.substr(0, q)))
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' since SRC_URI references unknown mirror:// '" +
mirror.substr(0, q) + "'");
+
+ for (Environment::MirrorIterator
+ m(_imp->env->begin_mirrors(mirror.substr(0, q))),
+ m_end(_imp->env->end_mirrors(mirror.substr(0, q))) ;
+ m != m_end ; ++m)
+ flat_src_uri.append(m->second + "/" + mirror.substr(q + 1) + " ");
+
for (std::list<std::string>::iterator
m(_imp->mirrors.find(mirror.substr(0, q))->second.begin()),
m_end(_imp->mirrors.find(mirror.substr(0, q))->second.end()) ;
@@ -1414,6 +1423,12 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
/// \todo don't hardcode
if (is_mirror("gentoo") && ! no_mirror)
{
+ for (Environment::MirrorIterator
+ m(_imp->env->begin_mirrors("gentoo")),
+ m_end(_imp->env->end_mirrors("gentoo")) ;
+ m != m_end ; ++m)
+ flat_src_uri.append(m->second + "/" + (*ff)->text().substr(p + 1) + " ");
+
for (std::list<std::string>::iterator
m(_imp->mirrors.find("gentoo")->second.begin()),
m_end(_imp->mirrors.find("gentoo")->second.end()) ;
diff --git a/paludis/test_environment.hh b/paludis/test_environment.hh
index 0ae5913..87a9fa0 100644
--- a/paludis/test_environment.hh
+++ b/paludis/test_environment.hh
@@ -40,6 +40,9 @@ namespace paludis
*/
class TestEnvironment : public Environment
{
+ private:
+ std::multimap<std::string, std::string> _mirrors;
+
public:
/**
* Constructor.
@@ -80,6 +83,16 @@ namespace paludis
virtual void perform_hook(const Hook &) const
{
}
+
+ virtual MirrorIterator begin_mirrors(const std::string &) const
+ {
+ return _mirrors.end();
+ }
+
+ virtual MirrorIterator end_mirrors(const std::string &) const
+ {
+ return _mirrors.end();
+ }
};
}