aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-22 12:20:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-22 12:56:30 +0000
commiteddec79df4c65fe370554ccf9e2311a2111aa7f7 (patch)
tree6018c216f25984d6bfb1e34558321b1df01ff68d
parentae4abad908a52441d60e52bd85cfca0960c54e0f (diff)
downloadpaludis-eddec79df4c65fe370554ccf9e2311a2111aa7f7.tar.gz
paludis-eddec79df4c65fe370554ccf9e2311a2111aa7f7.tar.xz
Let jobs require confirmation
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/job.cc124
-rw-r--r--paludis/resolver/job.hh43
-rw-r--r--paludis/resolver/orderer.cc54
-rw-r--r--paludis/resolver/orderer.hh8
-rw-r--r--paludis/resolver/required_confirmations-fwd.hh38
-rw-r--r--paludis/resolver/required_confirmations.cc73
-rw-r--r--paludis/resolver/required_confirmations.hh68
-rw-r--r--paludis/resolver/resolver.cc3
-rw-r--r--paludis/resolver/resolver_functions.hh9
-rw-r--r--paludis/resolver/resolver_lists.cc9
-rw-r--r--paludis/resolver/resolver_lists.hh2
-rw-r--r--paludis/resolver/resolver_test.cc10
-rw-r--r--paludis/resolver/resolver_test.hh6
-rw-r--r--src/clients/cave/resolve_common.cc13
15 files changed, 450 insertions, 12 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 5eeb9cf..549d480 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -40,6 +40,7 @@ noinst_HEADERS = \
failure_kinds.hh failure_kinds-fwd.hh failure_kinds-se.hh \
orderer.hh orderer-fwd.hh \
reason.hh reason-fwd.hh \
+ required_confirmations.hh required_confirmations-fwd.hh \
resolution.hh resolution-fwd.hh \
resolutions.hh resolutions-fwd.hh \
resolvent.hh resolvent-fwd.hh \
@@ -69,6 +70,7 @@ libpaludisresolver_a_SOURCES = \
jobs.cc \
orderer.cc \
reason.cc \
+ required_confirmations.cc \
resolution.cc \
resolutions.cc \
resolvent.cc \
diff --git a/paludis/resolver/job.cc b/paludis/resolver/job.cc
index ef34e4c..ccadc30 100644
--- a/paludis/resolver/job.cc
+++ b/paludis/resolver/job.cc
@@ -21,6 +21,7 @@
#include <paludis/resolver/arrow.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/required_confirmations.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/make_named_values.hh>
@@ -40,11 +41,13 @@ namespace paludis
const std::tr1::shared_ptr<const Resolution> resolution;
const std::tr1::shared_ptr<ArrowSequence> arrows;
const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+ const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const std::tr1::shared_ptr<const Resolution> & r) :
resolution(r),
arrows(new ArrowSequence),
- used_existing_packages_when_ordering(new JobIDSequence)
+ used_existing_packages_when_ordering(new JobIDSequence),
+ required_confirmations(new RequiredConfirmations)
{
}
};
@@ -55,11 +58,13 @@ namespace paludis
const std::tr1::shared_ptr<const JobIDSequence> ids;
const std::tr1::shared_ptr<ArrowSequence> arrows;
const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+ const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const std::tr1::shared_ptr<const JobIDSequence> & i) :
ids(i),
arrows(new ArrowSequence),
- used_existing_packages_when_ordering(new JobIDSequence)
+ used_existing_packages_when_ordering(new JobIDSequence),
+ required_confirmations(new RequiredConfirmations)
{
}
};
@@ -71,13 +76,15 @@ namespace paludis
const std::tr1::shared_ptr<const ChangesToMakeDecision> decision;
const std::tr1::shared_ptr<ArrowSequence> arrows;
const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+ const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const std::tr1::shared_ptr<const Resolution> & r,
const std::tr1::shared_ptr<const ChangesToMakeDecision> & d) :
resolution(r),
decision(d),
arrows(new ArrowSequence),
- used_existing_packages_when_ordering(new JobIDSequence)
+ used_existing_packages_when_ordering(new JobIDSequence),
+ required_confirmations(new RequiredConfirmations)
{
}
};
@@ -89,13 +96,15 @@ namespace paludis
const std::tr1::shared_ptr<const ChangesToMakeDecision> decision;
const std::tr1::shared_ptr<ArrowSequence> arrows;
const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+ const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const std::tr1::shared_ptr<const Resolution> & r,
const std::tr1::shared_ptr<const ChangesToMakeDecision> & d) :
resolution(r),
decision(d),
arrows(new ArrowSequence),
- used_existing_packages_when_ordering(new JobIDSequence)
+ used_existing_packages_when_ordering(new JobIDSequence),
+ required_confirmations(new RequiredConfirmations)
{
}
};
@@ -107,13 +116,15 @@ namespace paludis
const std::tr1::shared_ptr<const RemoveDecision> decision;
const std::tr1::shared_ptr<ArrowSequence> arrows;
const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+ const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const std::tr1::shared_ptr<const Resolution> & r,
const std::tr1::shared_ptr<const RemoveDecision> & d) :
resolution(r),
decision(d),
arrows(new ArrowSequence),
- used_existing_packages_when_ordering(new JobIDSequence)
+ used_existing_packages_when_ordering(new JobIDSequence),
+ required_confirmations(new RequiredConfirmations)
{
}
};
@@ -125,13 +136,15 @@ namespace paludis
const std::tr1::shared_ptr<const UnableToMakeDecision> decision;
const std::tr1::shared_ptr<ArrowSequence> arrows;
const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+ const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const std::tr1::shared_ptr<const Resolution> & r,
const std::tr1::shared_ptr<const UnableToMakeDecision> & d) :
resolution(r),
decision(d),
arrows(new ArrowSequence),
- used_existing_packages_when_ordering(new JobIDSequence)
+ used_existing_packages_when_ordering(new JobIDSequence),
+ required_confirmations(new RequiredConfirmations)
{
}
};
@@ -160,6 +173,15 @@ namespace
for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
result->used_existing_packages_when_ordering()->push_back(vv.member<JobID>(stringify(n)));
}
+
+ void do_required(
+ const std::tr1::shared_ptr<Job> & result,
+ Deserialisator & v)
+ {
+ Deserialisator vv(*v.find_remove_member("required_confirmations"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ result->required_confirmations()->push_back(vv.member<std::tr1::shared_ptr<RequiredConfirmation> >(stringify(n)));
+ }
}
const std::tr1::shared_ptr<Job>
@@ -175,6 +197,7 @@ Job::deserialise(Deserialisation & d)
));
do_arrows(result, v);
do_existing(result, v);
+ do_required(result, v);
}
else if (d.class_name() == "UsableGroupJob")
{
@@ -188,6 +211,7 @@ Job::deserialise(Deserialisation & d)
result.reset(new UsableGroupJob(ids));
do_arrows(result, v);
do_existing(result, v);
+ do_required(result, v);
}
else if (d.class_name() == "SimpleInstallJob")
{
@@ -198,6 +222,7 @@ Job::deserialise(Deserialisation & d)
));
do_arrows(result, v);
do_existing(result, v);
+ do_required(result, v);
}
else if (d.class_name() == "UninstallJob")
{
@@ -208,6 +233,7 @@ Job::deserialise(Deserialisation & d)
));
do_arrows(result, v);
do_existing(result, v);
+ do_required(result, v);
}
else if (d.class_name() == "FetchJob")
{
@@ -218,6 +244,7 @@ Job::deserialise(Deserialisation & d)
));
do_arrows(result, v);
do_existing(result, v);
+ do_required(result, v);
}
else if (d.class_name() == "ErrorJob")
{
@@ -228,6 +255,7 @@ Job::deserialise(Deserialisation & d)
));
do_arrows(result, v);
do_existing(result, v);
+ do_required(result, v);
}
else
throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
@@ -274,6 +302,18 @@ UsableJob::used_existing_packages_when_ordering()
return _imp->used_existing_packages_when_ordering;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+UsableJob::required_confirmations() const
+{
+ return _imp->required_confirmations;
+}
+
+const std::tr1::shared_ptr<RequiredConfirmations>
+UsableJob::required_confirmations()
+{
+ return _imp->required_confirmations;
+}
+
const JobID
UsableJob::id() const
{
@@ -289,6 +329,8 @@ UsableJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "arrows", arrows())
.member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "required_confirmations", required_confirmations())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
"used_existing_packages_when_ordering", used_existing_packages_when_ordering())
;
}
@@ -332,6 +374,18 @@ UsableGroupJob::used_existing_packages_when_ordering()
return _imp->used_existing_packages_when_ordering;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+UsableGroupJob::required_confirmations() const
+{
+ return _imp->required_confirmations;
+}
+
+const std::tr1::shared_ptr<RequiredConfirmations>
+UsableGroupJob::required_confirmations()
+{
+ return _imp->required_confirmations;
+}
+
namespace
{
std::string stringify_job_id(const JobID & i)
@@ -355,6 +409,8 @@ UsableGroupJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "arrows", arrows())
.member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "job_ids", job_ids())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "required_confirmations", required_confirmations())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
"used_existing_packages_when_ordering", used_existing_packages_when_ordering())
;
}
@@ -405,6 +461,18 @@ FetchJob::used_existing_packages_when_ordering()
return _imp->used_existing_packages_when_ordering;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+FetchJob::required_confirmations() const
+{
+ return _imp->required_confirmations;
+}
+
+const std::tr1::shared_ptr<RequiredConfirmations>
+FetchJob::required_confirmations()
+{
+ return _imp->required_confirmations;
+}
+
const JobID
FetchJob::id() const
{
@@ -421,6 +489,8 @@ FetchJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null>(), "changes_to_make_decision", changes_to_make_decision())
.member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "required_confirmations", required_confirmations())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
"used_existing_packages_when_ordering", used_existing_packages_when_ordering())
;
}
@@ -471,6 +541,18 @@ SimpleInstallJob::used_existing_packages_when_ordering()
return _imp->used_existing_packages_when_ordering;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+SimpleInstallJob::required_confirmations() const
+{
+ return _imp->required_confirmations;
+}
+
+const std::tr1::shared_ptr<RequiredConfirmations>
+SimpleInstallJob::required_confirmations()
+{
+ return _imp->required_confirmations;
+}
+
const JobID
SimpleInstallJob::id() const
{
@@ -487,6 +569,8 @@ SimpleInstallJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null>(), "changes_to_make_decision", changes_to_make_decision())
.member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "required_confirmations", required_confirmations())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
"used_existing_packages_when_ordering", used_existing_packages_when_ordering())
;
}
@@ -537,6 +621,18 @@ UninstallJob::used_existing_packages_when_ordering()
return _imp->used_existing_packages_when_ordering;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+UninstallJob::required_confirmations() const
+{
+ return _imp->required_confirmations;
+}
+
+const std::tr1::shared_ptr<RequiredConfirmations>
+UninstallJob::required_confirmations()
+{
+ return _imp->required_confirmations;
+}
+
const JobID
UninstallJob::id() const
{
@@ -553,6 +649,8 @@ UninstallJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null>(), "remove_decision", remove_decision())
.member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "required_confirmations", required_confirmations())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
"used_existing_packages_when_ordering", used_existing_packages_when_ordering())
;
}
@@ -596,6 +694,18 @@ ErrorJob::used_existing_packages_when_ordering()
return _imp->used_existing_packages_when_ordering;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+ErrorJob::required_confirmations() const
+{
+ return _imp->required_confirmations;
+}
+
+const std::tr1::shared_ptr<RequiredConfirmations>
+ErrorJob::required_confirmations()
+{
+ return _imp->required_confirmations;
+}
+
const JobID
ErrorJob::id() const
{
@@ -612,6 +722,8 @@ ErrorJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null>(), "unable_to_make_decision", unable_to_make_decision())
.member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "required_confirmations", required_confirmations())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
"used_existing_packages_when_ordering", used_existing_packages_when_ordering())
;
}
diff --git a/paludis/resolver/job.hh b/paludis/resolver/job.hh
index 32455c5..a8fc79c 100644
--- a/paludis/resolver/job.hh
+++ b/paludis/resolver/job.hh
@@ -26,6 +26,7 @@
#include <paludis/resolver/resolution-fwd.hh>
#include <paludis/resolver/decision-fwd.hh>
#include <paludis/resolver/sync_point-fwd.hh>
+#include <paludis/resolver/required_confirmations-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/simple_visitor.hh>
#include <paludis/util/type_list.hh>
@@ -59,6 +60,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
virtual void serialise(Serialiser &) const = 0;
static const std::tr1::shared_ptr<Job> deserialise(
@@ -88,6 +95,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const;
@@ -116,6 +129,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const JobIDSequence> job_ids() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const;
@@ -146,6 +165,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const ChangesToMakeDecision> changes_to_make_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -177,6 +202,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const ChangesToMakeDecision> changes_to_make_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -208,6 +239,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const RemoveDecision> remove_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -239,6 +276,12 @@ namespace paludis
virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<RequiredConfirmations> required_confirmations()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const UnableToMakeDecision> unable_to_make_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 4d65294..daeb486 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -30,6 +30,8 @@
#include <paludis/resolver/resolver_lists.hh>
#include <paludis/resolver/job.hh>
#include <paludis/resolver/jobs.hh>
+#include <paludis/resolver/required_confirmations.hh>
+#include <paludis/resolver/resolver_functions.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/sequence-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
@@ -61,6 +63,7 @@ namespace paludis
struct Implementation<Orderer>
{
const Environment * const env;
+ const ResolverFunctions fns;
const std::tr1::shared_ptr<const Decider> decider;
const std::tr1::shared_ptr<ResolverLists> lists;
@@ -68,9 +71,11 @@ namespace paludis
ToOrder to_order;
Implementation(const Environment * const e,
+ const ResolverFunctions & f,
const std::tr1::shared_ptr<const Decider> & d,
const std::tr1::shared_ptr<ResolverLists> & l) :
env(e),
+ fns(f),
decider(d),
lists(l)
{
@@ -78,9 +83,11 @@ namespace paludis
};
}
-Orderer::Orderer(const Environment * const e, const std::tr1::shared_ptr<const Decider> & d,
+Orderer::Orderer(const Environment * const e,
+ const ResolverFunctions & f,
+ const std::tr1::shared_ptr<const Decider> & d,
const std::tr1::shared_ptr<ResolverLists> & l) :
- PrivateImplementationPattern<Orderer>(new Implementation<Orderer>(e, d, l))
+ PrivateImplementationPattern<Orderer>(new Implementation<Orderer>(e, f, d, l))
{
}
@@ -112,17 +119,25 @@ namespace
{
struct DecisionHandler
{
+ typedef std::tr1::function<void (
+ const std::tr1::shared_ptr<const Resolution> &,
+ const ChangesToMakeDecision &,
+ const std::tr1::shared_ptr<SimpleInstallJob> &)> MightNeedConfirmationFunction;
+
const std::tr1::shared_ptr<Resolution> resolution;
const std::tr1::shared_ptr<ResolverLists> lists;
ToOrder & to_order;
+ MightNeedConfirmationFunction might_need_confirmation;
DecisionHandler(
const std::tr1::shared_ptr<Resolution> & r,
const std::tr1::shared_ptr<ResolverLists> & l,
- ToOrder & o) :
+ ToOrder & o,
+ const MightNeedConfirmationFunction & m) :
resolution(r),
lists(l),
- to_order(o)
+ to_order(o),
+ might_need_confirmation(m)
{
}
@@ -196,6 +211,9 @@ namespace
value_for<n::failure_kinds>(FailureKinds()),
value_for<n::maybe_reason>(make_null_shared_ptr())
));
+
+ /* do we need confirmation of this? */
+ might_need_confirmation(resolution, d, install_job);
}
else
{
@@ -262,11 +280,37 @@ Orderer::_resolve_jobs()
i_end(_imp->lists->all_resolutions()->end()) ;
i != i_end ; ++i)
{
- DecisionHandler d(*i, _imp->lists, _imp->to_order);
+ DecisionHandler d(*i, _imp->lists, _imp->to_order, std::tr1::bind(
+ &Orderer::_confirm, this, std::tr1::placeholders::_1,
+ std::tr1::placeholders::_2, std::tr1::placeholders::_3));
(*i)->decision()->accept(d);
}
}
+void
+Orderer::_confirm(
+ const std::tr1::shared_ptr<const Resolution> & resolution,
+ const ChangesToMakeDecision & decision,
+ const std::tr1::shared_ptr<SimpleInstallJob> & job)
+{
+ if (! decision.best())
+ {
+ const std::tr1::shared_ptr<RequiredConfirmation> c(new NotBestConfirmation);
+ if (! _imp->fns.confirm_fn()(resolution->resolvent(), resolution, c))
+ job->required_confirmations()->push_back(c);
+ }
+
+ if (ct_downgrade == decision.change_type())
+ {
+ const std::tr1::shared_ptr<DowngradeConfirmation> c(new DowngradeConfirmation);
+ if (! _imp->fns.confirm_fn()(resolution->resolvent(), resolution, c))
+ job->required_confirmations()->push_back(c);
+ }
+
+ if (! job->required_confirmations()->empty())
+ _imp->lists->job_ids_needing_confirmation()->push_back(job->id());
+}
+
namespace
{
struct LabelArrowsInfo
diff --git a/paludis/resolver/orderer.hh b/paludis/resolver/orderer.hh
index 12523c6..76a8a60 100644
--- a/paludis/resolver/orderer.hh
+++ b/paludis/resolver/orderer.hh
@@ -31,6 +31,8 @@
#include <paludis/resolver/decider-fwd.hh>
#include <paludis/resolver/resolver-fwd.hh>
#include <paludis/resolver/job_id-fwd.hh>
+#include <paludis/resolver/job-fwd.hh>
+#include <paludis/resolver/decision-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/environment.hh>
@@ -56,9 +58,15 @@ namespace paludis
bool _remove_usable_cycles() PALUDIS_ATTRIBUTE((warn_unused_result));
void _cycle_error() PALUDIS_ATTRIBUTE((noreturn));
+ void _confirm(
+ const std::tr1::shared_ptr<const Resolution> &,
+ const ChangesToMakeDecision &,
+ const std::tr1::shared_ptr<SimpleInstallJob> &);
+
public:
Orderer(
const Environment * const,
+ const ResolverFunctions &,
const std::tr1::shared_ptr<const Decider> &,
const std::tr1::shared_ptr<ResolverLists> &);
~Orderer();
diff --git a/paludis/resolver/required_confirmations-fwd.hh b/paludis/resolver/required_confirmations-fwd.hh
new file mode 100644
index 0000000..2f8aabb
--- /dev/null
+++ b/paludis/resolver/required_confirmations-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_REQUIRED_CONFIRMATIONS_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_REQUIRED_CONFIRMATIONS_FWD_HH 1
+
+#include <paludis/util/sequence-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct RequiredConfirmation;
+ struct DowngradeConfirmation;
+ struct NotBestConfirmation;
+
+ typedef Sequence<std::tr1::shared_ptr<const RequiredConfirmation> > RequiredConfirmations;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/required_confirmations.cc b/paludis/resolver/required_confirmations.cc
new file mode 100644
index 0000000..ac0ad4a
--- /dev/null
+++ b/paludis/resolver/required_confirmations.cc
@@ -0,0 +1,73 @@
+/* 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/required_confirmations.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/serialise-impl.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+const std::tr1::shared_ptr<RequiredConfirmation>
+RequiredConfirmation::deserialise(Deserialisation & d)
+{
+ std::tr1::shared_ptr<RequiredConfirmation> result;
+
+ if (d.class_name() == "DowngradeConfirmation")
+ return DowngradeConfirmation::deserialise(d);
+ else if (d.class_name() == "NotBestConfirmation")
+ return NotBestConfirmation::deserialise(d);
+ else
+ throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
+
+ return result;
+}
+
+const std::tr1::shared_ptr<DowngradeConfirmation>
+DowngradeConfirmation::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "DowngradeConfirmation");
+ return make_shared_ptr(new DowngradeConfirmation);
+}
+
+void
+DowngradeConfirmation::serialise(Serialiser & s) const
+{
+ s.object("DowngradeConfirmation")
+ ;
+}
+
+const std::tr1::shared_ptr<NotBestConfirmation>
+NotBestConfirmation::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "NotBestConfirmation");
+ return make_shared_ptr(new NotBestConfirmation);
+}
+
+void
+NotBestConfirmation::serialise(Serialiser & s) const
+{
+ s.object("NotBestConfirmation")
+ ;
+}
+
+template class Sequence<std::tr1::shared_ptr<const RequiredConfirmation> >;
+template class WrappedForwardIterator<RequiredConfirmations::ConstIteratorTag, const std::tr1::shared_ptr<const RequiredConfirmation> >;
+
diff --git a/paludis/resolver/required_confirmations.hh b/paludis/resolver/required_confirmations.hh
new file mode 100644
index 0000000..7e8c517
--- /dev/null
+++ b/paludis/resolver/required_confirmations.hh
@@ -0,0 +1,68 @@
+/* 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_REQUIRED_CONFIRMATIONS_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_REQUIRED_CONFIRMATIONS_HH 1
+
+#include <paludis/resolver/required_confirmations-fwd.hh>
+#include <paludis/util/simple_visitor.hh>
+#include <paludis/util/type_list.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/serialise-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE RequiredConfirmation :
+ public virtual DeclareAbstractAcceptMethods<RequiredConfirmation, MakeTypeList<
+ DowngradeConfirmation, NotBestConfirmation>::Type>
+ {
+ public:
+ virtual void serialise(Serialiser &) const = 0;
+
+ static const std::tr1::shared_ptr<RequiredConfirmation> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE DowngradeConfirmation :
+ public RequiredConfirmation,
+ public ImplementAcceptMethods<RequiredConfirmation, DowngradeConfirmation>
+ {
+ public:
+ static const std::tr1::shared_ptr<DowngradeConfirmation> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void serialise(Serialiser &) const;
+ };
+
+ class PALUDIS_VISIBLE NotBestConfirmation :
+ public RequiredConfirmation,
+ public ImplementAcceptMethods<RequiredConfirmation, NotBestConfirmation>
+ {
+ public:
+ static const std::tr1::shared_ptr<NotBestConfirmation> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void serialise(Serialiser &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 0b308f8..41b2a61 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -61,6 +61,7 @@ namespace paludis
fns(f),
lists(new ResolverLists(make_named_values<ResolverLists>(
value_for<n::all_resolutions>(make_shared_ptr(new Resolutions)),
+ value_for<n::job_ids_needing_confirmation>(make_shared_ptr(new JobIDSequence)),
value_for<n::jobs>(make_shared_ptr(new Jobs)),
value_for<n::taken_error_job_ids>(make_shared_ptr(new JobIDSequence)),
value_for<n::taken_job_ids>(make_shared_ptr(new JobIDSequence)),
@@ -68,7 +69,7 @@ namespace paludis
value_for<n::untaken_job_ids>(make_shared_ptr(new JobIDSequence))
))),
decider(new Decider(e, f, lists)),
- orderer(new Orderer(e, decider, lists))
+ orderer(new Orderer(e, f, decider, lists))
{
}
};
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 780feb7..e0028c3 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -29,6 +29,7 @@
#include <paludis/resolver/decision-fwd.hh>
#include <paludis/resolver/destination_types-fwd.hh>
#include <paludis/resolver/constraint-fwd.hh>
+#include <paludis/resolver/required_confirmations-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/tribool-fwd.hh>
#include <paludis/filter-fwd.hh>
@@ -41,6 +42,7 @@ namespace paludis
{
struct allowed_to_remove_fn;
struct care_about_dep_fn;
+ struct confirm_fn;
struct find_repository_for_fn;
struct get_destination_types_for_fn;
struct get_initial_constraints_for_fn;
@@ -63,6 +65,12 @@ namespace paludis
const SanitisedDependency &
)> CareAboutDepFunction;
+ typedef std::tr1::function<bool (
+ const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const std::tr1::shared_ptr<const RequiredConfirmation> &
+ )> ConfirmFunction;
+
typedef std::tr1::function<const std::tr1::shared_ptr<const Repository> (
const Resolvent &,
const std::tr1::shared_ptr<const Resolution> &,
@@ -110,6 +118,7 @@ namespace paludis
{
NamedValue<n::allowed_to_remove_fn, AllowedToRemoveFunction> allowed_to_remove_fn;
NamedValue<n::care_about_dep_fn, CareAboutDepFunction> care_about_dep_fn;
+ NamedValue<n::confirm_fn, ConfirmFunction> confirm_fn;
NamedValue<n::find_repository_for_fn, FindRepositoryForFunction> find_repository_for_fn;
NamedValue<n::get_destination_types_for_fn, GetDestinationTypesForFunction> get_destination_types_for_fn;
NamedValue<n::get_initial_constraints_for_fn, GetInitialConstraintsFunction> get_initial_constraints_for_fn;
diff --git a/paludis/resolver/resolver_lists.cc b/paludis/resolver/resolver_lists.cc
index 80f095d..c2bbdbd 100644
--- a/paludis/resolver/resolver_lists.cc
+++ b/paludis/resolver/resolver_lists.cc
@@ -35,6 +35,7 @@ ResolverLists::serialise(Serialiser & s) const
s.object("ResolverLists")
.member(SerialiserFlags<serialise::might_be_null>(), "all_resolutions", all_resolutions())
.member(SerialiserFlags<serialise::might_be_null>(), "jobs", jobs())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "job_ids_needing_confirmation", job_ids_needing_confirmation())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "taken_error_job_ids", taken_error_job_ids())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "taken_job_ids", taken_job_ids())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "untaken_error_job_ids", untaken_error_job_ids())
@@ -47,6 +48,13 @@ ResolverLists::deserialise(Deserialisation & d)
{
Deserialisator v(d, "ResolverLists");
+ std::tr1::shared_ptr<JobIDSequence> job_ids_needing_confirmation(new JobIDSequence);
+ {
+ Deserialisator vv(*v.find_remove_member("job_ids_needing_confirmation"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ job_ids_needing_confirmation->push_back(vv.member<JobID>(stringify(n)));
+ }
+
std::tr1::shared_ptr<JobIDSequence> taken_error_job_ids(new JobIDSequence);
{
Deserialisator vv(*v.find_remove_member("taken_error_job_ids"), "c");
@@ -77,6 +85,7 @@ ResolverLists::deserialise(Deserialisation & d)
return make_named_values<ResolverLists>(
value_for<n::all_resolutions>(v.member<std::tr1::shared_ptr<Resolutions> >("all_resolutions")),
+ value_for<n::job_ids_needing_confirmation>(job_ids_needing_confirmation),
value_for<n::jobs>(v.member<std::tr1::shared_ptr<Jobs> >("jobs")),
value_for<n::taken_error_job_ids>(taken_error_job_ids),
value_for<n::taken_job_ids>(taken_job_ids),
diff --git a/paludis/resolver/resolver_lists.hh b/paludis/resolver/resolver_lists.hh
index 4c704fc..a69769e 100644
--- a/paludis/resolver/resolver_lists.hh
+++ b/paludis/resolver/resolver_lists.hh
@@ -33,6 +33,7 @@ namespace paludis
namespace n
{
struct all_resolutions;
+ struct job_ids_needing_confirmation;
struct jobs;
struct taken_error_job_ids;
struct taken_job_ids;
@@ -45,6 +46,7 @@ namespace paludis
struct ResolverLists
{
NamedValue<n::all_resolutions, std::tr1::shared_ptr<Resolutions> > all_resolutions;
+ NamedValue<n::job_ids_needing_confirmation, std::tr1::shared_ptr<JobIDSequence> > job_ids_needing_confirmation;
NamedValue<n::jobs, std::tr1::shared_ptr<Jobs> > jobs;
NamedValue<n::taken_error_job_ids, std::tr1::shared_ptr<JobIDSequence> > taken_error_job_ids;
NamedValue<n::taken_job_ids, std::tr1::shared_ptr<JobIDSequence> > taken_job_ids;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 18e7f8c..989746e 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -265,6 +265,15 @@ paludis::resolver::resolver_test::prefer_or_avoid_fn(
return indeterminate;
}
+bool
+paludis::resolver::resolver_test::confirm_fn(
+ const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const std::tr1::shared_ptr<const RequiredConfirmation> &)
+{
+ return true;
+}
+
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s),
@@ -318,6 +327,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
value_for<n::allowed_to_remove_fn>(std::tr1::bind(&allowed_to_remove_fn,
allowed_to_remove_names, std::tr1::placeholders::_1)),
value_for<n::care_about_dep_fn>(&care_about_dep_fn),
+ value_for<n::confirm_fn>(&confirm_fn),
value_for<n::find_repository_for_fn>(std::tr1::bind(&find_repository_for_fn,
&env, std::tr1::placeholders::_1, std::tr1::placeholders::_2,
std::tr1::placeholders::_3)),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 99b1fd2..7e19693 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -32,6 +32,7 @@
#include <paludis/resolver/resolver-fwd.hh>
#include <paludis/resolver/jobs-fwd.hh>
#include <paludis/resolver/resolver_functions-fwd.hh>
+#include <paludis/resolver/required_confirmations-fwd.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/environments/test/test_environment.hh>
@@ -98,6 +99,11 @@ namespace paludis
const std::tr1::shared_ptr<const Map<QualifiedPackageName, bool> > &,
const QualifiedPackageName &);
+ bool confirm_fn(
+ const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const std::tr1::shared_ptr<const RequiredConfirmation> &);
+
struct ResolverTestCase : test::TestCase
{
TestEnvironment env;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 0fadeea..64e937e 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1080,6 +1080,16 @@ namespace
return indeterminate;
}
+ bool confirm_fn(
+ const Environment * const,
+ const ResolveCommandLineResolutionOptions &,
+ const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const std::tr1::shared_ptr<const RequiredConfirmation> &)
+ {
+ return false;
+ }
+
void ser_thread_func(StringListStream & ser_stream, const ResolverLists & resolution_lists)
{
Serialiser ser(ser_stream);
@@ -1383,6 +1393,9 @@ paludis::cave::resolve_common(
value_for<n::care_about_dep_fn>(std::tr1::bind(&care_about_dep_fn,
env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1,
std::tr1::placeholders::_2, std::tr1::placeholders::_3)),
+ value_for<n::confirm_fn>(std::tr1::bind(&confirm_fn,
+ env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1,
+ std::tr1::placeholders::_2, std::tr1::placeholders::_3)),
value_for<n::find_repository_for_fn>(std::tr1::bind(&find_repository_for_fn,
env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1, std::tr1::placeholders::_2,
std::tr1::placeholders::_3)),