aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Dimitry Ishenko <dimitry.ishenko@gmail.com> 2014-03-05 11:17:33 -0500
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2014-03-21 15:36:17 +0000
commit4146ff8665112932e5e9cd54f7ed5caf0773e51a (patch)
tree24aac10da3b2d9a14e7f50bf1836195a4f939cdc
parent20d93f8212a5d0da626bca631b7e36cc3125cc6b (diff)
downloadpaludis-4146ff8665112932e5e9cd54f7ed5caf0773e51a.tar.gz
paludis-4146ff8665112932e5e9cd54f7ed5caf0773e51a.tar.xz
Add PromoteBinariesHelper
-rw-r--r--paludis/resolver/Makefile.am13
-rw-r--r--paludis/resolver/decider.cc2
-rw-r--r--paludis/resolver/promote_binaries-fwd.hh35
-rw-r--r--paludis/resolver/promote_binaries.cc29
-rw-r--r--paludis/resolver/promote_binaries.hh34
-rw-r--r--paludis/resolver/promote_binaries.se14
-rw-r--r--paludis/resolver/promote_binaries_helper.cc78
-rw-r--r--paludis/resolver/promote_binaries_helper.hh51
-rw-r--r--paludis/resolver/resolver_functions.hh8
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/resolver_test.hh2
-rw-r--r--src/clients/cave/resolve_common.cc4
12 files changed, 271 insertions, 1 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 84f9578..60dc4ee 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -7,6 +7,7 @@ DISTCLEANFILES = \
destination_types-se.hh destination_types-se.cc \
job_requirements-se.hh job_requirements-se.cc \
nag-se.hh nag-se.cc \
+ promote_binaries-se.hh promote_binaries-se.cc \
resolver_functions-se.hh resolver_functions-se.cc \ \
use_existing-se.hh use_existing-se.cc
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
@@ -17,6 +18,7 @@ EXTRA_DIST = \
destination_types-se.hh destination_types-se.cc destination_types.se \
job_requirements-se.hh job_requirements-se.cc job_requirements.se \
nag-se.hh nag-se.cc nag.se \
+ promote_binaries-se.hh promote_binaries-se.cc promote_binaries.se \
resolver_functions-se.hh resolver_functions-se.cc resolver_functions.se \
use_existing-se.hh use_existing-se.cc use_existing.se \
$(check_SCRIPTS)
@@ -27,6 +29,7 @@ BUILT_SOURCES = \
destination_types-se.hh destination_types-se.cc \
nag-se.hh nag-se.cc \
job_requirements-se.hh job_requirements-se.cc \
+ promote_binaries-se.hh promote_binaries-se.cc \
resolver_functions-se.hh resolver_functions-se.cc \
use_existing-se.hh use_existing-se.cc
@@ -84,6 +87,8 @@ noinst_HEADERS = \
package_id_comparator_with_promotion.hh package_id_comparator_with_promotion-fwd.hh \
package_or_block_dep_spec.hh package_or_block_dep_spec-fwd.hh \
prefer_or_avoid_helper.hh prefer_or_avoid_helper-fwd.hh \
+ promote_binaries.hh promote_binaries-fwd.hh promote_binaries-se.hh \
+ promote_binaries_helper.hh \
reason.hh reason-fwd.hh \
reason_utils.hh reason_utils-fwd.hh \
remove_hidden_helper.hh remove_hidden_helper-fwd.hh \
@@ -159,6 +164,8 @@ libpaludisresolver_a_SOURCES = \
package_id_comparator_with_promotion.cc \
package_or_block_dep_spec.cc \
prefer_or_avoid_helper.cc \
+ promote_binaries.cc \
+ promote_binaries_helper.cc \
reason.cc \
reason_utils.cc \
remove_hidden_helper.cc \
@@ -434,3 +441,9 @@ decision-se.hh : decision.se $(top_srcdir)/misc/make_se.bash
decision-se.cc : decision.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/decision.se > $@ ; then rm -f $@ ; exit 1 ; fi
+promote_binaries-se.hh : promote_binaries.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/promote_binaries.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
+promote_binaries-se.cc : promote_binaries.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/promote_binaries.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 21a5c78..f2a7f11 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1738,7 +1738,7 @@ Decider::_find_installable_id_candidates_for(
Context context("When finding installable ID candidates for '" + stringify(package) + "':");
return _imp->fns.remove_hidden_fn()(
- (*_imp->env)[selection::AllVersionsSorted(
+ (*_imp->env)[_imp->fns.promote_binaries_fn()(
_imp->fns.make_origin_filtered_generator_fn()(generator::Package(package)) |
slot_filter |
destination_type_filter |
diff --git a/paludis/resolver/promote_binaries-fwd.hh b/paludis/resolver/promote_binaries-fwd.hh
new file mode 100644
index 0000000..b26e054
--- /dev/null
+++ b/paludis/resolver/promote_binaries-fwd.hh
@@ -0,0 +1,35 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2014 Dimitry Ishenko
+ *
+ * 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_PROMOTE_BINARIES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_PROMOTE_BINARIES_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ namespace resolver
+ {
+#include <paludis/resolver/promote_binaries-se.hh>
+ }
+}
+
+#endif
diff --git a/paludis/resolver/promote_binaries.cc b/paludis/resolver/promote_binaries.cc
new file mode 100644
index 0000000..47bf6a8
--- /dev/null
+++ b/paludis/resolver/promote_binaries.cc
@@ -0,0 +1,29 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2014 Dimitry Ishenko
+ *
+ * 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/promote_binaries.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/stringify.hh>
+#include <ostream>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+#include <paludis/resolver/promote_binaries-se.cc>
diff --git a/paludis/resolver/promote_binaries.hh b/paludis/resolver/promote_binaries.hh
new file mode 100644
index 0000000..721daaa
--- /dev/null
+++ b/paludis/resolver/promote_binaries.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2014 Dimitry Ishenko
+ *
+ * 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_PROMOTE_BINARIES_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_PROMOTE_BINARIES_HH 1
+
+#include <paludis/resolver/promote_binaries-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+
+ }
+}
+
+#endif
diff --git a/paludis/resolver/promote_binaries.se b/paludis/resolver/promote_binaries.se
new file mode 100644
index 0000000..20428d8
--- /dev/null
+++ b/paludis/resolver/promote_binaries.se
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_PromoteBinaries()
+{
+ prefix pb
+ namespace paludis::resolver
+
+ # must be kept in strictness order
+ key pb_never "Never"
+ key pb_if_same "If it is the same"
+
+ want_destringify
+}
diff --git a/paludis/resolver/promote_binaries_helper.cc b/paludis/resolver/promote_binaries_helper.cc
new file mode 100644
index 0000000..93f84a0
--- /dev/null
+++ b/paludis/resolver/promote_binaries_helper.cc
@@ -0,0 +1,78 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2014 Dimitry Ishenko
+ *
+ * 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/promote_binaries_helper.hh>
+#include <paludis/resolver/promote_binaries.hh>
+#include <paludis/resolver/selection_with_promotion.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/selection.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/environment.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<PromoteBinariesHelper>
+ {
+ const Environment * const env;
+ PromoteBinaries promote_binaries;
+
+ Imp(const Environment * const e) :
+ env(e),
+ promote_binaries(pb_never)
+ {
+ }
+ };
+}
+
+PromoteBinariesHelper::PromoteBinariesHelper(const Environment * const e) :
+ _imp(e)
+{
+}
+
+PromoteBinariesHelper::~PromoteBinariesHelper() = default;
+
+void
+PromoteBinariesHelper::set_promote_binaries(const PromoteBinaries v)
+{
+ _imp->promote_binaries = v;
+}
+
+Selection
+PromoteBinariesHelper::operator() (const FilteredGenerator & fg) const
+{
+ switch(_imp->promote_binaries)
+ {
+ case pb_if_same:
+ return selection::AllVersionsSortedWithPromotion(fg);
+
+ default:
+ return selection::AllVersionsSorted(fg);
+ }
+}
+
+namespace paludis
+{
+ template class Pimp<PromoteBinariesHelper>;
+}
diff --git a/paludis/resolver/promote_binaries_helper.hh b/paludis/resolver/promote_binaries_helper.hh
new file mode 100644
index 0000000..58e37fc
--- /dev/null
+++ b/paludis/resolver/promote_binaries_helper.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2014 Dimitry Ishenko
+ *
+ * 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_PROMOTE_BINARIES_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_PROMOTE_BINARIES_HELPER_HH 1
+
+#include <paludis/resolver/promote_binaries-fwd.hh>
+#include <paludis/selection-fwd.hh>
+#include <paludis/filtered_generator-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE PromoteBinariesHelper
+ {
+ private:
+ Pimp<PromoteBinariesHelper> _imp;
+
+ public:
+ explicit PromoteBinariesHelper(const Environment * const);
+ ~PromoteBinariesHelper();
+
+ void set_promote_binaries(const PromoteBinaries);
+
+ Selection operator() (const FilteredGenerator &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index aefb6de..18387ff 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -43,6 +43,7 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/generator-fwd.hh>
#include <paludis/filtered_generator-fwd.hh>
+#include <paludis/selection-fwd.hh>
#include <functional>
@@ -74,6 +75,7 @@ namespace paludis
typedef Name<struct name_prefer_or_avoid_fn> prefer_or_avoid_fn;
typedef Name<struct name_remove_hidden_fn> remove_hidden_fn;
typedef Name<struct name_remove_if_dependent_fn> remove_if_dependent_fn;
+ typedef Name<struct name_promote_binaries_fn> promote_binaries_fn;
}
namespace resolver
@@ -194,6 +196,11 @@ namespace paludis
const std::shared_ptr<const PackageID> &
)> RemoveIfDependentFunction;
+
+ typedef std::function<Selection (
+ const FilteredGenerator &
+ )> PromoteBinariesFunction;
+
struct ResolverFunctions
{
NamedValue<n::allow_choice_changes_fn, AllowChoiceChangesFunction> allow_choice_changes_fn;
@@ -221,6 +228,7 @@ namespace paludis
MakeUnmaskableFilterFunction> make_unmaskable_filter_fn;
NamedValue<n::order_early_fn, OrderEarlyFunction> order_early_fn;
NamedValue<n::prefer_or_avoid_fn, PreferOrAvoidFunction> prefer_or_avoid_fn;
+ NamedValue<n::promote_binaries_fn, PromoteBinariesFunction> promote_binaries_fn;
NamedValue<n::remove_hidden_fn, RemoveHiddenFunction> remove_hidden_fn;
NamedValue<n::remove_if_dependent_fn, RemoveIfDependentFunction> remove_if_dependent_fn;
};
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 5439626..0751f5c 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -96,6 +96,7 @@ ResolverTestData::ResolverTestData(const std::string & t, const std::string & e,
make_unmaskable_filter_helper(&env),
order_early_helper(&env),
prefer_or_avoid_helper(&env),
+ promote_binaries_helper(&env),
remove_hidden_helper(&env),
remove_if_dependent_helper(&env),
get_resolvents_for_helper(&env, std::cref(remove_hidden_helper))
@@ -186,6 +187,7 @@ ResolverTestData::get_resolver_functions()
n::make_unmaskable_filter_fn() = std::cref(make_unmaskable_filter_helper),
n::order_early_fn() = std::cref(order_early_helper),
n::prefer_or_avoid_fn() = std::cref(prefer_or_avoid_helper),
+ n::promote_binaries_fn() = std::cref(promote_binaries_helper),
n::remove_hidden_fn() = std::cref(remove_hidden_helper),
n::remove_if_dependent_fn() = std::cref(remove_if_dependent_helper)
);
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 766eb44..ad51653 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -59,6 +59,7 @@
#include <paludis/resolver/remove_hidden_helper.hh>
#include <paludis/resolver/remove_if_dependent_helper.hh>
#include <paludis/resolver/prefer_or_avoid_helper.hh>
+#include <paludis/resolver/promote_binaries_helper.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -114,6 +115,7 @@ namespace paludis
MakeUnmaskableFilterHelper make_unmaskable_filter_helper;
OrderEarlyHelper order_early_helper;
PreferOrAvoidHelper prefer_or_avoid_helper;
+ PromoteBinariesHelper promote_binaries_helper;
RemoveHiddenHelper remove_hidden_helper;
RemoveIfDependentHelper remove_if_dependent_helper;
GetResolventsForHelper get_resolvents_for_helper;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 1be2ea6..ce353a2 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -91,6 +91,7 @@
#include <paludis/resolver/remove_hidden_helper.hh>
#include <paludis/resolver/remove_if_dependent_helper.hh>
#include <paludis/resolver/prefer_or_avoid_helper.hh>
+#include <paludis/resolver/promote_binaries_helper.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1084,6 +1085,8 @@ paludis::cave::resolve_common(
throw args::DoHelp("Don't understand argument '" + resolution_options.a_recommendations.argument() + "' to '--"
+ resolution_options.a_recommendations.long_name() + "'");
+ PromoteBinariesHelper promote_binaries_helper(env.get());
+
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),
@@ -1107,6 +1110,7 @@ paludis::cave::resolve_common(
n::make_unmaskable_filter_fn() = std::cref(make_unmaskable_filter_helper),
n::order_early_fn() = std::cref(order_early_helper),
n::prefer_or_avoid_fn() = std::cref(prefer_or_avoid_helper),
+ n::promote_binaries_fn() = std::cref(promote_binaries_helper),
n::remove_hidden_fn() = std::cref(remove_hidden_helper),
n::remove_if_dependent_fn() = std::cref(remove_if_dependent_helper)
));