aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-28 16:31:21 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-28 16:31:21 +0100
commit36d7d6aefbe96e95d9e401e3ab048f485f1c05a6 (patch)
treef764321aaaa4a7685a5c884e535324e032ed8e80
parent5df175e45592582da42d95ff8f767405e72e00e8 (diff)
downloadpaludis-36d7d6aefbe96e95d9e401e3ab048f485f1c05a6.tar.gz
paludis-36d7d6aefbe96e95d9e401e3ab048f485f1c05a6.tar.xz
Handle special purge behaviours
Fixes: ticket:893
-rw-r--r--paludis/resolver/decider.cc43
-rw-r--r--paludis/resolver/decider.hh5
-rw-r--r--paludis/resolver/resolver_TEST_purges.cc4
3 files changed, 46 insertions, 6 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index e4c82a6..630d7eb 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -57,6 +57,7 @@
#include <paludis/choice.hh>
#include <paludis/action.hh>
#include <paludis/elike_slot_requirement.hh>
+#include <paludis/dep_spec_flattener.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -1757,7 +1758,7 @@ Decider::purge()
std::copy(have_now->begin(), have_now->end(), have_now_seq->back_inserter());
const std::tr1::shared_ptr<const PackageIDSet> world(_collect_world(have_now));
- const std::tr1::shared_ptr<const PackageIDSet> world_plus_deps(_accumulate_deps(world, have_now_seq, true));
+ const std::tr1::shared_ptr<const PackageIDSet> world_plus_deps(_accumulate_deps_and_provides(world, have_now_seq, true));
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Calculating Unused"));
@@ -1770,6 +1771,10 @@ Decider::purge()
{
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
+ if ((*i)->behaviours_key() && (*i)->behaviours_key()->value()->end() !=
+ (*i)->behaviours_key()->value()->find("used"))
+ continue;
+
Resolvent resolvent(*i, dt_install_to_slash);
const std::tr1::shared_ptr<Resolution> resolution(_resolution_for_resolvent(resolvent, true));
@@ -1963,8 +1968,8 @@ Decider::_resolve_purges()
const std::tr1::shared_ptr<PackageIDSequence> will_eventually_have(new PackageIDSequence);
std::copy(will_eventually_have_set->begin(), will_eventually_have_set->end(), will_eventually_have->back_inserter());
- const std::tr1::shared_ptr<const PackageIDSet> used_originally(_accumulate_deps(going_away, will_eventually_have, false));
- const std::tr1::shared_ptr<const PackageIDSet> used_afterwards(_accumulate_deps(newly_available, will_eventually_have, false));
+ const std::tr1::shared_ptr<const PackageIDSet> used_originally(_accumulate_deps_and_provides(going_away, will_eventually_have, false));
+ const std::tr1::shared_ptr<const PackageIDSet> used_afterwards(_accumulate_deps_and_provides(newly_available, will_eventually_have, false));
const std::tr1::shared_ptr<PackageIDSet> used_originally_and_not_going_away(new PackageIDSet);
std::set_difference(used_originally->begin(), used_originally->end(),
@@ -1997,6 +2002,10 @@ Decider::_resolve_purges()
{
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
+ if ((*i)->behaviours_key() && (*i)->behaviours_key()->value()->end() !=
+ (*i)->behaviours_key()->value()->find("used"))
+ continue;
+
const std::tr1::shared_ptr<PackageIDSequence> used_to_use(new PackageIDSequence), star_i_set(new PackageIDSequence);
star_i_set->push_back(*i);
for (PackageIDSet::ConstIterator g(going_away->begin()), g_end(going_away->end()) ;
@@ -2036,7 +2045,7 @@ Decider::_collect_installed() const
}
const std::tr1::shared_ptr<const PackageIDSet>
-Decider::_accumulate_deps(
+Decider::_accumulate_deps_and_provides(
const std::tr1::shared_ptr<const PackageIDSet> & start,
const std::tr1::shared_ptr<const PackageIDSequence> & will_eventually_have,
const bool recurse) const
@@ -2058,6 +2067,9 @@ Decider::_accumulate_deps(
const std::tr1::shared_ptr<const PackageIDSet> depped_upon(_collect_depped_upon(*i, will_eventually_have));
std::copy(depped_upon->begin(), depped_upon->end(), result->inserter());
+
+ const std::tr1::shared_ptr<const PackageIDSet> provided(_collect_provided(*i));
+ std::copy(provided->begin(), provided->end(), result->inserter());
}
if (! recurse)
@@ -2092,6 +2104,29 @@ Decider::_collect_depped_upon(
return result;
}
+const std::tr1::shared_ptr<const PackageIDSet>
+Decider::_collect_provided(
+ const std::tr1::shared_ptr<const PackageID> & id) const
+{
+ const std::tr1::shared_ptr<PackageIDSet> result(new PackageIDSet);
+
+ if (id->provide_key())
+ {
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->env);
+ id->provide_key()->value()->root()->accept(f);
+
+ for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator v(f.begin()), v_end(f.end()) ;
+ v != v_end ; ++v)
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> virtuals((*_imp->env)[selection::AllVersionsUnsorted(
+ generator::Matches(**v, MatchPackageOptions()))]);
+ std::copy(virtuals->begin(), virtuals->end(), result->inserter());
+ }
+ }
+
+ return result;
+}
+
const std::tr1::shared_ptr<ConstraintSequence>
Decider::_make_constraints_for_purge(
const std::tr1::shared_ptr<const Resolution> & resolution,
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 63dde2b..bd27e69 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -232,7 +232,7 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSet> _collect_installed() const PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::tr1::shared_ptr<const PackageIDSet> _accumulate_deps(
+ const std::tr1::shared_ptr<const PackageIDSet> _accumulate_deps_and_provides(
const std::tr1::shared_ptr<const PackageIDSet> &,
const std::tr1::shared_ptr<const PackageIDSequence> &,
const bool recurse) const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -241,6 +241,9 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> &,
const std::tr1::shared_ptr<const PackageIDSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const PackageIDSet> _collect_provided(
+ const std::tr1::shared_ptr<const PackageID> & id) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const PackageIDSet> _collect_world(
const std::tr1::shared_ptr<const PackageIDSet> & from) const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/resolver/resolver_TEST_purges.cc b/paludis/resolver/resolver_TEST_purges.cc
index d7d92c3..1cc4909 100644
--- a/paludis/resolver/resolver_TEST_purges.cc
+++ b/paludis/resolver/resolver_TEST_purges.cc
@@ -82,8 +82,10 @@ namespace test_cases
TestPurges() :
ResolverPurgesTestCase("purges")
{
- install("purges", "target", "0")->build_dependencies_key()->set_from_string("purges/still-used-dep purges/old-dep purges/unrelated-dep");
+ install("purges", "target", "0")->build_dependencies_key()->set_from_string(
+ "purges/still-used-dep purges/old-dep purges/old-dep-locked purges/unrelated-dep");
install("purges", "old-dep", "0");
+ install("purges", "old-dep-locked", "0")->behaviours_set()->insert("used");
install("purges", "still-used-dep", "0");
install("purges", "unrelated-dep", "0");
install("purges", "unrelated", "0")->build_dependencies_key()->set_from_string("purges/unrelated-dep");