aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-05 10:34:42 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-05 10:34:42 +0100
commit975c0c94b62ff647c8aceab9c4ff62ca4e47142e (patch)
tree7d1460d25a2c90a1b152dba9bfe1751c37dab4d5
parent5c950263e9ea902e86030b5fd3a8c6b0760e7539 (diff)
downloadpaludis-975c0c94b62ff647c8aceab9c4ff62ca4e47142e.tar.gz
paludis-975c0c94b62ff647c8aceab9c4ff62ca4e47142e.tar.xz
cave resolve --hide
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/decider.cc19
-rw-r--r--paludis/resolver/decider.hh6
-rw-r--r--paludis/resolver/remove_hidden_helper-fwd.hh31
-rw-r--r--paludis/resolver/remove_hidden_helper.cc79
-rw-r--r--paludis/resolver/remove_hidden_helper.hh51
-rw-r--r--paludis/resolver/resolver_functions.hh6
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/resolver_test.hh2
-rw-r--r--src/clients/cave/resolve_cmdline.cc13
-rw-r--r--src/clients/cave/resolve_cmdline.hh5
-rw-r--r--src/clients/cave/resolve_common.cc8
12 files changed, 209 insertions, 15 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index e26b114..9f19ca8 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -81,6 +81,7 @@ noinst_HEADERS = \
prefer_or_avoid_helper.hh prefer_or_avoid_helper-fwd.hh \
reason.hh reason-fwd.hh \
reason_utils.hh reason_utils-fwd.hh \
+ remove_hidden_helper.hh remove_hidden_helper-fwd.hh \
remove_if_dependent_helper.hh remove_if_dependent_helper-fwd.hh \
required_confirmations.hh required_confirmations-fwd.hh \
resolution.hh resolution-fwd.hh \
@@ -153,6 +154,7 @@ libpaludisresolver_a_SOURCES = \
prefer_or_avoid_helper.cc \
reason.cc \
reason_utils.cc \
+ remove_hidden_helper.cc \
remove_if_dependent_helper.cc \
required_confirmations.cc \
resolution.cc \
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index a89d313..6350514 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1818,12 +1818,19 @@ Decider::_find_installable_id_candidates_for(
{
Context context("When finding installable ID candidates for '" + stringify(package) + "':");
- return (*_imp->env)[selection::AllVersionsSorted(
- _make_origin_filtered_generator(generator::Package(package)) |
- slot_filter |
- filter::SupportsAction<InstallAction>() |
- (include_errors ? filter::All() : include_unmaskable ? _make_unmaskable_filter(package) : filter::NotMasked())
- )];
+ return _remove_hidden(
+ (*_imp->env)[selection::AllVersionsSorted(
+ _make_origin_filtered_generator(generator::Package(package)) |
+ slot_filter |
+ filter::SupportsAction<InstallAction>() |
+ (include_errors ? filter::All() : include_unmaskable ? _make_unmaskable_filter(package) : filter::NotMasked())
+ )]);
+}
+
+const std::shared_ptr<const PackageIDSequence>
+Decider::_remove_hidden(const std::shared_ptr<const PackageIDSequence> & ids) const
+{
+ return _imp->fns.remove_hidden_fn()(ids);
}
const Decider::FoundID
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index cef1f3a..5474fb1 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -224,17 +224,23 @@ namespace paludis
const std::shared_ptr<Constraints> _initial_constraints_for(const Resolvent &) const;
+ const std::shared_ptr<const PackageIDSequence> _remove_hidden(
+ const std::shared_ptr<const PackageIDSequence> & ids) const;
+
const std::shared_ptr<const PackageID> _find_existing_id_for(
const std::shared_ptr<const Resolution> &) const;
+
const std::shared_ptr<const PackageIDSequence> _find_installable_id_candidates_for(
const QualifiedPackageName &,
const Filter &,
const bool include_errors,
const bool include_unmaskable) const;
+
const FoundID _find_installable_id_for(
const std::shared_ptr<const Resolution> &,
const bool include_option_changes,
const bool include_unmaskable) const;
+
const FoundID _find_id_for_from(
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const PackageIDSequence> &,
diff --git a/paludis/resolver/remove_hidden_helper-fwd.hh b/paludis/resolver/remove_hidden_helper-fwd.hh
new file mode 100644
index 0000000..5061d42
--- /dev/null
+++ b/paludis/resolver/remove_hidden_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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_REMOVE_HIDDEN_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_REMOVE_HIDDEN_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class RemoveHiddenHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/remove_hidden_helper.cc b/paludis/resolver/remove_hidden_helper.cc
new file mode 100644
index 0000000..d40fbe2
--- /dev/null
+++ b/paludis/resolver/remove_hidden_helper.cc
@@ -0,0 +1,79 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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/remove_hidden_helper.hh>
+
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/options.hh>
+
+#include <paludis/dep_spec.hh>
+#include <paludis/package_dep_spec_collection.hh>
+
+#include <list>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<RemoveHiddenHelper>
+ {
+ const Environment * const env;
+ PackageDepSpecCollection hide_specs;
+
+ Imp(const Environment * const e) :
+ env(e),
+ hide_specs(make_null_shared_ptr())
+ {
+ }
+ };
+}
+
+RemoveHiddenHelper::RemoveHiddenHelper(const Environment * const e) :
+ _imp(e)
+{
+}
+
+RemoveHiddenHelper::~RemoveHiddenHelper() = default;
+
+void
+RemoveHiddenHelper::add_hide_spec(const PackageDepSpec & spec)
+{
+ _imp->hide_specs.insert(spec);
+}
+
+const std::shared_ptr<const PackageIDSequence>
+RemoveHiddenHelper::operator() (
+ const std::shared_ptr<const PackageIDSequence> & candidates) const
+{
+ auto result(std::make_shared<PackageIDSequence>());
+
+ for (auto c(candidates->begin()), c_end(candidates->end()) ;
+ c != c_end ; ++c)
+ if (! _imp->hide_specs.match_any(_imp->env, *c, { }))
+ result->push_back(*c);
+
+ return result;
+}
+
+template class Pimp<RemoveHiddenHelper>;
+
diff --git a/paludis/resolver/remove_hidden_helper.hh b/paludis/resolver/remove_hidden_helper.hh
new file mode 100644
index 0000000..8ae6780
--- /dev/null
+++ b/paludis/resolver/remove_hidden_helper.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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_REMOVE_HIDDEN_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_REMOVE_HIDDEN_HELPER_HH 1
+
+#include <paludis/resolver/remove_hidden_helper-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE RemoveHiddenHelper
+ {
+ private:
+ Pimp<RemoveHiddenHelper> _imp;
+
+ public:
+ explicit RemoveHiddenHelper(const Environment * const);
+ ~RemoveHiddenHelper();
+
+ void add_hide_spec(const PackageDepSpec &);
+
+ const std::shared_ptr<const PackageIDSequence> operator() (
+ const std::shared_ptr<const PackageIDSequence> &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 4a835b6..3ccf50e 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -68,6 +68,7 @@ namespace paludis
typedef Name<struct name_make_unmaskable_filter_fn> make_unmaskable_filter_fn;
typedef Name<struct name_order_early_fn> order_early_fn;
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;
}
@@ -180,6 +181,10 @@ namespace paludis
const QualifiedPackageName &
)> PreferOrAvoidFunction;
+ typedef std::function<std::shared_ptr<const PackageIDSequence> (
+ const std::shared_ptr<const PackageIDSequence> &
+ )> RemoveHiddenFunction;
+
typedef std::function<bool (
const std::shared_ptr<const PackageID> &
)> RemoveIfDependentFunction;
@@ -211,6 +216,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::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 820f0f7..2026885 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -122,6 +122,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),
+ remove_hidden_helper(&env),
remove_if_dependent_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
@@ -195,6 +196,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::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 8b0d0e1..84e7c27 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -56,6 +56,7 @@
#include <paludis/resolver/make_origin_filtered_generator_helper.hh>
#include <paludis/resolver/make_unmaskable_filter_helper.hh>
#include <paludis/resolver/order_early_helper.hh>
+#include <paludis/resolver/remove_hidden_helper.hh>
#include <paludis/resolver/remove_if_dependent_helper.hh>
#include <paludis/resolver/prefer_or_avoid_helper.hh>
@@ -114,6 +115,7 @@ namespace paludis
MakeUnmaskableFilterHelper make_unmaskable_filter_helper;
OrderEarlyHelper order_early_helper;
PreferOrAvoidHelper prefer_or_avoid_helper;
+ RemoveHiddenHelper remove_hidden_helper;
RemoveIfDependentHelper remove_if_dependent_helper;
ResolverTestData(const std::string & group, const std::string & eapi, const std::string & layout);
diff --git a/src/clients/cave/resolve_cmdline.cc b/src/clients/cave/resolve_cmdline.cc
index ecdcc33..ac7044a 100644
--- a/src/clients/cave/resolve_cmdline.cc
+++ b/src/clients/cave/resolve_cmdline.cc
@@ -227,6 +227,13 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
"specified package names"),
a_avoid(&g_package_options, "avoid", 'A', "If there is a choice (e.g. || ( ) dependencies), avoid the "
"specified package names"),
+ a_preset(&g_package_options, "preset", 'p', "Preset a given constraint. For example, --preset =cat/pkg-2.1 will tell "
+ "the resolver to use that particular version. Note that this may lead to errors, if the specified version "
+ "does not satisfy other constraints. Also note that specifying a preset will not force a package to be "
+ "considered if it would otherwise not be part of the resolution set."),
+ a_hide(&g_package_options, "hide", 'H', "When selecting origin ID candidates, pretend that any ID matching the "
+ "specified spec does not exist. For example, --hide */*::foo can be used to avoid selecting any ID in the "
+ "foo repository. May be specified multiple times."),
g_ordering_options(this, "Package Ordering Options", "Control the order in which packages are installed"),
a_not_usable(&g_ordering_options, "not-usable", 'N', "Consider installed packages matching the supplied specification "
@@ -237,12 +244,6 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
a_late(&g_ordering_options, "late", 'L', "When given a collection of otherwise equally desirable packages to order, "
"order packages matching the supplied spec last."),
- g_preset_options(this, "Preset Options", "Preset various constraints."),
- a_preset(&g_preset_options, "preset", 'p', "Preset a given constraint. For example, --preset =cat/pkg-2.1 will tell "
- "the resolver to use that particular version. Note that this may lead to errors, if the specified version "
- "does not satisfy other constraints. Also note that specifying a preset will not force a package to be "
- "considered if it would otherwise not be part of the resolution set."),
-
g_destination_options(this, "Destination Options", "Control to which destinations targets are installed. Dependencies "
"will always be installed to / as necessary."),
a_make(&g_destination_options, "make", 'm', "Specify what to do with targets.",
diff --git a/src/clients/cave/resolve_cmdline.hh b/src/clients/cave/resolve_cmdline.hh
index 74237b3..8bdd0b4 100644
--- a/src/clients/cave/resolve_cmdline.hh
+++ b/src/clients/cave/resolve_cmdline.hh
@@ -86,15 +86,14 @@ namespace paludis
args::ArgsGroup g_package_options;
args::StringSetArg a_favour;
args::StringSetArg a_avoid;
+ args::StringSetArg a_preset;
+ args::StringSetArg a_hide;
args::ArgsGroup g_ordering_options;
args::StringSetArg a_not_usable;
args::StringSetArg a_early;
args::StringSetArg a_late;
- args::ArgsGroup g_preset_options;
- args::StringSetArg a_preset;
-
args::ArgsGroup g_destination_options;
args::EnumArg a_make;
args::EnumArg a_make_dependencies;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index cad509b..9524e0b 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -91,6 +91,7 @@
#include <paludis/resolver/make_origin_filtered_generator_helper.hh>
#include <paludis/resolver/make_unmaskable_filter_helper.hh>
#include <paludis/resolver/order_early_helper.hh>
+#include <paludis/resolver/remove_hidden_helper.hh>
#include <paludis/resolver/remove_if_dependent_helper.hh>
#include <paludis/resolver/prefer_or_avoid_helper.hh>
@@ -961,6 +962,12 @@ paludis::cave::resolve_common(
i != i_end ; ++i)
prefer_or_avoid_helper.add_avoid_name(disambiguate_if_necessary(env.get(), *i));
+ RemoveHiddenHelper remove_hidden_helper(env.get());
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_hide.begin_args()),
+ i_end(resolution_options.a_hide.end_args()) ;
+ i != i_end ; ++i)
+ remove_hidden_helper.add_hide_spec(parse_spec_with_nice_error(*i, env.get(), { updso_allow_wildcards }, filter::All()));
+
RemoveIfDependentHelper remove_if_dependent_helper(env.get());
for (args::StringSetArg::ConstIterator i(resolution_options.a_remove_if_dependent.begin_args()),
i_end(resolution_options.a_remove_if_dependent.end_args()) ;
@@ -1082,6 +1089,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::remove_hidden_fn() = std::cref(remove_hidden_helper),
n::remove_if_dependent_fn() = std::cref(remove_if_dependent_helper)
));