aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-06 20:01:26 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:06 +0100
commit533dd974bd06e622e3ddc63d9d1f47d005068f2e (patch)
tree514c2dba007eafddcf12658c25fba2cd989e80cc
parentdb5d7e70da97563bc086eefa8055dfbe27cc56a4 (diff)
downloadpaludis-533dd974bd06e622e3ddc63d9d1f47d005068f2e.tar.gz
paludis-533dd974bd06e622e3ddc63d9d1f47d005068f2e.tar.xz
AlwaysViaBinaryHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/always_via_binary_helper-fwd.hh31
-rw-r--r--paludis/resolver/always_via_binary_helper.cc86
-rw-r--r--paludis/resolver/always_via_binary_helper.hh51
-rw-r--r--paludis/resolver/resolver_test.cc12
-rw-r--r--paludis/resolver/resolver_test.hh5
-rw-r--r--src/clients/cave/resolve_common.cc35
7 files changed, 186 insertions, 36 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index fba8707..66493df 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -30,6 +30,7 @@ BUILT_SOURCES = \
noinst_HEADERS = \
allow_choice_changes_helper.hh allow_choice_changes_helper-fwd.hh \
allowed_to_remove_helper.hh allowed_to_remove_helper-fwd.hh \
+ always_via_binary_helper.hh always_via_binary_helper-fwd.hh \
any_child_score.hh any_child_score-fwd.hh any_child_score-se.hh \
change_by_resolvent.hh change_by_resolvent-fwd.hh \
change_type.hh change_type-fwd.hh change_type-se.hh \
@@ -68,6 +69,7 @@ noinst_HEADERS = \
libpaludisresolver_a_SOURCES = \
allow_choice_changes_helper.cc \
allowed_to_remove_helper.cc \
+ always_via_binary_helper.cc \
any_child_score.cc \
change_by_resolvent.cc \
change_type.cc \
diff --git a/paludis/resolver/always_via_binary_helper-fwd.hh b/paludis/resolver/always_via_binary_helper-fwd.hh
new file mode 100644
index 0000000..c528167
--- /dev/null
+++ b/paludis/resolver/always_via_binary_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_ALWAYS_VIA_BINARY_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ALWAYS_VIA_BINARY_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct AlwaysViaBinaryHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/always_via_binary_helper.cc b/paludis/resolver/always_via_binary_helper.cc
new file mode 100644
index 0000000..f353142
--- /dev/null
+++ b/paludis/resolver/always_via_binary_helper.cc
@@ -0,0 +1,86 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/always_via_binary_helper.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/package_dep_spec_collection.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<AlwaysViaBinaryHelper>
+ {
+ const Environment * const env;
+ PackageDepSpecCollection always_via_binary_specs;
+
+ Imp(const Environment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+AlwaysViaBinaryHelper::AlwaysViaBinaryHelper(const Environment * const e) :
+ Pimp<AlwaysViaBinaryHelper>(e)
+{
+}
+
+AlwaysViaBinaryHelper::~AlwaysViaBinaryHelper() = default;
+
+void
+AlwaysViaBinaryHelper::add_always_via_binary_spec(const PackageDepSpec & spec)
+{
+ _imp->always_via_binary_specs.insert(spec);
+}
+
+namespace
+{
+ bool can_make_binary_for(const std::shared_ptr<const PackageID> & id)
+ {
+ if (! id->behaviours_key())
+ return true;
+ return id->behaviours_key()->value()->end() == id->behaviours_key()->value()->find("unbinaryable");
+ }
+}
+
+bool
+AlwaysViaBinaryHelper::operator() (const std::shared_ptr<const Resolution> & resolution) const
+{
+ const ChangesToMakeDecision * changes_decision(simple_visitor_cast<const ChangesToMakeDecision>(*resolution->decision()));
+ if (! changes_decision)
+ return false;
+
+ return can_make_binary_for(changes_decision->origin_id()) &&
+ _imp->always_via_binary_specs.match_any(_imp->env, changes_decision->origin_id(), { });
+}
+
+template class Pimp<AlwaysViaBinaryHelper>;
+
diff --git a/paludis/resolver/always_via_binary_helper.hh b/paludis/resolver/always_via_binary_helper.hh
new file mode 100644
index 0000000..c6f4fa1
--- /dev/null
+++ b/paludis/resolver/always_via_binary_helper.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_ALWAYS_VIA_BINARY_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ALWAYS_VIA_BINARY_HELPER_HH 1
+
+#include <paludis/resolver/always_via_binary_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE AlwaysViaBinaryHelper :
+ private Pimp<AlwaysViaBinaryHelper>
+ {
+ public:
+ explicit AlwaysViaBinaryHelper(const Environment * const);
+ ~AlwaysViaBinaryHelper();
+
+ void add_always_via_binary_spec(const PackageDepSpec &);
+
+ bool operator() (const std::shared_ptr<const Resolution> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::AlwaysViaBinaryHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 07f5541..fea4b4a 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -330,20 +330,14 @@ paludis::resolver::resolver_test::can_use_fn(
return true;
}
-bool
-paludis::resolver::resolver_test::always_via_binary_fn(
- const std::shared_ptr<const Resolution> &)
-{
- return false;
-}
-
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s),
remove_if_dependent_names(std::make_shared<QualifiedPackageNameSet>()),
prefer_or_avoid_names(std::make_shared<Map<QualifiedPackageName, bool>>()),
allow_choice_changes_helper(&env),
- allowed_to_remove_helper(&env)
+ allowed_to_remove_helper(&env),
+ always_via_binary_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -391,7 +385,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
return make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::cref(allowed_to_remove_helper),
- n::always_via_binary_fn() = &always_via_binary_fn,
+ n::always_via_binary_fn() = std::cref(always_via_binary_helper),
n::can_use_fn() = &can_use_fn,
n::confirm_fn() = &confirm_fn,
n::find_repository_for_fn() = std::bind(&find_repository_for_fn,
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 30bdcbe..a43b788 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -37,6 +37,7 @@
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
+#include <paludis/resolver/always_via_binary_helper.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -138,9 +139,6 @@ namespace paludis
bool can_use_fn(
const std::shared_ptr<const PackageID> &);
- bool always_via_binary_fn(
- const std::shared_ptr<const Resolution> &);
-
struct ResolverTestCase : test::TestCase
{
TestEnvironment env;
@@ -151,6 +149,7 @@ namespace paludis
AllowChoiceChangesHelper allow_choice_changes_helper;
AllowedToRemoveHelper allowed_to_remove_helper;
+ AlwaysViaBinaryHelper always_via_binary_helper;
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 9b965ab..96255d5 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -67,6 +67,7 @@
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
+#include <paludis/resolver/always_via_binary_helper.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1415,18 +1416,6 @@ namespace
return ! match_any(env, list, id);
}
- bool always_via_binary_fn(
- const Environment * const env,
- const PackageDepSpecList & list,
- const std::shared_ptr<const Resolution> & resolution)
- {
- const ChangesToMakeDecision * changes_decision(simple_visitor_cast<const ChangesToMakeDecision>(*resolution->decision()));
- if (! changes_decision)
- return false;
-
- return can_make_binary_for(changes_decision->origin_id()) && match_any(env, list, changes_decision->origin_id());
- }
-
void serialise_resolved(StringListStream & ser_stream, const Resolved & resolved)
{
Serialiser ser(ser_stream);
@@ -1743,8 +1732,7 @@ paludis::cave::resolve_common(
PackageDepSpecList allowed_to_break_specs, remove_if_dependent_specs,
less_restrictive_remove_blockers_specs, purge_specs, with, without,
permit_old_version, permit_downgrade, take, take_from, ignore, ignore_from,
- favour, avoid, early, late, no_dependencies_from, no_blockers_from, not_usable_specs,
- via_binary_specs;
+ favour, avoid, early, late, no_dependencies_from, no_blockers_from, not_usable_specs;
bool allowed_to_break_system(false);
for (args::StringSetArg::ConstIterator i(resolution_options.a_uninstalls_may_break.begin_args()),
@@ -1864,14 +1852,6 @@ paludis::cave::resolve_common(
not_usable_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
{ updso_allow_wildcards }));
-#ifdef ENABLE_PBINS
- for (args::StringSetArg::ConstIterator i(resolution_options.a_via_binary.begin_args()),
- i_end(resolution_options.a_via_binary.end_args()) ;
- i != i_end ; ++i)
- via_binary_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
- { updso_allow_wildcards }));
-#endif
-
std::shared_ptr<Generator> binary_destinations;
for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ;
@@ -1938,11 +1918,18 @@ paludis::cave::resolve_common(
i != i_end ; ++i)
allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ AlwaysViaBinaryHelper always_via_binary_helper(env.get());
+#ifdef ENABLE_PBINS
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_via_binary.begin_args()),
+ i_end(resolution_options.a_via_binary.end_args()) ;
+ i != i_end ; ++i)
+ always_via_binary_helper.add_always_via_binary_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+#endif
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::cref(allowed_to_remove_helper),
- n::always_via_binary_fn() = std::bind(&always_via_binary_fn,
- env.get(), std::cref(via_binary_specs), _1),
+ n::always_via_binary_fn() = std::cref(always_via_binary_helper),
n::can_use_fn() = std::bind(&can_use_fn,
env.get(), std::cref(not_usable_specs), _1),
n::confirm_fn() = std::bind(&confirm_fn,