aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-24 15:59:57 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-24 15:59:57 +0000
commit112974bc8dba2f1866a61b9224cb47cc2298086b (patch)
treeb643453bffa836f578a7234419990ecea5e6fe6c
parent8f02582ecaff0a2dbf91b1d863e15be800c336e4 (diff)
downloadpaludis-112974bc8dba2f1866a61b9224cb47cc2298086b.tar.gz
paludis-112974bc8dba2f1866a61b9224cb47cc2298086b.tar.xz
Check for unrecognised mirrors
-rw-r--r--paludis/fake_repository.cc6
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc31
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/qa/src_uri_check.cc20
-rw-r--r--paludis/repository.hh13
6 files changed, 70 insertions, 4 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index 4cf560d..f95cac7 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -205,3 +205,9 @@ FakeRepository::do_is_licence(const std::string &) const
return false;
}
+bool
+FakeRepository::do_is_mirror(const std::string &) const
+{
+ return false;
+}
+
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index f036fb9..93a63df 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -77,6 +77,8 @@ namespace paludis
virtual bool do_is_licence(const std::string &) const;
+ virtual bool do_is_mirror(const std::string &) const;
+
public:
/**
* Constructor.
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 5e3fca5..2b83b5b 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -67,6 +67,8 @@ typedef MakeHashedSet<UseFlagName>::Type UseMaskSet;
typedef MakeHashedSet<UseFlagName>::Type UseFlagSet;
+typedef MakeHashedSet<std::string>::Type MirrorSet;
+
typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>, VersionMetadata::Pointer>::Type MetadataMap;
namespace paludis
@@ -134,6 +136,11 @@ namespace paludis
/// Do we have arch_list?
mutable bool has_arch_list;
+ /// Do we have mirrors?
+ mutable bool has_mirrors;
+
+ mutable MirrorSet mirrors;
+
/// Constructor.
Implementation(const PackageDatabase * const d, const FSEntry & l, const FSEntry & p,
const FSEntry & c);
@@ -155,7 +162,8 @@ Implementation<PortageRepository>::Implementation(const PackageDatabase * const
has_category_names(false),
has_repo_mask(false),
has_profile(false),
- has_arch_list(false)
+ has_arch_list(false),
+ has_mirrors(false)
{
}
@@ -822,3 +830,24 @@ PortageRepository::do_is_licence(const std::string & s) const
return l.exists() && l.is_regular_file();
}
+bool
+PortageRepository::do_is_mirror(const std::string & s) const
+{
+ if (! _implementation->has_mirrors)
+ {
+ static Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n");
+
+ LineConfigFile mirrors(_implementation->location / "profiles" / "thirdpartymirrors");
+ for (LineConfigFile::Iterator line(mirrors.begin()) ; line != mirrors.end() ; ++line)
+ {
+ std::vector<std::string> entries;
+ tokeniser.tokenise(*line, std::back_inserter(entries));
+ if (! entries.empty())
+ _implementation->mirrors.insert(entries.at(0));
+ }
+ _implementation->has_mirrors = true;
+ }
+
+ return _implementation->mirrors.end() != _implementation->mirrors.find(s);
+}
+
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 850e27d..1a3f12f 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -88,6 +88,8 @@ namespace paludis
virtual bool do_is_licence(const std::string &) const;
+ virtual bool do_is_mirror(const std::string &) const;
+
public:
/**
* Constructor.
diff --git a/paludis/qa/src_uri_check.cc b/paludis/qa/src_uri_check.cc
index 24924e1..43cab8f 100644
--- a/paludis/qa/src_uri_check.cc
+++ b/paludis/qa/src_uri_check.cc
@@ -32,10 +32,12 @@ namespace
{
CheckResult & result;
bool fetch_restrict;
+ const Environment * const env;
- Checker(CheckResult & rr, bool f) :
+ Checker(CheckResult & rr, bool f, const Environment * const e) :
result(rr),
- fetch_restrict(f)
+ fetch_restrict(f),
+ env(e)
{
}
@@ -63,6 +65,18 @@ namespace
(std::string::npos != a->text().find("alpha.gnu.org")) ||
(std::string::npos != a->text().find("geocities.com")))
result << Message(qal_major, "Unreliable host for '" + a->text() + "'");
+
+ else
+ {
+ if (0 == a->text().compare(0, 9, "mirror://"))
+ {
+ std::string mirror_host(a->text().substr(9));
+ mirror_host.erase(mirror_host.find('/'));
+ if (! env->package_database()->fetch_repository(
+ env->package_database()->favourite_repository())->is_mirror(mirror_host))
+ result << Message(qal_major, "Unknown mirror for '" + a->text() + "'");
+ }
+ }
}
void visit(const AllDepAtom * const a)
@@ -131,7 +145,7 @@ SrcUriCheck::operator() (const EbuildCheckData & e) const
std::inserter(restricts, restricts.begin()));
bool fetch_restrict(restricts.end() != restricts.find("fetch"));
- Checker checker(result, fetch_restrict);
+ Checker checker(result, fetch_restrict, e.get<ecd_environment>());
src_uri_parts->accept(&checker);
}
catch (const DepStringError & e)
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 5367df5..d3c7748 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -143,6 +143,11 @@ namespace paludis
*/
virtual bool do_is_licence(const std::string &) const = 0;
+ /**
+ * Override in descendents: is this a mirror?
+ */
+ virtual bool do_is_mirror(const std::string &) const = 0;
+
public:
/**
* Destructor.
@@ -349,6 +354,14 @@ namespace paludis
{
return do_is_licence(u);
}
+
+ /**
+ * Query whether the specified item is a mirror.
+ */
+ bool is_mirror(const std::string & u) const
+ {
+ return do_is_mirror(u);
+ }
};
/**