aboutsummaryrefslogtreecommitdiff
path: root/paludis/resolver/destination_utils.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 16:57:55 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 17:08:46 +0100
commite2326073ac9ca7150b6db740cc037719b8089e66 (patch)
treed2d839360426502c49871fb34d4d2cfa7acdd3ba /paludis/resolver/destination_utils.cc
parentb4ab443375d5f8848e4084cd408dbb753fcaf771 (diff)
downloadpaludis-e2326073ac9ca7150b6db740cc037719b8089e66.tar.gz
paludis-e2326073ac9ca7150b6db740cc037719b8089e66.tar.xz
GetInitialConstraintsForHelper
Diffstat (limited to 'paludis/resolver/destination_utils.cc')
-rw-r--r--paludis/resolver/destination_utils.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/paludis/resolver/destination_utils.cc b/paludis/resolver/destination_utils.cc
index b58804a00..3abba3426 100644
--- a/paludis/resolver/destination_utils.cc
+++ b/paludis/resolver/destination_utils.cc
@@ -20,6 +20,12 @@
#include <paludis/resolver/destination_utils.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/generator.hh>
+#include <paludis/generator_handler.hh>
+#include <paludis/filter.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -40,3 +46,60 @@ paludis::resolver::can_chroot(const std::shared_ptr<const PackageID> & id)
return id->behaviours_key()->value()->end() == id->behaviours_key()->value()->find("unchrootable");
}
+namespace
+{
+ struct BinaryDestinationGeneratorHandler :
+ AllGeneratorHandlerBase
+ {
+ virtual std::shared_ptr<const RepositoryNameSet> repositories(
+ const Environment * const env) const
+ {
+ using namespace std::placeholders;
+ std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
+ for (auto r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if (! (*r)->installed_root_key())
+ if ((*r)->destination_interface())
+ result->insert((*r)->name());
+
+ return result;
+ }
+
+ virtual std::string as_string() const
+ {
+ return "binary destination repositories";
+ }
+ };
+
+ struct BinaryDestinationGenerator :
+ Generator
+ {
+ BinaryDestinationGenerator() :
+ Generator(std::make_shared<BinaryDestinationGeneratorHandler>())
+ {
+ }
+ };
+}
+
+FilteredGenerator
+paludis::resolver::destination_filtered_generator(const DestinationType t, const Generator & g)
+{
+ switch (t)
+ {
+ case dt_install_to_slash:
+ return g | filter::InstalledAtSlash();
+
+ case dt_install_to_chroot:
+ return g | filter::InstalledAtNotSlash();
+
+ case dt_create_binary:
+ return g & BinaryDestinationGenerator();
+
+ case last_dt:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "unhandled dt");
+}
+