aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-27 22:11:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-27 22:11:20 +0100
commit6ded7008469640d2284022deff1e39c3c792f564 (patch)
tree7ef93d9290eded8df32812c872f819f65b2cb35c
parentafc70958528f85092b4278bc09dcbc8584221a05 (diff)
downloadpaludis-6ded7008469640d2284022deff1e39c3c792f564.tar.gz
paludis-6ded7008469640d2284022deff1e39c3c792f564.tar.xz
Per distribution repository blacklists
-rw-r--r--paludis/Makefile.am.m45
-rw-r--r--paludis/distributions/exherbo/Makefile.am2
-rw-r--r--paludis/distributions/exherbo/repository_blacklist.conf2
-rw-r--r--paludis/distributions/gentoo/Makefile.am2
-rw-r--r--paludis/distributions/gentoo/repository_blacklist.conf0
-rw-r--r--paludis/repository.cc59
6 files changed, 43 insertions, 27 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 2066fc1..ebcee0d 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -81,7 +81,7 @@ DEFS= \
-DPYTHONINSTALLDIR=\"$(PYTHON_INSTALL_DIR)\"
EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \
testscriptlist srlist srcleanlist selist secleanlist \
- repository_blacklist.txt hooker.bash \
+ hooker.bash \
stripper_TEST_binary.cc
SUBDIRS = distributions fetchers syncers util selinux . repositories environments args
BUILT_SOURCES = srcleanlist secleanlist
@@ -137,9 +137,6 @@ check_LTLIBRARIES = libpaludissohooks_TEST_@PALUDIS_PC_SLOT@.la
stripper_TEST_binary_SOURCES = stripper_TEST_binary.cc
-paludis_datadir = $(datadir)/paludis
-paludis_data_DATA = repository_blacklist.txt
-
paludis_libexecdir = $(libexecdir)/paludis
paludis_libexec_SCRIPTS = hooker.bash
diff --git a/paludis/distributions/exherbo/Makefile.am b/paludis/distributions/exherbo/Makefile.am
index 9b85d03..dfd67d8 100644
--- a/paludis/distributions/exherbo/Makefile.am
+++ b/paludis/distributions/exherbo/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS =
distributiondir = $(datadir)/paludis/distributions/exherbo/
-distribution_DATA = e.conf gems.conf paludis.conf
+distribution_DATA = e.conf gems.conf paludis.conf repository_blacklist.conf
EXTRA_DIST = $(distribution_DATA)
diff --git a/paludis/distributions/exherbo/repository_blacklist.conf b/paludis/distributions/exherbo/repository_blacklist.conf
new file mode 100644
index 0000000..e75c173
--- /dev/null
+++ b/paludis/distributions/exherbo/repository_blacklist.conf
@@ -0,0 +1,2 @@
+gentoo = Nice try, but it won't work.
+
diff --git a/paludis/distributions/gentoo/Makefile.am b/paludis/distributions/gentoo/Makefile.am
index 4ba0c73..b5099aa 100644
--- a/paludis/distributions/gentoo/Makefile.am
+++ b/paludis/distributions/gentoo/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS =
distributiondir = $(datadir)/paludis/distributions/gentoo/
-distribution_DATA = e.conf gems.conf paludis.conf
+distribution_DATA = e.conf gems.conf paludis.conf repository_blacklist.conf
EXTRA_DIST = $(distribution_DATA)
diff --git a/paludis/distributions/gentoo/repository_blacklist.conf b/paludis/distributions/gentoo/repository_blacklist.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/paludis/distributions/gentoo/repository_blacklist.conf
diff --git a/paludis/repository.cc b/paludis/repository.cc
index aa306e1..1ebdabc 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -20,7 +20,6 @@
#include <paludis/repository.hh>
#include <paludis/util/log.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -29,11 +28,13 @@
#include <paludis/util/sequence-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/set-impl.hh>
-#include <paludis/util/config_file.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/action.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/distribution-impl.hh>
+#include <paludis/environment.hh>
#include <tr1/functional>
#include <map>
#include <list>
@@ -71,26 +72,40 @@ RecursivelyDefinedSetError::RecursivelyDefinedSetError(const std::string & our_n
{
}
+namespace paludis
+{
+ namespace n
+ {
+ struct repository_blacklist;
+ }
+}
+
namespace
{
- struct RepositoryBlacklist :
- InstantiationPolicy<RepositoryBlacklist, instantiation_method::SingletonTag>
+ struct RepositoryDistribution
+ {
+ NamedValue<n::repository_blacklist, std::tr1::function<std::string (const std::string &)> > repository_blacklist;
+ };
+
+ typedef ExtraDistributionData<RepositoryDistribution> RepositoryDistributionData;
+}
+
+namespace paludis
+{
+ template <>
+ struct ExtraDistributionDataData<RepositoryDistribution>
{
- std::map<std::string, std::string> items;
+ static std::string config_file_name()
+ {
+ return "repository_blacklist.conf";
+ }
- RepositoryBlacklist()
+ static std::tr1::shared_ptr<RepositoryDistribution> make_data(const std::tr1::shared_ptr<const KeyValueConfigFile> & k)
{
- if (! (FSEntry(DATADIR) / "paludis" / "repository_blacklist.txt").exists())
- return;
-
- LineConfigFile f(FSEntry(DATADIR) / "paludis" / "repository_blacklist.txt", LineConfigFileOptions());
- for (LineConfigFile::ConstIterator line(f.begin()), line_end(f.end()) ;
- line != line_end ; ++line)
- {
- std::string::size_type p(line->find(" - "));
- if (std::string::npos != p)
- items.insert(std::make_pair(line->substr(0, p), line->substr(p + 3)));
- }
+ return make_shared_ptr(new RepositoryDistribution(make_named_values<RepositoryDistribution>(
+ value_for<n::repository_blacklist>(std::tr1::bind(std::tr1::mem_fn(&KeyValueConfigFile::get),
+ k, std::tr1::placeholders::_1))
+ )));
}
};
}
@@ -117,12 +132,14 @@ Repository::Repository(
RepositoryCapabilities(caps),
_imp(PrivateImplementationPattern<Repository>::_imp)
{
- std::map<std::string, std::string>::const_iterator i(
- RepositoryBlacklist::get_instance()->items.find(stringify(name())));
- if (RepositoryBlacklist::get_instance()->items.end() != i)
+ std::string reason(RepositoryDistributionData::get_instance()->data_from_distribution(
+ *DistributionData::get_instance()->distribution_from_string(
+ env->distribution()))->repository_blacklist()(stringify(our_name)));
+
+ if (! reason.empty())
Log::get_instance()->message("repository.blacklisted", ll_warning, lc_no_context)
<< "Repository '" << stringify(name())
- << "' is blacklisted with reason '" << i->second << "'. Consult the FAQ for more details.";
+ << "' is blacklisted with reason '" << reason << "'. Consult the FAQ for more details.";
}
Repository::~Repository()