aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-13 19:57:26 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-13 20:08:59 +0100
commit363aac6ff2a9db9d279669d544fdd3656d03b3a8 (patch)
tree3a617b9bbd8b1c5046aaec4efc755f2e7328d22f
parentb8e139c487eb9e5640e0a6ff106b9ea98de59851 (diff)
downloadpaludis-363aac6ff2a9db9d279669d544fdd3656d03b3a8.tar.gz
paludis-363aac6ff2a9db9d279669d544fdd3656d03b3a8.tar.xz
Split some code out
-rw-r--r--paludis/resolver/Makefile.am12
-rw-r--r--paludis/resolver/accumulate_deps_and_provides-fwd.hh41
-rw-r--r--paludis/resolver/accumulate_deps_and_provides.cc70
-rw-r--r--paludis/resolver/accumulate_deps_and_provides.hh25
-rw-r--r--paludis/resolver/collect_depped_upon-fwd.hh48
-rw-r--r--paludis/resolver/collect_depped_upon.cc220
-rw-r--r--paludis/resolver/collect_depped_upon.hh25
-rw-r--r--paludis/resolver/collect_installed-fwd.hh38
-rw-r--r--paludis/resolver/collect_installed.cc45
-rw-r--r--paludis/resolver/collect_installed.hh25
-rw-r--r--paludis/resolver/collect_provided-fwd.hh38
-rw-r--r--paludis/resolver/collect_provided.cc61
-rw-r--r--paludis/resolver/collect_provided.hh25
-rw-r--r--paludis/resolver/collect_purges-fwd.hh41
-rw-r--r--paludis/resolver/collect_purges.cc49
-rw-r--r--paludis/resolver/collect_purges.hh25
-rw-r--r--paludis/resolver/collect_world-fwd.hh39
-rw-r--r--paludis/resolver/collect_world.cc46
-rw-r--r--paludis/resolver/collect_world.hh25
-rw-r--r--paludis/resolver/decider.cc303
-rw-r--r--paludis/resolver/decider.hh24
21 files changed, 919 insertions, 306 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index b144211..51ac518 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -28,6 +28,7 @@ BUILT_SOURCES = \
use_existing-se.hh use_existing-se.cc
noinst_HEADERS = \
+ accumulate_deps_and_provides.hh accumulate_deps_and_provides-fwd.hh \
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 \
@@ -35,6 +36,11 @@ noinst_HEADERS = \
can_use_helper.hh can_use_helper-fwd.hh \
change_by_resolvent.hh change_by_resolvent-fwd.hh \
change_type.hh change_type-fwd.hh change_type-se.hh \
+ collect_depped_upon.hh collect_depped_upon-fwd.hh \
+ collect_installed.hh collect_installed-fwd.hh \
+ collect_provided.hh collect_provided-fwd.hh \
+ collect_purges.hh collect_purges-fwd.hh \
+ collect_world.hh collect_world-fwd.hh \
confirm_helper.hh confirm_helper-fwd.hh \
constraint.hh constraint-fwd.hh \
decider.hh decider-fwd.hh \
@@ -88,6 +94,7 @@ noinst_HEADERS = \
use_existing.hh use_existing-fwd.hh use_existing-se.hh
libpaludisresolver_a_SOURCES = \
+ accumulate_deps_and_provides.cc \
allow_choice_changes_helper.cc \
allowed_to_remove_helper.cc \
always_via_binary_helper.cc \
@@ -95,6 +102,11 @@ libpaludisresolver_a_SOURCES = \
can_use_helper.cc \
change_by_resolvent.cc \
change_type.cc \
+ collect_depped_upon.cc \
+ collect_installed.cc \
+ collect_provided.cc \
+ collect_purges.cc \
+ collect_world.cc \
confirm_helper.cc \
constraint.cc \
decider.cc \
diff --git a/paludis/resolver/accumulate_deps_and_provides-fwd.hh b/paludis/resolver/accumulate_deps_and_provides-fwd.hh
new file mode 100644
index 0000000..c076b75
--- /dev/null
+++ b/paludis/resolver/accumulate_deps_and_provides-fwd.hh
@@ -0,0 +1,41 @@
+/* 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_ACCUMULATE_DEPS_AND_PROVIDES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ACCUMULATE_DEPS_AND_PROVIDES_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <functional>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ const std::shared_ptr<const PackageIDSet> accumulate_deps_and_provides(
+ const Environment * const,
+ const std::shared_ptr<const PackageIDSet> & start,
+ const std::shared_ptr<const PackageIDSequence> & will_eventually_have,
+ const bool recurse,
+ const std::function<void ()> & step);
+ }
+}
+
+#endif
diff --git a/paludis/resolver/accumulate_deps_and_provides.cc b/paludis/resolver/accumulate_deps_and_provides.cc
new file mode 100644
index 0000000..d5172cc
--- /dev/null
+++ b/paludis/resolver/accumulate_deps_and_provides.cc
@@ -0,0 +1,70 @@
+/* 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/accumulate_deps_and_provides.hh>
+#include <paludis/resolver/collect_depped_upon.hh>
+#include <paludis/resolver/collect_provided.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/package_id.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+const std::shared_ptr<const PackageIDSet>
+paludis::resolver::accumulate_deps_and_provides(
+ const Environment * const env,
+ const std::shared_ptr<const PackageIDSet> & start,
+ const std::shared_ptr<const PackageIDSequence> & will_eventually_have,
+ const bool recurse,
+ const std::function<void ()> & step)
+{
+ const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>()), done(std::make_shared<PackageIDSet>());
+ std::copy(start->begin(), start->end(), result->inserter());
+
+ while (result->size() > done->size())
+ {
+ const std::shared_ptr<PackageIDSet> more(std::make_shared<PackageIDSet>());
+ std::set_difference(result->begin(), result->end(), done->begin(), done->end(), more->inserter(), PackageIDSetComparator());
+
+ for (PackageIDSet::ConstIterator i(more->begin()), i_end(more->end()) ;
+ i != i_end ; ++i)
+ {
+ step();
+
+ done->insert(*i);
+
+ const std::shared_ptr<const PackageIDSet> depped_upon(collect_depped_upon(
+ env, *i, will_eventually_have, std::make_shared<PackageIDSequence>()));
+ std::copy(depped_upon->begin(), depped_upon->end(), result->inserter());
+
+ const std::shared_ptr<const PackageIDSet> provided(collect_provided(env, *i));
+ std::copy(provided->begin(), provided->end(), result->inserter());
+ }
+
+ if (! recurse)
+ break;
+ }
+
+ return result;
+}
+
+
diff --git a/paludis/resolver/accumulate_deps_and_provides.hh b/paludis/resolver/accumulate_deps_and_provides.hh
new file mode 100644
index 0000000..36105c1
--- /dev/null
+++ b/paludis/resolver/accumulate_deps_and_provides.hh
@@ -0,0 +1,25 @@
+/* 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_ACCUMULATE_DEPS_AND_PROVIDES_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ACCUMULATE_DEPS_AND_PROVIDES_HH 1
+
+#include <paludis/resolver/accumulate_deps_and_provides-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/collect_depped_upon-fwd.hh b/paludis/resolver/collect_depped_upon-fwd.hh
new file mode 100644
index 0000000..f3f3bb2
--- /dev/null
+++ b/paludis/resolver/collect_depped_upon-fwd.hh
@@ -0,0 +1,48 @@
+/* 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_COLLECT_DEPPED_UPON_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_DEPPED_UPON_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/resolver/change_by_resolvent-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ const std::shared_ptr<const ChangeByResolventSequence> dependent_upon(
+ const Environment * const,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const ChangeByResolventSequence> &,
+ const std::shared_ptr<const ChangeByResolventSequence> &,
+ const std::shared_ptr<const PackageIDSequence> &) PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ const std::shared_ptr<const PackageIDSet> collect_depped_upon(
+ const Environment * const,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const PackageIDSequence> &,
+ const std::shared_ptr<const PackageIDSequence> &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ }
+}
+
+#endif
diff --git a/paludis/resolver/collect_depped_upon.cc b/paludis/resolver/collect_depped_upon.cc
new file mode 100644
index 0000000..0eec69d
--- /dev/null
+++ b/paludis/resolver/collect_depped_upon.cc
@@ -0,0 +1,220 @@
+/* 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/collect_depped_upon.hh>
+#include <paludis/resolver/change_by_resolvent.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/spec_tree.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/match_package.hh>
+#include <paludis/version_spec.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace
+{
+ const std::shared_ptr<const PackageID> dependent_checker_id(const std::shared_ptr<const PackageID> & i)
+ {
+ return i;
+ }
+
+ const std::shared_ptr<const PackageID> dependent_checker_id(const ChangeByResolvent & i)
+ {
+ return i.package_id();
+ }
+
+ template <typename S_>
+ const std::shared_ptr<const PackageID> best_eventual(
+ const Environment * const env,
+ const PackageDepSpec & spec,
+ const S_ & seq)
+ {
+ std::shared_ptr<const PackageID> result;
+
+ for (auto i(seq->begin()), i_end(seq->end()) ;
+ i != i_end ; ++i)
+ {
+ if ((! result) || dependent_checker_id(*i)->version() >= result->version())
+ if (match_package(*env, spec, *dependent_checker_id(*i), { }))
+ result = dependent_checker_id(*i);
+ }
+
+ return result;
+ }
+ template <typename C_>
+ struct DependentChecker
+ {
+ const Environment * const env;
+ const std::shared_ptr<const C_> going_away;
+ const std::shared_ptr<const C_> newly_available;
+ const std::shared_ptr<const PackageIDSequence> not_changing_slots;
+ const std::shared_ptr<C_> result;
+
+ DependentChecker(
+ const Environment * const e,
+ const std::shared_ptr<const C_> & g,
+ const std::shared_ptr<const C_> & n,
+ const std::shared_ptr<const PackageIDSequence> & s) :
+ env(e),
+ going_away(g),
+ newly_available(n),
+ not_changing_slots(s),
+ result(std::make_shared<C_>())
+ {
+ }
+
+ void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & s)
+ {
+ const std::shared_ptr<const SetSpecTree> set(env->set(s.spec()->name()));
+ set->top()->accept(*this);
+ }
+
+ void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & s)
+ {
+ for (typename C_::ConstIterator g(going_away->begin()), g_end(going_away->end()) ;
+ g != g_end ; ++g)
+ {
+ auto spec(s.spec());
+
+ if (s.spec()->slot_requirement_ptr() && simple_visitor_cast<const SlotAnyUnlockedRequirement>(
+ *s.spec()->slot_requirement_ptr()))
+ {
+ auto best_eventual_id(best_eventual(env, *s.spec(), newly_available));
+ if (! best_eventual_id)
+ best_eventual_id = best_eventual(env, *s.spec(), not_changing_slots);
+ if (best_eventual_id && best_eventual_id->slot_key())
+ {
+ PartiallyMadePackageDepSpec part_spec(*s.spec());
+ part_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(best_eventual_id->slot_key()->value(), false));
+ spec = std::make_shared<PackageDepSpec>(part_spec);
+ }
+ }
+
+ if (! match_package(*env, *spec, *dependent_checker_id(*g), { }))
+ continue;
+
+ bool any(false);
+ for (typename C_::ConstIterator n(newly_available->begin()), n_end(newly_available->end()) ;
+ n != n_end ; ++n)
+ {
+ if (match_package(*env, *spec, *dependent_checker_id(*n), { }))
+ {
+ any = true;
+ break;
+ }
+ }
+
+ if (! any)
+ result->push_back(*g);
+ }
+ }
+
+ void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &)
+ {
+ }
+
+ void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & s)
+ {
+ if (s.spec()->condition_met())
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
+ accept_visitor(*this));
+ }
+
+ void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & s)
+ {
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
+ accept_visitor(*this));
+ }
+
+ void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & s)
+ {
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
+ accept_visitor(*this));
+ }
+
+ void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &)
+ {
+ }
+ };
+}
+
+const std::shared_ptr<const ChangeByResolventSequence>
+paludis::resolver::dependent_upon(
+ const Environment * const env,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const ChangeByResolventSequence> & going_away,
+ const std::shared_ptr<const ChangeByResolventSequence> & staying,
+ const std::shared_ptr<const PackageIDSequence> & not_changing_slots)
+{
+ DependentChecker<ChangeByResolventSequence> c(env, going_away, staying, not_changing_slots);
+ if (id->dependencies_key())
+ id->dependencies_key()->value()->top()->accept(c);
+ else
+ {
+ if (id->build_dependencies_key())
+ id->build_dependencies_key()->value()->top()->accept(c);
+ if (id->run_dependencies_key())
+ id->run_dependencies_key()->value()->top()->accept(c);
+ if (id->post_dependencies_key())
+ id->post_dependencies_key()->value()->top()->accept(c);
+ if (id->suggested_dependencies_key())
+ id->suggested_dependencies_key()->value()->top()->accept(c);
+ }
+
+ return c.result;
+}
+
+const std::shared_ptr<const PackageIDSet>
+paludis::resolver::collect_depped_upon(
+ const Environment * const env,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const PackageIDSequence> & candidates,
+ const std::shared_ptr<const PackageIDSequence> & not_changing_slots)
+{
+ DependentChecker<PackageIDSequence> c(env, candidates, std::make_shared<PackageIDSequence>(), not_changing_slots);
+ if (id->dependencies_key())
+ id->dependencies_key()->value()->top()->accept(c);
+ else
+ {
+ if (id->build_dependencies_key())
+ id->build_dependencies_key()->value()->top()->accept(c);
+ if (id->run_dependencies_key())
+ id->run_dependencies_key()->value()->top()->accept(c);
+ if (id->post_dependencies_key())
+ id->post_dependencies_key()->value()->top()->accept(c);
+ if (id->suggested_dependencies_key())
+ id->suggested_dependencies_key()->value()->top()->accept(c);
+ }
+
+ const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
+ std::copy(c.result->begin(), c.result->end(), result->inserter());
+ return result;
+}
+
+
diff --git a/paludis/resolver/collect_depped_upon.hh b/paludis/resolver/collect_depped_upon.hh
new file mode 100644
index 0000000..0fb8348
--- /dev/null
+++ b/paludis/resolver/collect_depped_upon.hh
@@ -0,0 +1,25 @@
+/* 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_COLLECT_DEPPED_UPON_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_DEPPED_UPON_HH 1
+
+#include <paludis/resolver/collect_depped_upon-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/collect_installed-fwd.hh b/paludis/resolver/collect_installed-fwd.hh
new file mode 100644
index 0000000..7b2b87a
--- /dev/null
+++ b/paludis/resolver/collect_installed-fwd.hh
@@ -0,0 +1,38 @@
+/* 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_COLLECT_INSTALLED_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_INSTALLED_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ const std::shared_ptr<const PackageIDSet> collect_installed(
+ const Environment * const env
+ ) PALUDIS_ATTRIBUTE((warn_unused_result));
+ }
+}
+
+#endif
diff --git a/paludis/resolver/collect_installed.cc b/paludis/resolver/collect_installed.cc
new file mode 100644
index 0000000..cdcef7d
--- /dev/null
+++ b/paludis/resolver/collect_installed.cc
@@ -0,0 +1,45 @@
+/* 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/collect_installed.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/selection.hh>
+#include <paludis/generator.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/filter.hh>
+#include <paludis/environment.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+const std::shared_ptr<const PackageIDSet>
+paludis::resolver::collect_installed(
+ const Environment * const env
+ )
+{
+ const std::shared_ptr<const PackageIDSequence> q((*env)[selection::AllVersionsUnsorted(
+ generator::All() | filter::InstalledAtRoot(FSEntry("/")))]);
+ const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
+
+ std::copy(q->begin(), q->end(), result->inserter());
+ return result;
+}
+
diff --git a/paludis/resolver/collect_installed.hh b/paludis/resolver/collect_installed.hh
new file mode 100644
index 0000000..7cd7181
--- /dev/null
+++ b/paludis/resolver/collect_installed.hh
@@ -0,0 +1,25 @@
+/* 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_COLLECT_INSTALLED_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_INSTALLED_HH 1
+
+#include <paludis/resolver/collect_installed-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/collect_provided-fwd.hh b/paludis/resolver/collect_provided-fwd.hh
new file mode 100644
index 0000000..a94c11a
--- /dev/null
+++ b/paludis/resolver/collect_provided-fwd.hh
@@ -0,0 +1,38 @@
+/* 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_COLLECT_PROVIDED_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_PROVIDED_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/set-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ const std::shared_ptr<const PackageIDSet> collect_provided(
+ const Environment * const,
+ const std::shared_ptr<const PackageID> & id) PALUDIS_ATTRIBUTE((warn_unused_result));
+ }
+}
+
+#endif
diff --git a/paludis/resolver/collect_provided.cc b/paludis/resolver/collect_provided.cc
new file mode 100644
index 0000000..cf0775b
--- /dev/null
+++ b/paludis/resolver/collect_provided.cc
@@ -0,0 +1,61 @@
+/* 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/collect_provided.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/dep_spec_flattener.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/spec_tree.hh>
+#include <paludis/environment.hh>
+#include <paludis/selection.hh>
+#include <paludis/generator.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/filter.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+const std::shared_ptr<const PackageIDSet>
+paludis::resolver::collect_provided(
+ const Environment * const env,
+ const std::shared_ptr<const PackageID> & id)
+{
+ const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
+
+ if (id->provide_key())
+ {
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(env);
+ id->provide_key()->value()->top()->accept(f);
+
+ for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator v(f.begin()), v_end(f.end()) ;
+ v != v_end ; ++v)
+ {
+ const std::shared_ptr<const PackageIDSequence> virtuals((*env)[selection::AllVersionsUnsorted(
+ generator::Matches(**v, { }))]);
+ std::copy(virtuals->begin(), virtuals->end(), result->inserter());
+ }
+ }
+
+ return result;
+}
+
+
diff --git a/paludis/resolver/collect_provided.hh b/paludis/resolver/collect_provided.hh
new file mode 100644
index 0000000..3218712
--- /dev/null
+++ b/paludis/resolver/collect_provided.hh
@@ -0,0 +1,25 @@
+/* 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_COLLECT_PROVIDED_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_PROVIDED_HH 1
+
+#include <paludis/resolver/collect_provided-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/collect_purges-fwd.hh b/paludis/resolver/collect_purges-fwd.hh
new file mode 100644
index 0000000..531dfd7
--- /dev/null
+++ b/paludis/resolver/collect_purges-fwd.hh
@@ -0,0 +1,41 @@
+/* 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_COLLECT_PURGES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_PURGES_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <functional>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ const std::shared_ptr<PackageIDSet> collect_purges(
+ const Environment * const env,
+ const std::shared_ptr<const PackageIDSet> & have_now,
+ const std::shared_ptr<const PackageIDSequence> & have_now_seq,
+ const std::function<void ()> & step) PALUDIS_ATTRIBUTE((warn_unused_result));
+ }
+}
+
+#endif
diff --git a/paludis/resolver/collect_purges.cc b/paludis/resolver/collect_purges.cc
new file mode 100644
index 0000000..2139b62
--- /dev/null
+++ b/paludis/resolver/collect_purges.cc
@@ -0,0 +1,49 @@
+/* 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/collect_purges.hh>
+#include <paludis/resolver/collect_world.hh>
+#include <paludis/resolver/accumulate_deps_and_provides.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/package_id.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+const std::shared_ptr<PackageIDSet>
+paludis::resolver::collect_purges(
+ const Environment * const env,
+ const std::shared_ptr<const PackageIDSet> & have_now,
+ const std::shared_ptr<const PackageIDSequence> & have_now_seq,
+ const std::function<void ()> & step)
+{
+ const std::shared_ptr<const PackageIDSet> world(collect_world(env, have_now));
+ const std::shared_ptr<const PackageIDSet> world_plus_deps(accumulate_deps_and_provides(env, world, have_now_seq, true, step));
+
+ const std::shared_ptr<PackageIDSet> unused(std::make_shared<PackageIDSet>());
+ std::set_difference(have_now->begin(), have_now->end(),
+ world_plus_deps->begin(), world_plus_deps->end(), unused->inserter(), PackageIDSetComparator());
+
+ return unused;
+}
+
diff --git a/paludis/resolver/collect_purges.hh b/paludis/resolver/collect_purges.hh
new file mode 100644
index 0000000..7a2d9d4
--- /dev/null
+++ b/paludis/resolver/collect_purges.hh
@@ -0,0 +1,25 @@
+/* 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_COLLECT_PURGES_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_PURGES_HH 1
+
+#include <paludis/resolver/collect_purges-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/collect_world-fwd.hh b/paludis/resolver/collect_world-fwd.hh
new file mode 100644
index 0000000..e7ab263
--- /dev/null
+++ b/paludis/resolver/collect_world-fwd.hh
@@ -0,0 +1,39 @@
+/* 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_COLLECT_WORLD_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_WORLD_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ const std::shared_ptr<const PackageIDSet> collect_world(
+ const Environment * const env,
+ const std::shared_ptr<const PackageIDSet> &
+ ) PALUDIS_ATTRIBUTE((warn_unused_result));
+ }
+}
+
+#endif
diff --git a/paludis/resolver/collect_world.cc b/paludis/resolver/collect_world.cc
new file mode 100644
index 0000000..034cb30
--- /dev/null
+++ b/paludis/resolver/collect_world.cc
@@ -0,0 +1,46 @@
+/* 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/collect_world.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/util/options.hh>
+#include <paludis/environment.hh>
+#include <paludis/match_package.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+const std::shared_ptr<const PackageIDSet>
+paludis::resolver::collect_world(
+ const Environment * const env,
+ const std::shared_ptr<const PackageIDSet> & from
+ )
+{
+ const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
+ const std::shared_ptr<const SetSpecTree> set(env->set(SetName("world")));
+
+ for (auto i(from->begin()), i_end(from->end()) ;
+ i != i_end ; ++i)
+ if (match_package_in_set(*env, *set, **i, { }))
+ result->insert(*i);
+
+ return result;
+}
diff --git a/paludis/resolver/collect_world.hh b/paludis/resolver/collect_world.hh
new file mode 100644
index 0000000..bbc099b
--- /dev/null
+++ b/paludis/resolver/collect_world.hh
@@ -0,0 +1,25 @@
+/* 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_COLLECT_WORLD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_COLLECT_WORLD_HH 1
+
+#include <paludis/resolver/collect_world-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index a253f60..695adcb 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -32,6 +32,10 @@
#include <paludis/resolver/resolver.hh>
#include <paludis/resolver/required_confirmations.hh>
#include <paludis/resolver/change_by_resolvent.hh>
+#include <paludis/resolver/collect_depped_upon.hh>
+#include <paludis/resolver/collect_installed.hh>
+#include <paludis/resolver/collect_purges.hh>
+#include <paludis/resolver/accumulate_deps_and_provides.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
@@ -60,7 +64,6 @@
#include <paludis/choice.hh>
#include <paludis/action.hh>
#include <paludis/elike_slot_requirement.hh>
-#include <paludis/dep_spec_flattener.hh>
#include <paludis/package_id.hh>
#include <paludis/changed_choices.hh>
#include <paludis/additional_package_dep_spec_requirement.hh>
@@ -239,9 +242,9 @@ Decider::_resolve_dependents()
if (! (*s)->supports_action(SupportsActionTest<UninstallAction>()))
continue;
- const std::shared_ptr<const ChangeByResolventSequence> dependent_upon(_dependent_upon(
- *s, changing.first, changing.second, staying));
- if (dependent_upon->empty())
+ const std::shared_ptr<const ChangeByResolventSequence> dependent_upon_ids(dependent_upon(
+ _imp->env, *s, changing.first, changing.second, staying));
+ if (dependent_upon_ids->empty())
continue;
Resolvent resolvent(*s, dt_install_to_slash);
@@ -255,7 +258,7 @@ Decider::_resolve_dependents()
const std::shared_ptr<Resolution> resolution(_resolution_for_resolvent(resolvent, true));
const std::shared_ptr<const ConstraintSequence> constraints(_make_constraints_for_dependent(
- resolution, *s, dependent_upon));
+ resolution, *s, dependent_upon_ids));
for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
c != c_end ; ++c)
_apply_resolution_constraint(resolution, *c);
@@ -289,162 +292,12 @@ Decider::_make_constraints_for_dependent(
namespace
{
- const std::shared_ptr<const PackageID> dependent_checker_id(const std::shared_ptr<const PackageID> & i)
- {
- return i;
- }
-
- const std::shared_ptr<const PackageID> dependent_checker_id(const ChangeByResolvent & i)
- {
- return i.package_id();
- }
-
- template <typename S_>
- const std::shared_ptr<const PackageID> best_eventual(
- const Environment * const env,
- const PackageDepSpec & spec,
- const S_ & seq)
- {
- std::shared_ptr<const PackageID> result;
-
- for (auto i(seq->begin()), i_end(seq->end()) ;
- i != i_end ; ++i)
- {
- if ((! result) || dependent_checker_id(*i)->version() >= result->version())
- if (match_package(*env, spec, *dependent_checker_id(*i), { }))
- result = dependent_checker_id(*i);
- }
-
- return result;
- }
-
- template <typename C_>
- struct DependentChecker
- {
- const Environment * const env;
- const std::shared_ptr<const C_> going_away;
- const std::shared_ptr<const C_> newly_available;
- const std::shared_ptr<const PackageIDSequence> not_changing_slots;
- const std::shared_ptr<C_> result;
-
- DependentChecker(
- const Environment * const e,
- const std::shared_ptr<const C_> & g,
- const std::shared_ptr<const C_> & n,
- const std::shared_ptr<const PackageIDSequence> & s) :
- env(e),
- going_away(g),
- newly_available(n),
- not_changing_slots(s),
- result(std::make_shared<C_>())
- {
- }
-
- void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & s)
- {
- const std::shared_ptr<const SetSpecTree> set(env->set(s.spec()->name()));
- set->top()->accept(*this);
- }
-
- void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & s)
- {
- for (typename C_::ConstIterator g(going_away->begin()), g_end(going_away->end()) ;
- g != g_end ; ++g)
- {
- auto spec(s.spec());
-
- if (s.spec()->slot_requirement_ptr() && simple_visitor_cast<const SlotAnyUnlockedRequirement>(
- *s.spec()->slot_requirement_ptr()))
- {
- auto best_eventual_id(best_eventual(env, *s.spec(), newly_available));
- if (! best_eventual_id)
- best_eventual_id = best_eventual(env, *s.spec(), not_changing_slots);
- if (best_eventual_id && best_eventual_id->slot_key())
- {
- PartiallyMadePackageDepSpec part_spec(*s.spec());
- part_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(best_eventual_id->slot_key()->value(), false));
- spec = std::make_shared<PackageDepSpec>(part_spec);
- }
- }
-
- if (! match_package(*env, *spec, *dependent_checker_id(*g), { }))
- continue;
-
- bool any(false);
- for (typename C_::ConstIterator n(newly_available->begin()), n_end(newly_available->end()) ;
- n != n_end ; ++n)
- {
- if (match_package(*env, *spec, *dependent_checker_id(*n), { }))
- {
- any = true;
- break;
- }
- }
-
- if (! any)
- result->push_back(*g);
- }
- }
-
- void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &)
- {
- }
-
- void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & s)
- {
- if (s.spec()->condition_met())
- std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor(*this));
- }
-
- void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & s)
- {
- std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor(*this));
- }
-
- void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & s)
- {
- std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor(*this));
- }
-
- void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &)
- {
- }
- };
-
const std::shared_ptr<const PackageID> get_change_by_resolvent_id(const ChangeByResolvent & r)
{
return r.package_id();
}
}
-const std::shared_ptr<const ChangeByResolventSequence>
-Decider::_dependent_upon(
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const ChangeByResolventSequence> & going_away,
- const std::shared_ptr<const ChangeByResolventSequence> & staying,
- const std::shared_ptr<const PackageIDSequence> & not_changing_slots) const
-{
- DependentChecker<ChangeByResolventSequence> c(_imp->env, going_away, staying, not_changing_slots);
- if (id->dependencies_key())
- id->dependencies_key()->value()->top()->accept(c);
- else
- {
- if (id->build_dependencies_key())
- id->build_dependencies_key()->value()->top()->accept(c);
- if (id->run_dependencies_key())
- id->run_dependencies_key()->value()->top()->accept(c);
- if (id->post_dependencies_key())
- id->post_dependencies_key()->value()->top()->accept(c);
- if (id->suggested_dependencies_key())
- id->suggested_dependencies_key()->value()->top()->accept(c);
- }
-
- return c.result;
-}
-
namespace
{
struct ChangingCollector
@@ -2155,20 +2008,14 @@ Decider::purge()
{
Context context("When purging everything:");
- _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Collecting"));
+ _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Collecting Unused"));
- const std::shared_ptr<const PackageIDSet> have_now(_collect_installed());
+ const std::shared_ptr<const PackageIDSet> have_now(collect_installed(_imp->env));
const std::shared_ptr<PackageIDSequence> have_now_seq(std::make_shared<PackageIDSequence>());
std::copy(have_now->begin(), have_now->end(), have_now_seq->back_inserter());
- const std::shared_ptr<const PackageIDSet> world(_collect_world(have_now));
- const std::shared_ptr<const PackageIDSet> world_plus_deps(_accumulate_deps_and_provides(world, have_now_seq, true));
-
- _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Calculating Unused"));
-
- const std::shared_ptr<PackageIDSet> unused(std::make_shared<PackageIDSet>());
- std::set_difference(have_now->begin(), have_now->end(),
- world_plus_deps->begin(), world_plus_deps->end(), unused->inserter(), PackageIDSetComparator());
+ auto unused(collect_purges(_imp->env, have_now, have_now_seq,
+ std::bind(&Environment::trigger_notifier_callback, _imp->env, NotifierCallbackResolverStepEvent())));
for (PackageIDSet::ConstIterator i(unused->begin()), i_end(unused->end()) ;
i != i_end ; ++i)
@@ -2192,7 +2039,8 @@ Decider::purge()
i_seq->push_back(*i);
for (auto u(unused->begin()), u_end(unused->end()) ;
u != u_end ; ++u)
- if ((*u)->supports_action(SupportsActionTest<UninstallAction>()) && ! _collect_depped_upon(*u, i_seq, have_now_seq)->empty())
+ if ((*u)->supports_action(SupportsActionTest<UninstallAction>()) &&
+ ! collect_depped_upon(_imp->env, *u, i_seq, have_now_seq)->empty())
used_to_use->push_back(make_named_values<ChangeByResolvent>(
n::package_id() = *u,
n::resolvent() = Resolvent(*u, dt_install_to_slash)
@@ -2208,21 +2056,6 @@ Decider::purge()
}
}
-const std::shared_ptr<const PackageIDSet>
-Decider::_collect_world(
- const std::shared_ptr<const PackageIDSet> & from) const
-{
- const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- const std::shared_ptr<const SetSpecTree> set(_imp->env->set(SetName("world")));
-
- for (PackageIDSet::ConstIterator i(from->begin()), i_end(from->end()) ;
- i != i_end ; ++i)
- if (match_package_in_set(*_imp->env, *set, **i, { }))
- result->insert(*i);
-
- return result;
-}
-
void
Decider::resolve()
{
@@ -2392,7 +2225,7 @@ Decider::_resolve_purges()
std::transform(going_away_newly_available.second->begin(), going_away_newly_available.second->end(),
newly_available->inserter(), get_change_by_resolvent_id);
- const std::shared_ptr<const PackageIDSet> have_now(_collect_installed());
+ const std::shared_ptr<const PackageIDSet> have_now(collect_installed(_imp->env));
const std::shared_ptr<PackageIDSet> have_now_minus_going_away(std::make_shared<PackageIDSet>());
std::set_difference(have_now->begin(), have_now->end(),
@@ -2405,8 +2238,10 @@ Decider::_resolve_purges()
const std::shared_ptr<PackageIDSequence> will_eventually_have(std::make_shared<PackageIDSequence>());
std::copy(will_eventually_have_set->begin(), will_eventually_have_set->end(), will_eventually_have->back_inserter());
- const std::shared_ptr<const PackageIDSet> used_originally(_accumulate_deps_and_provides(going_away, will_eventually_have, false));
- const std::shared_ptr<const PackageIDSet> used_afterwards(_accumulate_deps_and_provides(newly_available, will_eventually_have, false));
+ const std::shared_ptr<const PackageIDSet> used_originally(accumulate_deps_and_provides(_imp->env, going_away, will_eventually_have, false,
+ std::bind(&Environment::trigger_notifier_callback, _imp->env, NotifierCallbackResolverStepEvent())));
+ const std::shared_ptr<const PackageIDSet> used_afterwards(accumulate_deps_and_provides(_imp->env, newly_available, will_eventually_have, false,
+ std::bind(&Environment::trigger_notifier_callback, _imp->env, NotifierCallbackResolverStepEvent())));
const std::shared_ptr<PackageIDSet> used_originally_and_not_going_away(std::make_shared<PackageIDSet>());
std::set_difference(used_originally->begin(), used_originally->end(),
@@ -2431,7 +2266,7 @@ Decider::_resolve_purges()
{
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
- const std::shared_ptr<const PackageIDSet> used(_collect_depped_upon(*u, newly_unused_seq, have_now_minus_going_away_seq));
+ const std::shared_ptr<const PackageIDSet> used(collect_depped_upon(_imp->env, *u, newly_unused_seq, have_now_minus_going_away_seq));
std::copy(used->begin(), used->end(), used_by_unchanging->inserter());
}
@@ -2463,7 +2298,7 @@ Decider::_resolve_purges()
for (ChangeByResolventSequence::ConstIterator g(going_away_newly_available.first->begin()), g_end(going_away_newly_available.first->end()) ;
g != g_end ; ++g)
if (g->package_id()->supports_action(SupportsActionTest<UninstallAction>()) &&
- ! _collect_depped_upon(g->package_id(), star_i_set, have_now_minus_going_away_seq)->empty())
+ ! collect_depped_upon(_imp->env, g->package_id(), star_i_set, have_now_minus_going_away_seq)->empty())
used_to_use->push_back(*g);
Resolvent resolvent(*i, dt_install_to_slash);
@@ -2486,102 +2321,6 @@ Decider::_resolve_purges()
return changed;
}
-const std::shared_ptr<const PackageIDSet>
-Decider::_collect_installed() const
-{
- const std::shared_ptr<const PackageIDSequence> q((*_imp->env)[selection::AllVersionsUnsorted(
- generator::All() | filter::InstalledAtRoot(FSEntry("/")))]);
- const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
-
- std::copy(q->begin(), q->end(), result->inserter());
- return result;
-}
-
-const std::shared_ptr<const PackageIDSet>
-Decider::_accumulate_deps_and_provides(
- const std::shared_ptr<const PackageIDSet> & start,
- const std::shared_ptr<const PackageIDSequence> & will_eventually_have,
- const bool recurse) const
-{
- const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>()), done(std::make_shared<PackageIDSet>());
- std::copy(start->begin(), start->end(), result->inserter());
-
- while (result->size() > done->size())
- {
- const std::shared_ptr<PackageIDSet> more(std::make_shared<PackageIDSet>());
- std::set_difference(result->begin(), result->end(), done->begin(), done->end(), more->inserter(), PackageIDSetComparator());
-
- for (PackageIDSet::ConstIterator i(more->begin()), i_end(more->end()) ;
- i != i_end ; ++i)
- {
- _imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
-
- done->insert(*i);
-
- const std::shared_ptr<const PackageIDSet> depped_upon(_collect_depped_upon(
- *i, will_eventually_have, std::make_shared<PackageIDSequence>()));
- std::copy(depped_upon->begin(), depped_upon->end(), result->inserter());
-
- const std::shared_ptr<const PackageIDSet> provided(_collect_provided(*i));
- std::copy(provided->begin(), provided->end(), result->inserter());
- }
-
- if (! recurse)
- break;
- }
-
- return result;
-}
-
-const std::shared_ptr<const PackageIDSet>
-Decider::_collect_depped_upon(
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const PackageIDSequence> & candidates,
- const std::shared_ptr<const PackageIDSequence> & not_changing_slots) const
-{
- DependentChecker<PackageIDSequence> c(_imp->env, candidates, std::make_shared<PackageIDSequence>(), not_changing_slots);
- if (id->dependencies_key())
- id->dependencies_key()->value()->top()->accept(c);
- else
- {
- if (id->build_dependencies_key())
- id->build_dependencies_key()->value()->top()->accept(c);
- if (id->run_dependencies_key())
- id->run_dependencies_key()->value()->top()->accept(c);
- if (id->post_dependencies_key())
- id->post_dependencies_key()->value()->top()->accept(c);
- if (id->suggested_dependencies_key())
- id->suggested_dependencies_key()->value()->top()->accept(c);
- }
-
- const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- std::copy(c.result->begin(), c.result->end(), result->inserter());
- return result;
-}
-
-const std::shared_ptr<const PackageIDSet>
-Decider::_collect_provided(
- const std::shared_ptr<const PackageID> & id) const
-{
- const std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
-
- if (id->provide_key())
- {
- DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->env);
- id->provide_key()->value()->top()->accept(f);
-
- for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator v(f.begin()), v_end(f.end()) ;
- v != v_end ; ++v)
- {
- const std::shared_ptr<const PackageIDSequence> virtuals((*_imp->env)[selection::AllVersionsUnsorted(
- generator::Matches(**v, { }))]);
- std::copy(virtuals->begin(), virtuals->end(), result->inserter());
- }
- }
-
- return result;
-}
-
const std::shared_ptr<ConstraintSequence>
Decider::_make_constraints_for_purge(
const std::shared_ptr<const Resolution> & resolution,
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index c0a4f0b..642428d 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -259,32 +259,8 @@ namespace paludis
const std::shared_ptr<const PackageIDSequence> _collect_staying(
const std::shared_ptr<const ChangeByResolventSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::shared_ptr<const ChangeByResolventSequence> _dependent_upon(
- const std::shared_ptr<const PackageID> &,
- const std::shared_ptr<const ChangeByResolventSequence> &,
- const std::shared_ptr<const ChangeByResolventSequence> &,
- const std::shared_ptr<const PackageIDSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
void _confirm(const std::shared_ptr<const Resolution> & resolution);
- const std::shared_ptr<const PackageIDSet> _collect_installed() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::shared_ptr<const PackageIDSet> _accumulate_deps_and_provides(
- const std::shared_ptr<const PackageIDSet> &,
- const std::shared_ptr<const PackageIDSequence> &,
- const bool recurse) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::shared_ptr<const PackageIDSet> _collect_depped_upon(
- const std::shared_ptr<const PackageID> &,
- const std::shared_ptr<const PackageIDSequence> &,
- const std::shared_ptr<const PackageIDSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::shared_ptr<const PackageIDSet> _collect_provided(
- const std::shared_ptr<const PackageID> & id) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::shared_ptr<const PackageIDSet> _collect_world(
- const std::shared_ptr<const PackageIDSet> & from) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
bool _can_use(
const std::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result));