aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-16 17:28:41 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-16 17:28:41 +0100
commitc0f76979f86fb54bd8ea21c0cd4e020e1577e743 (patch)
treeee84a0c996c823d961b721e196d6cf2b98222ad7
parentc80df694dad34cf04487a584066137e4383996f6 (diff)
downloadpaludis-c0f76979f86fb54bd8ea21c0cd4e020e1577e743.tar.gz
paludis-c0f76979f86fb54bd8ea21c0cd4e020e1577e743.tar.xz
Let repositories suggest an importance.
-rw-r--r--paludis/repositories/cran/registration.cc14
-rw-r--r--paludis/repositories/e/registration.cc15
-rw-r--r--paludis/repositories/gems/registration.cc14
-rw-r--r--paludis/repositories/unavailable/registration.cc13
-rw-r--r--paludis/repositories/unpackaged/registration.cc14
-rw-r--r--paludis/repositories/virtuals/registration.cc14
-rw-r--r--paludis/repository_factory.cc15
-rw-r--r--paludis/repository_factory.hh20
8 files changed, 118 insertions, 1 deletions
diff --git a/paludis/repositories/cran/registration.cc b/paludis/repositories/cran/registration.cc
index 663460a..8cfe344 100644
--- a/paludis/repositories/cran/registration.cc
+++ b/paludis/repositories/cran/registration.cc
@@ -21,11 +21,23 @@
#include <paludis/repositories/cran/cran_repository.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/destringify.hh>
using namespace paludis;
extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
+namespace
+{
+ int generic_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else
+ return 1;
+ }
+}
+
void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
std::tr1::shared_ptr<Set<std::string> > cran_formats(new Set<std::string>);
@@ -34,6 +46,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
cran_formats,
&CRANRepository::repository_factory_name,
+ &generic_importance,
&CRANRepository::repository_factory_create,
&CRANRepository::repository_factory_dependencies
);
@@ -45,6 +58,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
installed_cran_formats,
&CRANInstalledRepository::repository_factory_name,
+ &generic_importance,
&CRANInstalledRepository::repository_factory_create,
&CRANInstalledRepository::repository_factory_dependencies
);
diff --git a/paludis/repositories/e/registration.cc b/paludis/repositories/e/registration.cc
index 07ad5e6..a67d80b 100644
--- a/paludis/repositories/e/registration.cc
+++ b/paludis/repositories/e/registration.cc
@@ -24,6 +24,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/destringify.hh>
using namespace paludis;
@@ -41,6 +42,16 @@ namespace
return ERepository::repository_factory_create(env, f);
}
+
+ int generic_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else if (! f("master_repository").empty())
+ return 10;
+ else
+ return 1;
+ }
}
extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
@@ -54,6 +65,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
ebuild_formats,
&ERepository::repository_factory_name,
+ &generic_importance,
&ERepository::repository_factory_create,
&ERepository::repository_factory_dependencies
);
@@ -64,6 +76,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
deprecated_ebuild_formats,
&ERepository::repository_factory_name,
+ &generic_importance,
make_portage_repository,
&ERepository::repository_factory_dependencies
);
@@ -74,6 +87,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
vdb_formats,
&VDBRepository::repository_factory_name,
+ &generic_importance,
&VDBRepository::repository_factory_create,
&VDBRepository::repository_factory_dependencies
);
@@ -84,6 +98,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
exndbam_formats,
&ExndbamRepository::repository_factory_name,
+ &generic_importance,
&ExndbamRepository::repository_factory_create,
&ExndbamRepository::repository_factory_dependencies
);
diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc
index 554cfc6..e52505c 100644
--- a/paludis/repositories/gems/registration.cc
+++ b/paludis/repositories/gems/registration.cc
@@ -25,11 +25,23 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/destringify.hh>
#include <paludis/distribution.hh>
#include <paludis/environment.hh>
using namespace paludis;
+namespace
+{
+ int generic_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else
+ return 1;
+ }
+}
+
extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
void paludis_initialise_repository_so(RepositoryFactory * const factory)
@@ -40,6 +52,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
gems_formats,
GemsRepository::repository_factory_name,
+ &generic_importance,
GemsRepository::repository_factory_create,
GemsRepository::repository_factory_dependencies
);
@@ -51,6 +64,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
installed_gems_formats,
InstalledGemsRepository::repository_factory_name,
+ &generic_importance,
InstalledGemsRepository::repository_factory_create,
InstalledGemsRepository::repository_factory_dependencies
);
diff --git a/paludis/repositories/unavailable/registration.cc b/paludis/repositories/unavailable/registration.cc
index eb13e6f..8249862 100644
--- a/paludis/repositories/unavailable/registration.cc
+++ b/paludis/repositories/unavailable/registration.cc
@@ -20,10 +20,22 @@
#include <paludis/repository_factory.hh>
#include <paludis/repositories/unavailable/unavailable_repository.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/destringify.hh>
using namespace paludis;
using namespace paludis::unavailable_repository;
+namespace
+{
+ int generic_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else
+ return 1;
+ }
+}
+
extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
void paludis_initialise_repository_so(RepositoryFactory * const factory)
@@ -33,6 +45,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(unavailable_formats,
&UnavailableRepository::repository_factory_name,
+ &generic_importance,
&UnavailableRepository::repository_factory_create,
&UnavailableRepository::repository_factory_dependencies
);
diff --git a/paludis/repositories/unpackaged/registration.cc b/paludis/repositories/unpackaged/registration.cc
index 0cca450..a2dd13f 100644
--- a/paludis/repositories/unpackaged/registration.cc
+++ b/paludis/repositories/unpackaged/registration.cc
@@ -19,12 +19,24 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/destringify.hh>
#include <paludis/repository_factory.hh>
#include <paludis/repositories/unpackaged/installed_repository.hh>
#include <paludis/repositories/unpackaged/unpackaged_repository.hh>
using namespace paludis;
+namespace
+{
+ int generic_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else
+ return 1;
+ }
+}
+
extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
void paludis_initialise_repository_so(RepositoryFactory * const factory)
@@ -35,6 +47,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
unpackaged_formats,
&UnpackagedRepository::repository_factory_name,
+ &generic_importance,
&UnpackagedRepository::repository_factory_create,
&UnpackagedRepository::repository_factory_dependencies
);
@@ -46,6 +59,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
installed_unpackaged_formats,
&InstalledUnpackagedRepository::repository_factory_name,
+ &generic_importance,
&InstalledUnpackagedRepository::repository_factory_create,
&InstalledUnpackagedRepository::repository_factory_dependencies
);
diff --git a/paludis/repositories/virtuals/registration.cc b/paludis/repositories/virtuals/registration.cc
index bc533be..1a67165 100644
--- a/paludis/repositories/virtuals/registration.cc
+++ b/paludis/repositories/virtuals/registration.cc
@@ -21,9 +21,21 @@
#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
#include <paludis/repositories/virtuals/virtuals_repository.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/destringify.hh>
using namespace paludis;
+namespace
+{
+ int virtual_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else
+ return -1;
+ }
+}
+
extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
void paludis_initialise_repository_so(RepositoryFactory * const factory)
@@ -34,6 +46,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
virtuals_formats,
&VirtualsRepository::repository_factory_name,
+ &virtual_importance,
&VirtualsRepository::repository_factory_create,
&VirtualsRepository::repository_factory_dependencies
);
@@ -45,6 +58,7 @@ void paludis_initialise_repository_so(RepositoryFactory * const factory)
factory->add_repository_format(
installed_virtuals_formats,
&InstalledVirtualsRepository::repository_factory_name,
+ &virtual_importance,
&InstalledVirtualsRepository::repository_factory_create,
&InstalledVirtualsRepository::repository_factory_dependencies
);
diff --git a/paludis/repository_factory.cc b/paludis/repository_factory.cc
index 2b33518..3965f69 100644
--- a/paludis/repository_factory.cc
+++ b/paludis/repository_factory.cc
@@ -45,6 +45,7 @@ namespace paludis
{
struct create_function;
struct dependencies_function;
+ struct importance_function;
struct name_function;
}
}
@@ -55,6 +56,7 @@ namespace
{
NamedValue<n::create_function, RepositoryFactory::CreateFunction> create_function;
NamedValue<n::dependencies_function, RepositoryFactory::DependenciesFunction> dependencies_function;
+ NamedValue<n::importance_function, RepositoryFactory::ImportanceFunction> importance_function;
NamedValue<n::name_function, RepositoryFactory::NameFunction> name_function;
};
@@ -166,6 +168,17 @@ RepositoryFactory::name(
return fetch(_imp->keys, key_function("format")).name_function()(env, key_function);
}
+int
+RepositoryFactory::importance(
+ const Environment * const env,
+ const KeyFunction & key_function
+ ) const
+{
+ Context context("When working out importance for repository" + (key_function("repo_file").empty() ? ":" :
+ " from file '" + key_function("repo_file") + ":"));
+ return fetch(_imp->keys, key_function("format")).importance_function()(env, key_function);
+}
+
RepositoryFactory::ConstIterator
RepositoryFactory::begin_keys() const
{
@@ -182,6 +195,7 @@ void
RepositoryFactory::add_repository_format(
const std::tr1::shared_ptr<const Set<std::string> > & formats,
const NameFunction & name_function,
+ const ImportanceFunction & importance_function,
const CreateFunction & create_function,
const DependenciesFunction & dependencies_function
)
@@ -192,6 +206,7 @@ RepositoryFactory::add_repository_format(
if (! _imp->keys.insert(std::make_pair(*f, make_named_values<Funcs>(
value_for<n::create_function>(create_function),
value_for<n::dependencies_function>(dependencies_function),
+ value_for<n::importance_function>(importance_function),
value_for<n::name_function>(name_function)
))).second)
throw ConfigurationError("Handler for repository format '" + stringify(*f) + "' already exists");
diff --git a/paludis/repository_factory.hh b/paludis/repository_factory.hh
index d3d2598..1db355a 100644
--- a/paludis/repository_factory.hh
+++ b/paludis/repository_factory.hh
@@ -64,6 +64,11 @@ namespace paludis
const KeyFunction &
)> NameFunction;
+ typedef std::tr1::function<int (
+ const Environment * const,
+ const KeyFunction &
+ )> ImportanceFunction;
+
/**
* Construct a given repository, or throw ConfigurationError.
*
@@ -87,7 +92,6 @@ namespace paludis
const KeyFunction & key_function
) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
/**
* Find the name of the repository that would be constructed if the
* supplied parameters were passed to RepositoryFactory::create.
@@ -100,6 +104,17 @@ namespace paludis
) const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
+ * Find the importance of the repository that would be constructed if the
+ * supplied parameters were passed to RepositoryFactory::create.
+ *
+ * \see RepositoryFactory::create for parameter documentation.
+ */
+ int importance(
+ const Environment * const env,
+ const KeyFunction & key_function
+ ) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
* Fetch the names of any repositories depended upon by a particular
* repository.
*
@@ -118,6 +133,8 @@ namespace paludis
*
* \param name_function is used to implement RepositoryMaker::name.
*
+ * \param importance_function is used to implement RepositoryMaker::importance.
+ *
* \param create_function is used to implement RepositoryMaker::create.
*
* \param dependencies_function is used to implement
@@ -126,6 +143,7 @@ namespace paludis
void add_repository_format(
const std::tr1::shared_ptr<const Set<std::string> > & formats,
const NameFunction & name_function,
+ const ImportanceFunction & importance_function,
const CreateFunction & create_function,
const DependenciesFunction & dependencies_function
);